1
0
mirror of https://github.com/RSS-Bridge/rss-bridge.git synced 2025-08-07 00:56:34 +02:00

Add a search bar to simplify looking for a bridge. (#494)

* Add a search bar to simplify looking for a bridge.

* Fix phpcs line length.

* Change the phpcs config.
This commit is contained in:
Teromene
2017-03-21 20:31:10 +00:00
committed by GitHub
parent 2ac0469750
commit 1a4c3f4418
6 changed files with 78 additions and 7 deletions

27
static/search.js Normal file
View File

@@ -0,0 +1,27 @@
function search() {
var searchTerm = document.getElementById('searchfield').value;
var searchableElements = document.getElementsByTagName('section');
var regexMatch = new RegExp(searchTerm, "i");
for(var i = 0; i < searchableElements.length; i++) {
var textValue = searchableElements[i].getAttribute('data-ref');
if(textValue != null) {
if(textValue.match(regexMatch) == null && searchableElements[i].style.display != "none") {
searchableElements[i].style.display = "none";
} else if(textValue.match(regexMatch) != null) {
searchableElements[i].style.display = "block";
}
}
}
}