PluginProbe ʕ •ᴥ•ʔ
Aruba HiSpeed Cache / 3.0.15
Aruba HiSpeed Cache v3.0.15
3.0.15 3.0.14 3.0.13 1.2.4 1.2.5 1.2.6 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.17 2.0.18 2.0.19 2.0.20 2.0.21 2.0.22 2.0.23 2.0.24 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3
aruba-hispeed-cache / assets / js / toolbar.js
aruba-hispeed-cache / assets / js Last commit date
debug_status.js 5 months ago index.php 5 months ago toolbar.js 5 months ago
toolbar.js
115 lines
1 /* The code is an immediately invoked function expression (IIFE) that creates a loader element and
2 defines an asynchronous function called `ahscBtnPurger`. */
3 (() => {
4 ("use strict");
5
6 /* The code is creating a new `div` element and assigning it to the `loader` variable. It then sets the
7 `id` attribute of the `div` element to "ahsc-loader-toolbar". Finally, it appends the `div` element
8 to the `body` of the document. This code is creating a loader element that can be used to indicate
9 that a process is in progress. */
10 const loader = document.createElement("div");
11 loader.setAttribute("id", "ahsc-loader-toolbar");
12 document.body.append(loader);
13
14 /**
15 * The above function is an asynchronous JavaScript function that purges the cache using an AJAX
16 * request.
17 * @returns nothing (undefined).
18 */
19 const ahscBtnPurger = async () => {
20 if (typeof AHSC_TOOLBAR.ahsc_nonce == "undefined") {
21 console.warn("No nonce is set for this action. This action has been aborted.");
22 return;
23 }
24
25 loader.style.display = "block";
26
27 let to_purge = "current-url" === AHSC_TOOLBAR.ahsc_topurge ? window.location.pathname : "all";
28
29 const data = new FormData();
30 data.append("action", "ahcs_clear_cache");
31 data.append("ahsc_nonce", AHSC_TOOLBAR.ahsc_nonce);
32 data.append("ahsc_to_purge", encodeURIComponent(to_purge));
33
34 const request = await fetch(AHSC_TOOLBAR.ahsc_ajax_url, {
35 method: "POST",
36 credentials: "same-origin",
37 body: data,
38 })
39 .then((r) => r.json())
40 .then((result) => {
41 if (result.code >= 200) {
42 let style = "";
43 loader.style.removeProperty("display");
44 switch (result.type) {
45 case "success":
46 style = "color:green";
47 break;
48 case "error":
49 style = "color:red";
50 break;
51 default:
52 style = "color:blue";
53 break;
54 }
55 console.log(`%c${result.message}`, style);
56 }
57 })
58 .catch((error) => {
59 console.log("[Aruba HiSpeed Cache Plugin]");
60 console.error(error);
61 });
62
63 return;
64 };
65
66 /* The line `window.ahscBtnPurger = ahscBtnPurger;` is assigning the `ahscBtnPurger` function to the
67 `ahscBtnPurger` property of the `window` object. This makes the function accessible globally in the
68 browser environment. */
69 window.ahscBtnPurger = ahscBtnPurger;
70
71 const ahscBtnTransientPurger = async () => {
72 loader.style.display = "block";
73
74
75
76 const data = new FormData();
77 data.append("action", "ahsc_clear_expired_transient");
78 data.append("ahsc_nonce", AHSC_TOOLBAR.ahsc_nonce);
79
80 const request = await fetch(AHSC_TOOLBAR.ahsc_ajax_url, {
81 method: "POST",
82 credentials: "same-origin",
83 body: data,
84 })
85 .then((r) => r.json())
86 .then((result) => {
87 if (result.code >= 200) {
88 let style = "";
89 loader.style.removeProperty("display");
90 switch (result.type) {
91 case "success":
92 style = "color:green";
93 break;
94 case "error":
95 style = "color:red";
96 break;
97 default:
98 style = "color:blue";
99 break;
100 }
101 console.log(`%c${result.message}`, style);
102 }
103 })
104 .catch((error) => {
105 console.log("[Aruba HiSpeed Cache Plugin]");
106 console.error(error);
107 });
108
109
110 }
111
112 window.ahscBtnTransientPurger = ahscBtnTransientPurger;
113
114 })();
115