PluginProbe
WebTotem Security / 2.4.18
WebTotem Security v2.4.18
3.0.2 3.0.1 3.0.0 trunk 1.0 1.1 1.2 1.3 1.3.1 1.3.2 1.3.3 2.0 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.1 2.2.2 2.2.3 All 110 releases
wt-security / includes / js / main.js

main.js in WebTotem Security 2.4.18, at includes/js/main.js

252 lines 13.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1
2 jQuery(document).ready(function ($) {
3
4 $('#wtotem-dos').on('change', function () {
5 let checked = $(this).prop('checked');
6 toggleLimits($('#wtotem-dos-limit'), $('#wtotem-dos-limit input'), checked);
7 });
8
9 $('#wtotem-login-attempts').on('change', function () {
10 let checked = $(this).prop('checked');
11 toggleLimits($('#wtotem-login-attempts-limit'), $('#wtotem-login-attempts-limit input'), checked);
12 });
13
14 function toggleLimits(limitWrap, limitInput, checked) {
15 (checked) ? limitWrap.removeClass('visually-hidden') : limitWrap.addClass('visually-hidden');
16 (checked) ? limitInput.removeAttr('disabled') : limitInput.attr('disabled', 'disabled');
17 }
18
19 $('body').on('click', 'ul.wtotem-tabs__caption li:not(.active)', function () {
20 $(this)
21 .addClass('active').siblings().removeClass('active')
22 .closest('div.wtotem-tabs').find('div.wtotem-tabs__content').removeClass('active').eq($(this).index()).addClass('active');
23 });
24
25 $('body').on('click', '#wtotem_ps_settings', function () {
26 $('.popup-overlay').removeClass('d-none');
27 }).on('click', '.port-scanner-list__header--close', function (e) {
28 $('.popup-overlay').addClass('d-none');
29 }).on('click', '.popup-overlay', function (e) {
30 if (e.target.className.includes('popup-overlay')) {
31 $('.popup-overlay').addClass('d-none');
32 $('body').removeClass('lock');
33 }
34 }).on('click', '.firewall-configuration__multi-adding', function () {
35 $('#wtotem-ip-list-type').val($(this).attr('data-list'));
36 }).on('click', '.wtotem_reports-accordion__title', function () {
37 $(this).next('div').toggleClass('visually-hidden')
38 }).on('click', '.wtotem_alert__close', function () {
39 $(this).parent('.wtotem_alert').remove();
40 });
41
42 // Pop-up notification options.
43 toastr.options = {
44 "closeButton": true,
45 "debug": false,
46 "newestOnTop": false,
47 "progressBar": true,
48 "positionClass": "toast-top-right",
49 "preventDuplicates": false,
50 "onclick": null,
51 "showDuration": "300",
52 "hideDuration": "5000",
53 "timeOut": "5000",
54 "extendedTimeOut": "1000",
55 "showEasing": "swing",
56 "hideEasing": "linear",
57 "showMethod": "fadeIn",
58 "hideMethod": "fadeOut"
59 }
60
61 });
62
63
64 // Hamburger menu.
65 const burgerEl = document.querySelector(".wtotem_burger");
66 const menuEl = document.querySelector(".wtotem_nav");
67 const bodyEl = document.getElementsByTagName("body")[0];
68
69 if (burgerEl) {
70 burgerEl.addEventListener("click", () => {
71 burgerEl.classList.toggle("active");
72 menuEl.classList.toggle("active");
73 // Adds body overflow hidden when the menu is open.
74 bodyEl.classList.toggle("lock");
75 });
76 }
77
78 // Report generate Modal.
79 const reportsBtn = document.querySelectorAll(".add_report");
80 const reportsModal = document.querySelector(".wtotem_reports-modal");
81 const reportsModalClose = document.querySelector(".wtotem_reports-modal__close");
82 const reportsModalMessage = document.querySelector("#wtotem_reports_form-messages");
83
84 if (reportsBtn) {
85 for (let elem of reportsBtn) {
86 elem.addEventListener("click", () => {
87 reportsModal.classList.add("wtotem_reports-modal--active");
88 bodyEl.classList.add("lock");
89 });
90 }
91 }
92
93 if (reportsModalClose) {
94 reportsModalClose.addEventListener("click", () => {
95 reportsModal.classList.remove("wtotem_reports-modal--active");
96 bodyEl.classList.remove("lock");
97 reportsModalMessage.innerHTML = '';
98 });
99 }
100
101
102 const addSideModal = (modal, openButton, closeButton, form) => {
103
104 const overlay = document.querySelector(".side-modal__overlay");
105 const message = document.querySelector(".wtotem_input__messages");
106 const bodyEl = document.getElementsByTagName("body")[0];
107 const toggleClassName = "side-modal--opened";
108 const toggleBody = "lock";
109
110 const showModal = () => {
111 modal.classList.add(toggleClassName);
112 bodyEl.classList.add(toggleBody);
113 };
114
115 const closeModal = () => {
116 modal.classList.remove(toggleClassName);
117 bodyEl.classList.remove(toggleBody);
118 if (form) {
119 form.reset();
120 message.innerHTML = '';
121 }
122 };
123
124 openButton.addEventListener("click", showModal);
125 closeButton.addEventListener("click", closeModal);
126 overlay.addEventListener("click", closeModal);
127 };
128
129 (function () {
130 const modal = document.querySelector(".firewall-multi-adding");
131 const openButton = document.querySelector(".firewall-configuration__multi-adding");
132 const openButton2 = document.querySelector(".multi-adding-deny_list");
133 const closeButton = document.querySelector(".firewall-multi-adding__close");
134 const form = document.querySelector("#wtotem-allow-deny-multi-add-form");
135
136 if (modal) {
137 addSideModal(modal, openButton, closeButton, form);
138 addSideModal(modal, openButton2, closeButton, form);
139 }
140 })();
141
142 (function () {
143 const modal = document.querySelector(".country-blocking-modal");
144 const openButton = document.querySelector("#block_countries_btn");
145 const closeButton = document.querySelector(".country-blocking-modal__closeBtn");
146
147 if (modal) {
148 addSideModal(modal, openButton, closeButton, false);
149 }
150 })();
151
152 window.addEventListener('DOMContentLoaded', function () {
153
154 function tlite(t) {
155 document.addEventListener("mouseover", function (e) {
156 var i = e.target, n = t(i);
157 n || (n = (i = i.parentElement) && t(i)), n && tlite.show(i, n, !0)
158 })
159 }
160
161 tlite.show = function (t, e, i) {
162 var n = "data-tlite";
163 e = e || {}, (t.tooltip || function (t, e) {
164 function o() {
165 tlite.hide(t, !0)
166 }
167
168 function l() {
169 r || (r = function (t, e, i) {
170 function n() {
171 o.className = "tlite tlite-" + r + s;
172 var e = t.offsetTop, i = t.offsetLeft;
173 o.offsetParent === t && (e = i = 0);
174 var n = t.offsetWidth, l = t.offsetHeight, d = o.offsetHeight, f = o.offsetWidth, a = i + n / 2;
175 o.style.top = ("s" === r ? e - d - 10 : "n" === r ? e + l + 10 : e + l / 2 - d / 2) + "px", o.style.left = ("w" === s ? i : "e" === s ? i + n - f : "w" === r ? i + n + 10 : "e" === r ? i - f - 10 : a - f / 2) + "px"
176 }
177
178 var o = document.createElement("span"), l = i.grav || t.getAttribute("data-tlite") || "n";
179 o.innerHTML = e, t.appendChild(o);
180 var r = l[0] || "", s = l[1] || "";
181 n();
182 var d = o.getBoundingClientRect();
183 return "s" === r && d.top < 0 ? (r = "n", n()) : "n" === r && d.bottom > window.innerHeight ? (r = "s", n()) : "e" === r && d.left < 0 ? (r = "w", n()) : "w" === r && d.right > window.innerWidth && (r = "e", n()), o.className += " tlite-visible", o
184 }(t, d, e))
185 }
186
187 var r, s, d;
188 return t.addEventListener("mousedown", o), t.addEventListener("mouseleave", o), t.tooltip = {
189 show: function () {
190 d = t.title || t.getAttribute(n) || d, t.title = "", t.setAttribute(n, ""), d && !s && (s = setTimeout(l, i ? 150 : 1))
191 }, hide: function (t) {
192 if (i === t) {
193 s = clearTimeout(s);
194 var e = r && r.parentNode;
195 e && e.removeChild(r), r = void 0
196 }
197 }
198 }
199 }(t, e)).show()
200 }, tlite.hide = function (t, e) {
201 t.tooltip && t.tooltip.hide(e)
202 }, "undefined" != typeof module && module.exports && (module.exports = tlite);
203
204 // init tooltip with class js--tooltip
205 tlite(el => {
206 return {
207 el: el.classList.contains('js--tooltip'), grav: 'sw',
208 }
209 });
210
211 });
212
213 /**
214 * Calendar init
215 *
216 * @param element
217 * Input selector element with the start date of the period.
218 * @param dateFromSelector
219 * Input selector with the start date of the period.
220 * @param dateToSelector
221 * Input selector with the end date of the period.
222 * @param toggler
223 * Selector element of the wrapper of the elements that open the calendar when clicked.
224 * @returns {*}
225 * @private
226 */
227 const setFlatpickr_ = (element, dateFromSelector, dateToSelector, toggler) => {
228 const calendar = flatpickr(element,
229 {
230 mode: "range",
231 dateFormat: "j M, Y",
232 onChange: function (selectedDates) {
233 debugger;
234 const dates = selectedDates.map(date => this.formatDate(date, "j M, Y"));
235 document.querySelector(dateFromSelector).value = dates[0];
236 if (dates[1]) {
237 document.querySelector(dateToSelector).value = dates[1];
238 }
239 }
240 });
241
242 toggler.addEventListener("click", calendar.open);
243
244 return calendar;
245 };
246
247 /*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
248 var saveAs=saveAs||function(e){"use strict";if(typeof e==="undefined"||typeof navigator!=="undefined"&&/MSIE [1-9]\./.test(navigator.userAgent)){return}var t=e.document,n=function(){return e.URL||e.webkitURL||e},r=t.createElementNS("http://www.w3.org/1999/xhtml","a"),o="download"in r,i=function(e){var t=new MouseEvent("click");e.dispatchEvent(t)},a=/constructor/i.test(e.HTMLElement),f=/CriOS\/[\d]+/.test(navigator.userAgent),u=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},d="application/octet-stream",s=1e3*40,c=function(e){var t=function(){if(typeof e==="string"){n().revokeObjectURL(e)}else{e.remove()}};setTimeout(t,s)},l=function(e,t,n){t=[].concat(t);var r=t.length;while(r--){var o=e["on"+t[r]];if(typeof o==="function"){try{o.call(e,n||e)}catch(i){u(i)}}}},p=function(e){if(/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)){return new Blob([String.fromCharCode(65279),e],{type:e.type})}return e},v=function(t,u,s){if(!s){t=p(t)}var v=this,w=t.type,m=w===d,y,h=function(){l(v,"writestart progress write writeend".split(" "))},S=function(){if((f||m&&a)&&e.FileReader){var r=new FileReader;r.onloadend=function(){var t=f?r.result:r.result.replace(/^data:[^;]*;/,"data:attachment/file;");var n=e.open(t,"_blank");if(!n)e.location.href=t;t=undefined;v.readyState=v.DONE;h()};r.readAsDataURL(t);v.readyState=v.INIT;return}if(!y){y=n().createObjectURL(t)}if(m){e.location.href=y}else{var o=e.open(y,"_blank");if(!o){e.location.href=y}}v.readyState=v.DONE;h();c(y)};v.readyState=v.INIT;if(o){y=n().createObjectURL(t);setTimeout(function(){r.href=y;r.download=u;i(r);h();c(y);v.readyState=v.DONE});return}S()},w=v.prototype,m=function(e,t,n){return new v(e,t||e.name||"download",n)};if(typeof navigator!=="undefined"&&navigator.msSaveOrOpenBlob){return function(e,t,n){t=t||e.name||"download";if(!n){e=p(e)}return navigator.msSaveOrOpenBlob(e,t)}}w.abort=function(){};w.readyState=w.INIT=0;w.WRITING=1;w.DONE=2;w.error=w.onwritestart=w.onprogress=w.onwrite=w.onabort=w.onerror=w.onwriteend=null;return m}(typeof self!=="undefined"&&self||typeof window!=="undefined"&&window||this.content);if(typeof module!=="undefined"&&module.exports){module.exports.saveAs=saveAs}else if(typeof define!=="undefined"&&define!==null&&define.amd!==null){define([],function(){return saveAs})}
249
250 !function(t){"use strict";if(t.URL=t.URL||t.webkitURL,t.Blob&&t.URL)try{return void new Blob}catch(e){}var n=t.BlobBuilder||t.WebKitBlobBuilder||t.MozBlobBuilder||function(t){var e=function(t){return Object.prototype.toString.call(t).match(/^\[object\s(.*)\]$/)[1]},n=function(){this.data=[]},o=function(t,e,n){this.data=t,this.size=t.length,this.type=e,this.encoding=n},i=n.prototype,a=o.prototype,r=t.FileReaderSync,c=function(t){this.code=this[this.name=t]},l="NOT_FOUND_ERR SECURITY_ERR ABORT_ERR NOT_READABLE_ERR ENCODING_ERR NO_MODIFICATION_ALLOWED_ERR INVALID_STATE_ERR SYNTAX_ERR".split(" "),s=l.length,u=t.URL||t.webkitURL||t,d=u.createObjectURL,f=u.revokeObjectURL,R=u,p=t.btoa,h=t.atob,b=t.ArrayBuffer,g=t.Uint8Array,w=/^[\w-]+:\/*\[?[\w\.:-]+\]?(?::[0-9]+)?/;for(o.fake=a.fake=!0;s--;)c.prototype[l[s]]=s+1;return u.createObjectURL||(R=t.URL=function(t){var e,n=document.createElementNS("http://www.w3.org/1999/xhtml","a");return n.href=t,"origin"in n||("data:"===n.protocol.toLowerCase()?n.origin=null:(e=t.match(w),n.origin=e&&e[1])),n}),R.createObjectURL=function(t){var e,n=t.type;return null===n&&(n="application/octet-stream"),t instanceof o?(e="data:"+n,"base64"===t.encoding?e+";base64,"+t.data:"URI"===t.encoding?e+","+decodeURIComponent(t.data):p?e+";base64,"+p(t.data):e+","+encodeURIComponent(t.data)):d?d.call(u,t):void 0},R.revokeObjectURL=function(t){"data:"!==t.substring(0,5)&&f&&f.call(u,t)},i.append=function(t){var n=this.data;if(g&&(t instanceof b||t instanceof g)){for(var i="",a=new g(t),l=0,s=a.length;s>l;l++)i+=String.fromCharCode(a[l]);n.push(i)}else if("Blob"===e(t)||"File"===e(t)){if(!r)throw new c("NOT_READABLE_ERR");var u=new r;n.push(u.readAsBinaryString(t))}else t instanceof o?"base64"===t.encoding&&h?n.push(h(t.data)):"URI"===t.encoding?n.push(decodeURIComponent(t.data)):"raw"===t.encoding&&n.push(t.data):("string"!=typeof t&&(t+=""),n.push(unescape(encodeURIComponent(t))))},i.getBlob=function(t){return arguments.length||(t=null),new o(this.data.join(""),t,"raw")},i.toString=function(){return"[object BlobBuilder]"},a.slice=function(t,e,n){var i=arguments.length;return 3>i&&(n=null),new o(this.data.slice(t,i>1?e:this.data.length),n,this.encoding)},a.toString=function(){return"[object Blob]"},a.close=function(){this.size=0,delete this.data},n}(t);t.Blob=function(t,e){var o=e?e.type||"":"",i=new n;if(t)for(var a=0,r=t.length;r>a;a++)Uint8Array&&t[a]instanceof Uint8Array?i.append(t[a].buffer):i.append(t[a]);var c=i.getBlob(o);return!c.slice&&c.webkitSlice&&(c.slice=c.webkitSlice),c};var o=Object.getPrototypeOf||function(t){return t.__proto__};t.Blob.prototype=o(new t.Blob)}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content||this);
251
252