Skip to content

Commit 3087ef8

Browse files
committed
Add search
1 parent 0ea635b commit 3087ef8

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

src/pages/_template.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@
4747
margin-top: -1px;
4848
border-bottom: 1px dotted;
4949
}
50+
p {
51+
margin: 10px 0;
52+
}
5053
table {
5154
border: 1px solid #ccc;
5255
border-collapse: collapse;
@@ -68,6 +71,7 @@
6871
td, th {
6972
border-bottom: 1px solid #ccc;
7073
text-indent: .5rem;
74+
padding: 2px ;
7175
}
7276
th {
7377
border-color: #c4c9df;
@@ -107,6 +111,21 @@
107111
margin: 1.5rem 0;
108112
overflow: hidden;
109113
}
114+
#search {
115+
float: right;
116+
background: #fff;
117+
border: 1px solid #ccc;
118+
padding: .125rem .5rem;
119+
box-shadow: inset 0 1px 2px rgba(0, 0, 0, .2);
120+
color: #333;
121+
}
122+
#search:focus {
123+
border-color: #369;
124+
}
125+
.half {
126+
width: 50%;
127+
float: left;
128+
}
110129
</style>
111130
</head>
112131
<body>
@@ -167,6 +186,30 @@
167186
}
168187
}, true);
169188
}
189+
190+
var search = document.getElementById('search');
191+
192+
if (search) {
193+
search.value = '';
194+
search.focus();
195+
search.onkeyup = function () {
196+
var filter, table, tr, td, i;
197+
filter = this.value.toUpperCase();
198+
table = document.getElementsByTagName('table')[0];
199+
tr = table.getElementsByTagName('tr');
200+
201+
for (i = 0; i < tr.length; i++) {
202+
td = tr[i].getElementsByTagName('td')[0];
203+
if (td) {
204+
if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
205+
tr[i].style.display = '';
206+
} else {
207+
tr[i].style.display = 'none';
208+
}
209+
}
210+
}
211+
}
212+
}
170213
</script>
171214
</body>
172215
</html>

src/pages/default.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
array_pop($rdirs);
55
$rdirs = implode('/', $rdirs);
66
?>
7-
<p><a href="<?= ! empty($rdirs) ? $rdirs : '/' ?>">Parent dir</a></p>
7+
<p class="half"><a href="<?= ! empty($rdirs) ? $rdirs : '/' ?>">Parent dir</a></p>
8+
<?php endif ?>
9+
<?php if(! empty($paths)): ?>
10+
<p class="half" style="float: right"><input type="text" id="search" placeholder="Search..."></p>
811
<?php endif ?>
912
<table>
1013
<thead>

0 commit comments

Comments
 (0)