# sync-basalam/1.9.2/assets/js/manage-box.js

ووسلام – همگام سازی ووکامرس و باسلام, version 1.9.2. 57 lines.

- Page: https://pluginprobe.com/plugins/sync-basalam/1.9.2/code/assets/js/manage-box.js
- Raw: https://pluginprobe.com/plugins/sync-basalam/1.9.2/raw/assets/js/manage-box.js
- Modified: 2026-07-08T11:26:14+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/sync-basalam/1.9.2/code/assets/js/manage-box.js#L10-L20`.

```javascript
document.addEventListener("DOMContentLoaded", function () {
  const buttons = document.querySelectorAll(".basalam-action-button[data-url]");

  buttons.forEach((button) => {
    button.addEventListener("click", function (event) {
      event.preventDefault();

      const dataAttributes = [...button.getAttributeNames()].filter((name) =>
        name.startsWith("data-")
      );

      const attributes = {};
      dataAttributes.forEach((attr) => {
        const cleanAttr = attr
          .replace("data-", "")
          .replace(/-/g, "_")
          .toLowerCase();
        attributes[cleanAttr] = button.getAttribute(attr);
      });

      const formData = new FormData();
      Object.keys(attributes).forEach((key) => {
        formData.append(key, attributes[key]);
      });

      const url = attributes["url"];

      if (confirm("آیا مطمئن هستید که می‌خواهید این عمل را انجام دهید؟")) {
        const originalText = this.innerText;
        this.innerText = "در حال پردازش...";
        this.disabled = true;

        fetch(url, {
          method: "POST",
          body: formData,
        })
          .then((response) => response.json())
          .then((data) => {
            if (data.success) {
              window.BasalamToast.success(data.data.message || "عملیات با موفقیت انجام شد.");
              location.reload();
            } else {
              window.BasalamToast.error(data.data?.message || "خطا در انجام عملیات.");
            }
          })
          .catch((error) => {
            window.BasalamToast.error("خطا در انجام عملیات: " + error);
          })
          .finally(() => {
            this.innerText = originalText;
            this.disabled = false;
          });
      }
    });
  });
});

```
