aboutsummaryrefslogtreecommitdiff
path: root/assets_src/js/gril.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets_src/js/gril.js')
-rw-r--r--assets_src/js/gril.js84
1 files changed, 42 insertions, 42 deletions
diff --git a/assets_src/js/gril.js b/assets_src/js/gril.js
index 561c221..7d92b5a 100644
--- a/assets_src/js/gril.js
+++ b/assets_src/js/gril.js
@@ -3,45 +3,45 @@ import * as dom from './lib/dom';
3import * as ajax from './lib/ajax'; 3import * as ajax from './lib/ajax';
4 4
5dom.ready(() => { 5dom.ready(() => {
6 $('.modal-trigger').leanModal({ 6 $('.modal-trigger').leanModal({
7 async ready() { 7 async ready() {
8 const el = document.getElementById('modal-add-gril-content'); 8 const el = document.getElementById('modal-add-gril-content');
9 9
10 el.innerHTML = ` 10 el.innerHTML = `
11 <div class="progress"> 11 <div class="progress">
12 <div class="indeterminate"></div> 12 <div class="indeterminate"></div>
13 </div>`; 13 </div>`;
14 14
15 let data = {}; 15 let data = {};
16 try { 16 try {
17 data = JSON.parse(await ajax.get('/api/lists/user')); 17 data = JSON.parse(await ajax.get('/api/lists/user'));
18 } catch(e) { 18 } catch(e) {
19 console.error(e); 19 console.error(e);
20 } 20 }
21 21
22 el.innerHTML = ''; 22 el.innerHTML = '';
23 23
24 data.forEach(d => { 24 data.forEach(d => {
25 const element = document.createElement('a'); 25 const element = document.createElement('a');
26 element.innerHTML = d.Name; 26 element.innerHTML = d.Name;
27 element.className = 'collection-item purple-text text-lighten-2'; 27 element.className = 'collection-item purple-text text-lighten-2';
28 element.addEventListener('click', async () => { 28 element.addEventListener('click', async () => {
29 try { 29 try {
30 await ajax.post( 30 await ajax.post(
31 `/list/${d.ID}`, 31 `/list/${d.ID}`,
32 'id=' + window.location.href.match(/\/gril\/([0-9]{1,})\//)[1], 32 'id=' + window.location.href.match(/\/gril\/([0-9]{1,})\//)[1],
33 { headers: { 33 { headers: {
34 'Content-type': 'application/x-www-form-urlencoded' 34 'Content-type': 'application/x-www-form-urlencoded'
35 } }); 35 } });
36 $('#modal_add_gril').closeModal(); 36 $('#modal_add_gril').closeModal();
37 } catch(e) { 37 } catch(e) {
38 console.error(e); 38 console.error(e);
39 } 39 }
40 40
41 return true; 41 return true;
42 }); 42 });
43 el.appendChild(element); 43 el.appendChild(element);
44 }); 44 });
45 }, 45 },
46 }); 46 });
47}); \ No newline at end of file 47});