Added quick filter in popup if there are more entries

This commit is contained in:
Ashus 2018-08-04 01:39:44 +02:00 committed by Jonathan White
parent afe66d3656
commit bfa5548715
3 changed files with 29 additions and 0 deletions

View file

@ -62,3 +62,11 @@ body {
float: right;
height: 30px;
}
#login-filter {
outline:none;
border-radius: 4px 0 0 4px;
border: 1px solid #ccc;
margin-bottom: 5px;
padding: 2px 10px;
width: 100%;
}

View file

@ -29,6 +29,10 @@
<p>
Select the login information you would like to get entered into the page:
</p>
<div id="filter-block" style="display: none;">
<label for="login-filter">Filter:</label>
<input type="text" id="login-filter">
</div>
<div id="login-list" class="list-group"></div>
</div>
</div>

View file

@ -25,6 +25,23 @@ $(function() {
});
ll.appendChild(a);
}
if (logins.length > 1) {
document.getElementById('filter-block').style = '';
let filter = document.getElementById('login-filter');
filter.addEventListener('keyup', (e) => {
let val = filter.value;
let re = new RegExp(val, 'i');
let links = ll.getElementsByTagName('a');
for (let i in links) {
if (links.hasOwnProperty(i)) {
let found = String(links[i].textContent).match(re) !== null;
links[i].style = found ? '' : 'display: none;';
}
}
});
filter.focus();
}
});
});