]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blame - js/unrealircd-admin.js
Set "issuer" already in connection call. This to speed up connection
[irc/unrealircd/unrealircd-webpanel.git] / js / unrealircd-admin.js
CommitLineData
8cfa32c5 1
76200e36
VP
2
3
4/* TKL (un)select all checkbox */
26971737 5function toggle_tkl(source) {
76200e36
VP
6 checkboxes = document.getElementsByName("tklch[]");
7 for (var i = 0, n = checkboxes.length; i < n; i++) {
8 checkboxes[i].checked = source.checked;
9 }
26971737
VP
10}
11
12
13/* TKL (un)select all checkbox */
14function toggle_user(source) {
15 checkboxes = document.getElementsByName("userch[]");
16 for (var i = 0, n = checkboxes.length; i < n; i++) {
17 checkboxes[i].checked = source.checked;
18 }
19}
20
f41baac8
VP
21
22/* TKL (un)select all checkbox */
23function toggle_server(source) {
24 checkboxes = document.getElementsByName("serverch[]");
25 for (var i = 0, n = checkboxes.length; i < n; i++) {
26 checkboxes[i].checked = source.checked;
27 }
28}
29
26971737
VP
30/* TKL (un)select all checkbox */
31function toggle_sf(source) {
32 checkboxes = document.getElementsByName("sf[]");
33 for (var i = 0, n = checkboxes.length; i < n; i++) {
34 checkboxes[i].checked = source.checked;
35 }
d1d9caa9
VP
36}
37
119fee10
VP
38function toggle_chanbans(source) {
39 checkboxes = document.getElementsByName("cb_checkboxes[]");
40 for (var i = 0, n = checkboxes.length; i < n; i++) {
41 checkboxes[i].checked = source.checked;
42 }
43}
44
45function toggle_chanexs(source) {
46 checkboxes = document.getElementsByName("ce_checkboxes[]");
47 for (var i = 0, n = checkboxes.length; i < n; i++) {
48 checkboxes[i].checked = source.checked;
49 }
50}
51
52function toggle_chaninvs(source) {
53 checkboxes = document.getElementsByName("ci_checkboxes[]");
54 for (var i = 0, n = checkboxes.length; i < n; i++) {
55 checkboxes[i].checked = source.checked;
56 }
57}
58
a85c268f
VP
59function toggle_checkbox(source) {
60 checkboxes = document.getElementsByName("checkboxes[]");
61 for (var i = 0, n = checkboxes.length; i < n; i++) {
62 checkboxes[i].checked = source.checked;
63 }
2d62c85d 64}
2751c89d
VP
65
66function generate_notif(title, body)
67{
68 /* generate a random number between 1000 and 90000 to use as an id */
69 const min = 1000;
70 const max = 90000;
71 const id = Math.floor(Math.random() * (max - min + 1)) + min;
72
73 const toast = document.createElement('div');
1c363d5e
VP
74 toast.classList.add('toast', 'hide');
75 toast.id = 'toast' + id;
76 toast.role = 'alert';
77 toast.ariaLive = 'assertive';
78 toast.ariaAtomic = 'true';
e65f1f65 79 toast.setAttribute('data-delay', '10000');
2751c89d
VP
80
81 const header = document.createElement('div');
82 header.classList.add('toast-header');
83
84 const theTitle = document.createElement('strong');
85 theTitle.classList.add('mr-auto');
86 theTitle.textContent = title;
87
52cc6126
VP
88 const notiftime = document.createElement('div');
89 notiftime.classList.add('badge', 'rounded-pill', 'badge-primary', 'ml-1');
90 notiftime.textContent = 'Just now'; // always just now I think right :D
2751c89d
VP
91
92 const closebutton = document.createElement('button');
93 closebutton.type = 'button';
94 closebutton.classList.add('ml-2', 'mb-1', 'close');
95 closebutton.setAttribute('data-dismiss', 'toast');
96 closebutton.ariaLabel = 'Close';
97
98 const closebuttonspan = document.createElement('span');
99 closebuttonspan.ariaHidden = 'true';
100 closebuttonspan.innerHTML = "&times;";
101
102 const toastbody = document.createElement('div');
103 toastbody.classList.add('toast-body');
104 toastbody.textContent = body;
105
106
107 /* put it all together */
108 closebutton.appendChild(closebuttonspan);
109 header.appendChild(theTitle);
110 header.appendChild(notiftime);
111 header.appendChild(closebutton);
1c363d5e
VP
112 toast.appendChild(header);
113 toast.appendChild(toastbody);
114 document.getElementById('toaster').append(toast);
2751c89d 115
1c363d5e 116 $('#' + toast.id).toast('show');
2751c89d 117}
1c363d5e 118
2751c89d
VP
119function StreamNotifs(e)
120{
121 var data;
122 try {
123 data = JSON.parse(e.data);
124 } catch(e) {
125 return;
126 }
127 title = data.subsystem + '.' + data.event_id;
128 msg = data.msg;
129 generate_notif(title, msg);
130}
131function StartStreamNotifs(url)
132{
133 if (!!window.EventSource) {
134 var source = new EventSource(url);
135 source.addEventListener('message', StreamNotifs, false);
136 }
137}