fix filter

This commit is contained in:
Miao Wang 2022-03-30 23:07:41 +08:00
parent 2d7d80c20d
commit 6e7114689a
2 changed files with 8 additions and 23 deletions

View File

@ -44,31 +44,16 @@
<script>
(function () {
'use strict'
var userInput = document.getElementById('search')
var repoList = document.querySelectorAll('.filelist > tbody > tr')
userInput.addEventListener('input', function (evt) {
var pat = new RegExp(userInput.value, 'i')
Array.prototype.slice.call(repoList).forEach(function (tr) {
var a = tr.querySelector('a')
if (!pat.test(a.text)) {
tr.classList.add('hidden')
} else {
tr.classList.remove('hidden')
}
})
})
document.body.onkeyup = function (evt) {
document.body.addEventListener('keyup', function (evt) {
if (evt.keyCode === 83 && document.activeElement.tagName !== 'INPUT') {
userInput.scrollIntoView()
userInput.focus()
var userInput = document.getElementById('search');
userInput.scrollIntoView();
userInput.focus();
}
}
})
})()
</script>
<!-- Designed by Miaomiao Li. It's a wonderful life! -->
<!--
vim:ai:et:sta:ts=4:sts=4:sw=4
-->
-->

View File

@ -10,7 +10,7 @@
<script src="/static/js/jquery.min.js?{{ site.data['hash'] }}"></script>
<script src="/static/js/bootstrap.min.js?{{ site.data['hash'] }}"></script>
<script src="/static/js/bootstrap-select.min.js?{{ site.data['hash'] }}"></script>
<script src="/static/js/vue.min.js?{{ site.data['hash'] }}"></script>
<script src="/static/js/vue.min.js?{{ site.data['hash'] }}"></script>
<script src="/static/js/timeago.min.js?{{ site.data['hash'] }}"></script>
<script src="/static/js/markup.min.js?{{ site.data['hash'] }}"></script>
<script src="/static/js/webfont.js?{{ site.data['hash'] }}"></script>
@ -25,7 +25,7 @@
<div id="filelist">
<div>
<h3 id="filetitle">文件列表</h3>
<input placeholder="按 S 过滤" id="search" type="search" autocomplete="off" />
<input placeholder="按 S 过滤" v-model.trim="filter" id="search" type="search" autocomplete="off" />
</div>
<table class="filelist">
<thead>