|
| 1 | +class Util { |
| 2 | + static refreshThreadList () { |
| 3 | + base.Database.get(base.Database.ONCE, "threads", (res) => { |
| 4 | + res = res.filter((thread, index, parent) => { |
| 5 | + if (thread !== "!SYSTEM") { |
| 6 | + thread.tid = index; |
| 7 | + return true; |
| 8 | + } |
| 9 | + }); |
| 10 | + |
| 11 | + for (let i = 0; i < res.length; i++) { |
| 12 | + let thread = DOM("A", { |
| 13 | + classes: ["mdl-list__item"], |
| 14 | + |
| 15 | + attributes: { |
| 16 | + Href: "Viewer/?tid=" + res[i].tid |
| 17 | + }, |
| 18 | + |
| 19 | + children: [ |
| 20 | + DOM("Span", { |
| 21 | + classes: ["mdl-list__item-primary-content"], |
| 22 | + |
| 23 | + children: [ |
| 24 | + DOM("I", { |
| 25 | + classes: ["mdl-list__item-avatar", "material-icons"], |
| 26 | + text: "person" |
| 27 | + }), |
| 28 | + |
| 29 | + DOM("Span", { |
| 30 | + text: res[i].title |
| 31 | + }) |
| 32 | + ] |
| 33 | + }) |
| 34 | + ] |
| 35 | + }); |
| 36 | + |
| 37 | + DOM("#Thread_Search").appendChild(thread); |
| 38 | + if (base.user) if (res[i].jobs.Owner.hasOwnProperty(base.user.uid)) DOM("#Thread_Admin").appendChild(thread); |
| 39 | + } |
| 40 | + }); |
| 41 | + } |
| 42 | +} |
| 43 | + |
1 | 44 | window.addEventListener("DOMContentLoaded", () => { |
2 | 45 | if (!base.user) { |
3 | 46 | DOM("$#Thread_Tab_Admin").setAttribute("Disabled", ""), |
4 | 47 | DOM("$#Thread_Admin").setAttribute("Disabled", ""); |
5 | 48 | } |
6 | 49 |
|
7 | | - base.Database.get(base.Database.ONCE, "threads", (res) => { |
8 | | - res = res.filter((thread, index, parent) => { |
9 | | - if (thread !== "!SYSTEM") { |
10 | | - thread.tid = index; |
11 | | - return true; |
12 | | - } |
13 | | - }); |
14 | | - |
15 | | - for (let i = 0; i < res.length; i++) { |
16 | | - let thread = DOM("A", { |
17 | | - classes: ["mdl-list__item"], |
18 | | - |
19 | | - attributes: { |
20 | | - Href: "Viewer/?tid=" + res[i].tid |
21 | | - }, |
22 | | - |
23 | | - children: [ |
24 | | - DOM("Span", { |
25 | | - classes: ["mdl-list__item-primary-content"], |
26 | | - |
27 | | - children: [ |
28 | | - DOM("I", { |
29 | | - classes: ["mdl-list__item-avatar", "material-icons"], |
30 | | - text: "person" |
31 | | - }), |
32 | | - |
33 | | - DOM("Span", { |
34 | | - text: res[i].title |
35 | | - }) |
36 | | - ] |
37 | | - }) |
38 | | - ] |
39 | | - }); |
40 | | - |
41 | | - DOM("#Thread_Search").appendChild(thread); |
42 | | - if (base.user) if (res[i].jobs.Owner.hasOwnProperty(base.user.uid)) DOM("#Thread_Admin").appendChild(thread); |
43 | | - } |
44 | | - }); |
| 50 | + Util.refreshThreadList(); |
45 | 51 |
|
46 | 52 |
|
47 | 53 |
|
@@ -69,6 +75,13 @@ window.addEventListener("DOMContentLoaded", () => { |
69 | 75 | }); |
70 | 76 | }); |
71 | 77 |
|
| 78 | + DOM("#Thread_Tab_Reload").addEventListener("click", (event) => { |
| 79 | + while (DOM("#Thread_Search").children.length > 1) DOM("#Thread_Search").children[1].remove(); |
| 80 | + while (DOM("#Thread_Admin").children.length > 1) DOM("#Thread_Admin").children[1].remove(); |
| 81 | + |
| 82 | + Util.refreshThreadList(); |
| 83 | + }); |
| 84 | + |
72 | 85 |
|
73 | 86 |
|
74 | 87 | let doc = parent.document; |
|
0 commit comments