aboutsummaryrefslogtreecommitdiff
path: root/assets_src/js/list.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets_src/js/list.js')
-rw-r--r--assets_src/js/list.js42
1 files changed, 27 insertions, 15 deletions
diff --git a/assets_src/js/list.js b/assets_src/js/list.js
index 25ff80d..413f517 100644
--- a/assets_src/js/list.js
+++ b/assets_src/js/list.js
@@ -1,17 +1,29 @@
1function clickSearchResult(resId) { 1import 'babel-polyfill';
2 var xhr = new XMLHttpRequest(); 2import * as search from './lib/search';
3 xhr.onreadystatechange = function() { 3import * as dom from './lib/dom';
4 if (xhr.readyState == XMLHttpRequest.DONE) { 4import * as ajax from './lib/ajax';
5 if (xhr.status !== 200) {
6 alert(xhr.status + ": " + xhr.response);
7 return;
8 }
9 5
10 data = xhr.responseText; 6async function resultClicked(grilId) {
11 document.getElementById("gril-list").innerHTML += data; 7 let response = null;
12 } 8 try {
9 response = await ajax.post(
10 window.location,
11 'id=' + grilId,
12 { headers: {
13 'Content-type': 'application/x-www-form-urlencoded'
14 } });
15 } catch (e) {
16 alert(e.message);
17 return;
13 } 18 }
14 xhr.open('POST', window.location, true); 19 document.getElementById('gril-list').innerHTML += response;
15 xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); 20}
16 xhr.send('id=' + resId); 21
17} \ No newline at end of file 22function main() {
23 let is = new search.InstantSearch(
24 document.getElementById('gril-add-search'),
25 document.getElementById('search-results'));
26 is.resultClicked = resultClicked;
27}
28
29dom.ready(main);