diff options
Diffstat (limited to 'assets_src/js/search.js')
-rw-r--r-- | assets_src/js/search.js | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/assets_src/js/search.js b/assets_src/js/search.js deleted file mode 100644 index 0cb33df..0000000 --- a/assets_src/js/search.js +++ /dev/null | |||
@@ -1,40 +0,0 @@ | |||
1 | var strokeTimeout = null; | ||
2 | |||
3 | function instantSearch() { | ||
4 | if (strokeTimeout) { | ||
5 | clearTimeout(strokeTimeout); | ||
6 | } | ||
7 | strokeTimeout = setTimeout(doSearch, 150); | ||
8 | } | ||
9 | |||
10 | function 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 | |||
38 | function clickSearchResult(resId) { | ||
39 | |||
40 | } \ No newline at end of file | ||