PageSourceSearch

https://www.biafora.it/wp-content/plugins/slope-widgets/js/slope-promotions.js?ver=4.3.5

js biafora.it collected 2026-10-06 00:18:27 UTC 4,096 bytes, 106 lines download raw bytes

1"use strict";
2
3// NOTE: This is the code of the latest promotion widget. Code for legacy promotions widget is placed in the file
4// slope-widgets.js
5
6document.addEventListener('DOMContentLoaded', function () {
7  var slopePromotionsShortcodes = document.querySelectorAll('[data-role="slope-promo"]');
8  slopePromotionsShortcodes.forEach(function (slopePromotionsShortcode) {
9    var language = slopePromotionsShortcode.getAttribute("data-lang");
10    var ajaxUrl = slpWidgetObj.ajax_url;
11    var nonce = slpWidgetObj.nonce;
12    fetch(ajaxUrl, {
13      method: "POST",
14      headers: {
15        "X-Requested-With": "XMLHttpRequest"
16      },
17      body: new URLSearchParams({
18        _ajax_nonce: nonce,
19        action: "slp_fetch_promotions",
20        language: language
21      })
22    }).then(function (response) {
23      return response.json();
24    }).then(function (response) {
25      // Remove loading spinner
26      var loadingElement = slopePromotionsShortcode.querySelector(".slp-loading-indicator");
27      if (loadingElement) {
28        loadingElement.remove();
29      }
30      if (response.success && response.data) {
31        slopePromotionsShortcode.innerHTML = response.data.html;
32        initializePromotionCards(slopePromotionsShortcode);
33      }
34      if (response.data && response.data.error) {
35        console.error("Error fetching promotions:", response.data.error);
36        var errorMessage = document.createElement("div");
37        errorMessage.className = "slp-error-message";
38        errorMessage.textContent = response.data.error;
39        slopePromotionsShortcode.appendChild(errorMessage);
40      }
41    })["catch"](function (error) {
42      console.error("Error fetching promotions:", error);
43      var errorMessage = document.createElement("div");
44      errorMessage.className = "slp-error-message";
45      errorMessage.textContent = "An error occurred while fetching promotions. Please try again later.";
46      slopePromotionsShortcode.appendChild(errorMessage);
47    });
48  });
49  function initializePromotionCards(shortcodeElement) {
50    var promotionCards = shortcodeElement.querySelectorAll('.slp-promotion-card');
51    if (document.querySelectorAll("[data-open-new-tab]").length > 0) {
52      shortcodeElement.querySelectorAll(".slp-reserve-button").forEach(function (promotionButton) {
53        return promotionButton.setAttribute("target", "_blank");
54      });
55    }
56    promotionCards.forEach(function (card) {
57      var promotionId = card.dataset.promotionId;
58      var modal = shortcodeElement.querySelector("#modal-".concat(promotionId));
59      var openButtons = card.querySelectorAll('[data-action="open-modal"]');
60      var closeButton = modal.querySelector('.slp-close-modal-button');
61
62      // Open modal handlers
63      openButtons.forEach(function (button) {
64        button.addEventListener('click', function () {
65          return openModal(modal);
66        });
67      });
68
69      // Close modal handler
70      closeButton.addEventListener('click', function () {
71        return closeModal(modal);
72      });
73
74      // Close on outside click
75      modal.addEventListener('click', function (e) {
76        if (e.target === modal) {
77          closeModal(modal);
78        }
79      });
80    });
81
82    // Modal functions
83    function openModal(modal) {
84      modal.classList.add('slp-modal-visible');
85      modal.classList.remove('slp-modal-hidden');
86      modal.setAttribute('aria-hidden', 'false');
87      document.body.style.overflow = 'hidden'; // Prevent background scrolling
88    }
89    function closeModal(modal) {
90      modal.classList.add('slp-modal-hidden');
91      modal.classList.remove('slp-modal-visible');
92      modal.setAttribute('aria-hidden', 'true');
93      document.body.style.overflow = ''; // Restore background scrolling
94    }
95
96    // When ESC key is pressed, close all open modals
97    document.addEventListener('keydown', function (e) {
98      if (e.key === 'Escape') {
99        var openModals = document.querySelectorAll('.slp-modal[style*="display: block"]');
100        openModals.forEach(function (modal) {
101          return closeModal(modal);
102        });
103      }
104    });
105  }
106});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.