]>
jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - js/unrealircd-admin.js
4 /* TKL (un)select all checkbox */
5 function toggle_tkl(source
) {
6 checkboxes
= document
.getElementsByName("tklch[]");
7 for (var i
= 0, n
= checkboxes
.length
; i
< n
; i
++) {
8 checkboxes
[i
].checked
= source
.checked
;
13 /* TKL (un)select all checkbox */
14 function 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
;
22 /* TKL (un)select all checkbox */
23 function 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
;
30 /* TKL (un)select all checkbox */
31 function 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
;
38 function 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
;
45 function 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
;
52 function 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
;
59 function 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
;
66 function generate_notif(title
, body
)
68 /* generate a random number between 1000 and 90000 to use as an id */
71 const id
= Math
.floor(Math
.random() * (max
- min
+ 1)) + min
;
73 const toast
= document
.createElement('div');
74 toast
.classList
.add('toast', 'hide');
75 toast
.id
= 'toast' + id
;
77 toast
.ariaLive
= 'assertive';
78 toast
.ariaAtomic
= 'true';
79 toast
.setAttribute('data-delay', '5000');
81 const header
= document
.createElement('div');
82 header
.classList
.add('toast-header');
84 const theTitle
= document
.createElement('strong');
85 theTitle
.classList
.add('mr-auto');
86 theTitle
.textContent
= title
;
88 const notiftime
= document
.createElement('small');
89 notiftime
.textContent
= "Just now"; // always just now I think right :D
91 const closebutton
= document
.createElement('button');
92 closebutton
.type
= 'button';
93 closebutton
.classList
.add('ml-2', 'mb-1', 'close');
94 closebutton
.setAttribute('data-dismiss', 'toast');
95 closebutton
.ariaLabel
= 'Close';
97 const closebuttonspan
= document
.createElement('span');
98 closebuttonspan
.ariaHidden
= 'true';
99 closebuttonspan
.innerHTML
= "×";
101 const toastbody
= document
.createElement('div');
102 toastbody
.classList
.add('toast-body');
103 toastbody
.textContent
= body
;
106 /* put it all together */
107 closebutton
.appendChild(closebuttonspan
);
108 header
.appendChild(theTitle
);
109 header
.appendChild(notiftime
);
110 header
.appendChild(closebutton
);
111 toast
.appendChild(header
);
112 toast
.appendChild(toastbody
);
113 document
.getElementById('toaster').append(toast
);
115 $('#' + toast
.id
).toast('show');
118 $("#myModal").on('shown.bs.modal', function(){
119 $("#CloseButton").focus();
121 function StreamNotifs(e
)
125 data
= JSON
.parse(e
.data
);
129 title
= data
.subsystem
+ '.' + data
.event_id
;
131 generate_notif(title
, msg
);
133 function StartStreamNotifs(url
)
135 if (!!window
.EventSource
) {
136 var source
= new EventSource(url
);
137 source
.addEventListener('message', StreamNotifs
, false);