aboutsummaryrefslogtreecommitdiff
path: root/assets
diff options
context:
space:
mode:
authorjan <jan@ruken.pw>2015-12-30 14:08:03 (UTC)
committerjan <jan@ruken.pw>2015-12-30 14:08:03 (UTC)
commita46963a6f9dff657a180ba0c6871c015871a80f5 (patch)
tree15adfd0298ff1d2fdfec62ceaabf8a904d811e74 /assets
parent36d7f9a0551a98eda1ff2a871254ff19128e7f63 (diff)
instant. fucking. suche.
Diffstat (limited to 'assets')
-rw-r--r--assets/css/list.css5
-rw-r--r--assets/js/search.js31
2 files changed, 36 insertions, 0 deletions
diff --git a/assets/css/list.css b/assets/css/list.css
index 7e6dde9..601f69b 100644
--- a/assets/css/list.css
+++ b/assets/css/list.css
@@ -24,4 +24,9 @@
24 background-size: cover; 24 background-size: cover;
25 width: 64px; 25 width: 64px;
26 height: 64px; 26 height: 64px;
27}
28
29.search-results {
30 top: -50px;
31 z-index: 2;
27} \ No newline at end of file 32} \ No newline at end of file
diff --git a/assets/js/search.js b/assets/js/search.js
new file mode 100644
index 0000000..0f544ab
--- /dev/null
+++ b/assets/js/search.js
@@ -0,0 +1,31 @@
1var strokeTimeout = null;
2
3function instantSearch() {
4 value = document.getElementById("search").value;
5
6 if (strokeTimeout) {
7 clearTimeout(strokeTimeout);
8 }
9 strokeTimeout = setTimeout(doSearch, 150, value);
10}
11
12function doSearch(value) {
13 if (value == "") {
14 strokeTimeout = null;
15 return;
16 }
17 var xhr = new XMLHttpRequest();
18 xhr.onreadystatechange = function() {
19 if (xhr.readyState == XMLHttpRequest.DONE) {
20 if (xhr.status === 404 || xhr.status === 400 || typeof xhr.response === 'undefined') {
21 console.log(xhr.status);
22 document.getElementById("search-results").innerHTML = '';
23 }
24 document.getElementById("search-results").innerHTML = xhr.response;
25 }
26 }
27 console.log(value);
28 xhr.open('GET', '/search/gril_instant/' + value, true);
29 xhr.send(null);
30 strokeTimeout = null;
31} \ No newline at end of file