PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.10.19
ووسلام – همگام سازی ووکامرس و باسلام v1.10.19
1.10.19 1.10.20 1.10.18 1.10.17 1.10.15 1.10.14 1.10.13 1.10.12 1.10.10 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.2 1.9.1 1.9.0 1.8.8 1.8.5 1.8.6 All 53 releases
sync-basalam / assets / js / manage-box.js

manage-box.js in ووسلام – همگام سازی ووکامرس و باسلام 1.10.19, at assets/js/manage-box.js

69 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 document.addEventListener("DOMContentLoaded", function () {
2 const buttons = document.querySelectorAll(".basalam-action-button[data-url]");
3
4 buttons.forEach((button) => {
5 button.addEventListener("click", function (event) {
6 event.preventDefault();
7
8 const dataAttributes = [...button.getAttributeNames()].filter((name) =>
9 name.startsWith("data-")
10 );
11
12 const attributes = {};
13 dataAttributes.forEach((attr) => {
14 const cleanAttr = attr
15 .replace("data-", "")
16 .replace(/-/g, "_")
17 .toLowerCase();
18 attributes[cleanAttr] = button.getAttribute(attr);
19 });
20
21 const formData = new FormData();
22 Object.keys(attributes).forEach((key) => {
23 formData.append(key, attributes[key]);
24 });
25
26 const url = attributes["url"];
27
28 if (confirm("آیا �
29 ط�
30 ئن هستید که �
31 ی‌خواهید این ع�
32 ل را انجا�
33 دهید؟")) {
34 const originalText = this.innerText;
35 this.innerText = "در حال پردازش...";
36 this.disabled = true;
37
38 fetch(url, {
39 method: "POST",
40 body: formData,
41 })
42 .then((response) => response.json())
43 .then((data) => {
44 if (data.success) {
45 window.BasalamToast.success(data.data.message || "ع�
46 لیات با �
47 وفقیت انجا�
48 شد.");
49 location.reload();
50 } else {
51 window.BasalamToast.error(data.data?.message || "خطا در انجا�
52 ع�
53 لیات.");
54 }
55 })
56 .catch((error) => {
57 window.BasalamToast.error("خطا در انجا�
58 ع�
59 لیات: " + error);
60 })
61 .finally(() => {
62 this.innerText = originalText;
63 this.disabled = false;
64 });
65 }
66 });
67 });
68 });
69