PluginProbe
WebTotem Security / 2.3.2
WebTotem Security v2.3.2
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 / htdocs / js / main.js

main.js in WebTotem Security 2.3.2, at htdocs/js/main.js

274 lines 10.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // Гамбургер (адаптивное меню)
2 const burgerEl = document.querySelector(".wtotem_burger");
3 const menuEl = document.querySelector(".wtotem_nav");
4 const bodyEl = document.getElementsByTagName("body")[0];
5
6 burgerEl.addEventListener("click", () => {
7 burgerEl.classList.toggle("active");
8 menuEl.classList.toggle("active");
9 // Добавляет body overflow hidden при открытой менюшки
10 bodyEl.classList.toggle("lock");
11 });
12
13 // Модальное окно (сгенерировать отчет)
14 const reportsBtn = document.querySelectorAll(".add_report");
15 const reportsModal = document.querySelector(".wtotem_reports-modal");
16 const reportsModalClose = document.querySelector(".wtotem_reports-modal__close");
17 if(reportsBtn){
18 for (let elem of reportsBtn) {
19 elem.addEventListener("click", () => {
20 reportsModal.classList.add("wtotem_reports-modal--active");
21 bodyEl.classList.add("lock");
22 });
23 }
24 }
25 if(reportsModalClose){
26 reportsModalClose.addEventListener("click", () => {
27 reportsModal.classList.remove("wtotem_reports-modal--active");
28 bodyEl.classList.remove("lock");
29 });
30 }
31
32
33 // window.addEventListener('DOMContentLoaded', function () {
34 //
35 // function tlite(t){document.addEventListener("mouseover",function(e){var i=e.target,n=t(i);n||(n=(i=i.parentElement)&&t(i)),n&&tlite.show(i,n,!0)})}tlite.show=function(t,e,i){var n="data-tlite";e=e||{},(t.tooltip||function(t,e){function o(){tlite.hide(t,!0)}function l(){r||(r=function(t,e,i){function n(){o.className="tlite tlite-"+r+s;var e=t.offsetTop,i=t.offsetLeft;o.offsetParent===t&&(e=i=0);var n=t.offsetWidth,l=t.offsetHeight,d=o.offsetHeight,f=o.offsetWidth,a=i+n/2;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"}var o=document.createElement("span"),l=i.grav||t.getAttribute("data-tlite")||"n";o.innerHTML=e,t.appendChild(o);var r=l[0]||"",s=l[1]||"";n();var d=o.getBoundingClientRect();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}(t,d,e))}var r,s,d;return t.addEventListener("mousedown",o),t.addEventListener("mouseleave",o),t.tooltip={show:function(){d=t.title||t.getAttribute(n)||d,t.title="",t.setAttribute(n,""),d&&!s&&(s=setTimeout(l,i?150:1))},hide:function(t){if(i===t){s=clearTimeout(s);var e=r&&r.parentNode;e&&e.removeChild(r),r=void 0}}}}(t,e)).show()},tlite.hide=function(t,e){t.tooltip&&t.tooltip.hide(e)},"undefined"!=typeof module&&module.exports&&(module.exports=tlite);
36 //
37 // // init tooltip with class js--tooltip
38 // tlite(el => {
39 // return {
40 // el: el.classList.contains('js--tooltip'), grav: 'sw',
41 // }
42 // });
43 // });
44
45 async function attacksMap() {
46
47 var labels = waf_attacksMap['countries'];
48 new Chart(document.getElementById("firewall"), {
49 type: "horizontalBar",
50
51 data: {
52 labels: labels,
53 datasets: [
54 {
55 backgroundColor: "#3D50DF",
56 data: waf_attacksMap['attacks'],
57 },
58 ],
59 },
60 options: {
61 cornerRadius: 3,
62 maintainAspectRatio: false,
63 scales: {
64 yAxes: [
65 {
66 barPercentage: 0.6,
67 stacked: true,
68 gridLines: {
69 display: true,
70 },
71 },
72 ],
73 xAxes: [
74 {
75 gridLines: {
76 display: false,
77 },
78 },
79 ],
80 },
81 legend: {
82 display: false,
83 },
84 },
85 });
86
87 const fill = (country) => {
88 svg._groups[0][0].childNodes[0].childNodes.forEach((e) => {
89 if (e.__data__.properties.name === country) {
90 d3.select(e).style("fill", "#3D50DF");
91 }
92 });
93 };
94 // The svg
95 var svg = d3.select("#firewallMap"),
96 width = +svg.attr("width"),
97 height = +svg.attr("height");
98
99 // Map and projection
100 var path = d3.geoPath();
101 var projection = d3
102 .geoMercator()
103 .scale(60)
104 .center([0, 0])
105 .translate([210, 220]);
106
107 // Load external data and boot
108 d3.queue().defer(d3.json, map_json).await(ready);
109
110 function ready(error, topo) {
111
112 // Draw the map
113 svg.append("g")
114 .selectAll("path")
115 .data(topo.features)
116 .enter()
117 .append("path")
118 // draw each country
119 .attr("d", d3.geoPath().projection(projection))
120 // set the color of each country
121 .attr("fill", function () {
122 return "#5E6977";
123 })
124 .style("stroke", "transparent")
125 .attr("class", function () {
126 return "Country";
127 });
128 labels.map((e) => {
129 fill(e);
130 });
131 }
132
133
134 Chart.elements.Rectangle.prototype.draw = function () {
135 function t(t) {
136 return s[(f + t) % 4];
137 }
138 var r,
139 e,
140 i,
141 o,
142 _,
143 h,
144 l,
145 a,
146 b = this._chart.ctx,
147 d = this._view,
148 n = d.borderWidth,
149 u = this._chart.config.options.cornerRadius;
150 if (
151 (u < 0 && (u = 0),
152 void 0 === u && (u = 0),
153 d.horizontal
154 ? ((r = d.base),
155 (e = d.x),
156 (i = d.y - d.height / 2),
157 (o = d.y + d.height / 2),
158 (_ = e > r ? 1 : -1),
159 (h = 1),
160 (l = d.borderSkipped || "left"))
161 : ((r = d.x - d.width / 2),
162 (e = d.x + d.width / 2),
163 (i = d.y),
164 (_ = 1),
165 (h = (o = d.base) > i ? 1 : -1),
166 (l = d.borderSkipped || "bottom")),
167 n)
168 ) {
169 var T = Math.min(Math.abs(r - e), Math.abs(i - o)),
170 v = (n = n > T ? T : n) / 2,
171 g = r + ("left" !== l ? v * _ : 0),
172 c = e + ("right" !== l ? -v * _ : 0),
173 C = i + ("top" !== l ? v * h : 0),
174 w = o + ("bottom" !== l ? -v * h : 0);
175 g !== c && ((i = C), (o = w)),
176 C !== w && ((r = g), (e = c));
177 }
178 b.beginPath(),
179 (b.fillStyle = d.backgroundColor),
180 (b.strokeStyle = d.borderColor),
181 (b.lineWidth = n);
182 var s = [
183 [r, o],
184 [r, i],
185 [e, i],
186 [e, o],
187 ],
188 f = ["bottom", "left", "top", "right"].indexOf(l, 0);
189 -1 === f && (f = 0);
190 var q = t(0);
191 b.moveTo(q[0], q[1]);
192 for (var m = 1; m < 4; m++)
193 (q = t(m)),
194 (nextCornerId = m + 1),
195 4 == nextCornerId && (nextCornerId = 0),
196 (nextCorner = t(nextCornerId)),
197 (width = s[2][0] - s[1][0]),
198 (height = s[0][1] - s[1][1]),
199 (x = s[1][0]),
200 (y = s[1][1]),
201 (a = u) > Math.abs(height) / 2 &&
202 (a = Math.floor(Math.abs(height) / 2)),
203 a > Math.abs(width) / 2 &&
204 (a = Math.floor(Math.abs(width) / 2)),
205 height < 0
206 ? ((x_tl = x),
207 (x_tr = x + width),
208 (y_tl = y + height),
209 (y_tr = y + height),
210 (x_bl = x),
211 (x_br = x + width),
212 (y_bl = y),
213 (y_br = y),
214 b.moveTo(x_bl + a, y_bl),
215 b.lineTo(x_br - a, y_br),
216 b.quadraticCurveTo(x_br, y_br, x_br, y_br - a),
217 b.lineTo(x_tr, y_tr + a),
218 b.quadraticCurveTo(x_tr, y_tr, x_tr - a, y_tr),
219 b.lineTo(x_tl + a, y_tl),
220 b.quadraticCurveTo(x_tl, y_tl, x_tl, y_tl + a),
221 b.lineTo(x_bl, y_bl - a),
222 b.quadraticCurveTo(x_bl, y_bl, x_bl + a, y_bl))
223 : width < 0
224 ? ((x_tl = x + width),
225 (x_tr = x),
226 (y_tl = y),
227 (y_tr = y),
228 (x_bl = x + width),
229 (x_br = x),
230 (y_bl = y + height),
231 (y_br = y + height),
232 b.moveTo(x_bl + a, y_bl),
233 b.lineTo(x_br - a, y_br),
234 b.quadraticCurveTo(x_br, y_br, x_br, y_br - a),
235 b.lineTo(x_tr, y_tr + a),
236 b.quadraticCurveTo(x_tr, y_tr, x_tr - a, y_tr),
237 b.lineTo(x_tl + a, y_tl),
238 b.quadraticCurveTo(x_tl, y_tl, x_tl, y_tl + a),
239 b.lineTo(x_bl, y_bl - a),
240 b.quadraticCurveTo(x_bl, y_bl, x_bl + a, y_bl))
241 : (b.moveTo(x + a, y),
242 b.lineTo(x + width - a, y),
243 b.quadraticCurveTo(
244 x + width,
245 y,
246 x + width,
247 y + a
248 ),
249 b.lineTo(x + width, y + height - a),
250 b.quadraticCurveTo(
251 x + width,
252 y + height,
253 x + width - a,
254 y + height
255 ),
256 b.lineTo(x + a, y + height),
257 b.quadraticCurveTo(
258 x,
259 y + height,
260 x,
261 y + height - a
262 ),
263 b.lineTo(x, y + a),
264 b.quadraticCurveTo(x, y, x + a, y));
265 b.fill(), n && b.stroke();
266 };
267 }
268
269 window.onload = function() {
270 if (typeof waf_attacksMap !== 'undefined') {
271 attacksMap();
272 }
273 };
274