diff options
author | rtz12 <koenig@fagott.pw> | 2016-01-17 21:31:12 (UTC) |
---|---|---|
committer | rtz12 <koenig@fagott.pw> | 2016-01-17 21:31:12 (UTC) |
commit | 72ad0e53f3887b5ad74034a99c6453a88eeb0cbd (patch) | |
tree | a2b83127f37ff1706e593f15299cd6e7347f788a /assets_src/js | |
parent | 6cb2de0a1f583ef8d018e430181a7414fa7faff1 (diff) |
Geiles neues Buildsystem fuer die Assets
Diffstat (limited to 'assets_src/js')
-rw-r--r-- | assets_src/js/list.js | 17 | ||||
-rw-r--r-- | assets_src/js/search.js | 40 |
2 files changed, 57 insertions, 0 deletions
diff --git a/assets_src/js/list.js b/assets_src/js/list.js new file mode 100644 index 0000000..25ff80d --- /dev/null +++ b/assets_src/js/list.js | |||
@@ -0,0 +1,17 @@ | |||
1 | function clickSearchResult(resId) { | ||
2 | var xhr = new XMLHttpRequest(); | ||
3 | xhr.onreadystatechange = function() { | ||
4 | if (xhr.readyState == XMLHttpRequest.DONE) { | ||
5 | if (xhr.status !== 200) { | ||
6 | alert(xhr.status + ": " + xhr.response); | ||
7 | return; | ||
8 | } | ||
9 | |||
10 | data = xhr.responseText; | ||
11 | document.getElementById("gril-list").innerHTML += data; | ||
12 | } | ||
13 | } | ||
14 | xhr.open('POST', window.location, true); | ||
15 | xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); | ||
16 | xhr.send('id=' + resId); | ||
17 | } \ No newline at end of file | ||
diff --git a/assets_src/js/search.js b/assets_src/js/search.js new file mode 100644 index 0000000..0cb33df --- /dev/null +++ b/assets_src/js/search.js | |||
@@ -0,0 +1,40 @@ | |||
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 | ||