]>
jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blob - js/unrealircd-admin.js
8c7ee0c867cfd89f893602a1f24777bf88e2b4c2
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('position-fixed', 'bottom-0', 'right-0', 'p-4');
75 toast
.style
.right
= 0;
76 toast
.style
.zIndex
= 5;
77 toast
.style
.bottom
= "50px";
79 const inner
= document
.createElement('div');
80 inner
.classList
.add('toast', 'hide');
81 inner
.id
= 'toast' + id
;
83 inner
.ariaLive
= 'assertive';
84 inner
.ariaAtomic
= 'true';
85 inner
.setAttribute('data-delay', '5000');
87 const header
= document
.createElement('div');
88 header
.classList
.add('toast-header');
90 const theTitle
= document
.createElement('strong');
91 theTitle
.classList
.add('mr-auto');
92 theTitle
.textContent
= title
;
94 const notiftime
= document
.createElement('small');
95 notiftime
.textContent
= "Just now"; // always just now I think right :D
97 const closebutton
= document
.createElement('button');
98 closebutton
.type
= 'button';
99 closebutton
.classList
.add('ml-2', 'mb-1', 'close');
100 closebutton
.setAttribute('data-dismiss', 'toast');
101 closebutton
.ariaLabel
= 'Close';
103 const closebuttonspan
= document
.createElement('span');
104 closebuttonspan
.ariaHidden
= 'true';
105 closebuttonspan
.innerHTML
= "×";
107 const toastbody
= document
.createElement('div');
108 toastbody
.classList
.add('toast-body');
109 toastbody
.textContent
= body
;
112 /* put it all together */
113 closebutton
.appendChild(closebuttonspan
);
114 header
.appendChild(theTitle
);
115 header
.appendChild(notiftime
);
116 header
.appendChild(closebutton
);
117 inner
.appendChild(header
);
118 inner
.appendChild(toastbody
);
119 toast
.appendChild(inner
);
121 document
.body
.appendChild(toast
);
122 $('#' + inner
.id
).toast('show');
124 $("#myModal").on('shown.bs.modal', function(){
125 $("#CloseButton").focus();
127 function StreamNotifs(e
)
131 data
= JSON
.parse(e
.data
);
135 title
= data
.subsystem
+ '.' + data
.event_id
;
137 generate_notif(title
, msg
);
139 function StartStreamNotifs(url
)
141 if (!!window
.EventSource
) {
142 var source
= new EventSource(url
);
143 source
.addEventListener('message', StreamNotifs
, false);