aboutsummaryrefslogtreecommitdiff
path: root/assets_src/js/lib
diff options
context:
space:
mode:
authorrtz12 <koenig@fagott.pw>2016-01-20 18:34:19 (UTC)
committerrtz12 <koenig@fagott.pw>2016-01-20 18:34:19 (UTC)
commit5325336ea46e4347f4ca12d4daaeec6269ce6c7b (patch)
treee608e0eecc6da33aa23fd7811c2e488cfe22ce5d /assets_src/js/lib
parent94da9601d1d17ddeaf1d7d5ea8df68008e90f3ab (diff)
Buildsystem verfeinert
Dafuer JS temporaer kaputtgemacht
Diffstat (limited to 'assets_src/js/lib')
-rw-r--r--assets_src/js/lib/search.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/assets_src/js/lib/search.js b/assets_src/js/lib/search.js
new file mode 100644
index 0000000..0cb33df
--- /dev/null
+++ b/assets_src/js/lib/search.js
@@ -0,0 +1,40 @@
1var strokeTimeout = null;
2
3function instantSearch() {
4 if (strokeTimeout) {
5 clearTimeout(strokeTimeout);
6 }
7 strokeTimeout = setTimeout(doSearch, 150);
8}
9
10function doSearch() {
11 value = document.getElementById("search").value;
12
13 if (value === "") {
14 strokeTimeout = null;
15 document.getElementById("search-results").innerHTML = "";
16 return;
17 }
18 var xhr = new XMLHttpRequest();
19 xhr.onreadystatechange = function() {
20 if (xhr.readyState == XMLHttpRequest.DONE) {
21 if (xhr.status === 404 || xhr.status === 400 || typeof xhr.response === 'undefined' || xhr.response === '404 not found') {
22 document.getElementById("search-results").innerHTML = '';
23 return
24 }
25 if (value === "") {
26 document.getElementById("search-results").innerHTML = "";
27 return;
28 }
29
30 document.getElementById("search-results").innerHTML = xhr.response.replace(new RegExp('{ (.*?)(' + value + ')(.*?) }', 'gi'), "$1<b>$2</b>$3").replace(new RegExp('{ (.*?) }', 'gi'), '$1');
31 }
32 }
33 xhr.open('GET', '/search/gril_instant/' + value, true);
34 xhr.send(null);
35 strokeTimeout = null;
36}
37
38function clickSearchResult(resId) {
39
40} \ No newline at end of file