PageSourceSearch

https://petro-center.lu/wp-content/plugins/rometheme-for-elementor/widgets/assets/js/countdown.js?ver=1.6.8

js petro-center.lu collected 2026-09-24 10:16:53 UTC 4,497 bytes, 131 lines download raw bytes

1jQuery(window).on("elementor/frontend/init", function () {
2  elementorFrontend.hooks.addAction(
3    "frontend/element_ready/rkit-countdown.default",
4    function ($scope, $) {
5      function formatDate(dateString) {
6        var parts = dateString.split(" ");
7        if (parts.length === 2) {
8          var datePart = parts[0];
9          var timePart = parts[1];
10          var timeParts = timePart.split(":");
11
12          if (timeParts.length === 3) {
13            if (timeParts[2].length === 1) {
14              timeParts[2] = "0" + timeParts[2];
15            }
16          }
17
18          return datePart + "T" + timeParts.join(":");
19        }
20        return "";
21      }
22
23      function updateCountdown($element, endDate) {
24        if (!endDate) {
25          return;
26        }
27
28        var formattedDate = formatDate(endDate);
29
30        var countDownDate = new Date(formattedDate).getTime();
31
32        if (isNaN(countDownDate)) {
33          return;
34        }
35
36        // Reset countdown display to '00'
37        $element.find(".countdown-days").text("00");
38        $element.find(".countdown-hours").text("00");
39        $element.find(".countdown-minutes").text("00");
40        $element.find(".countdown-seconds").text("00");
41
42        var x = setInterval(function () {
43          var now = new Date().getTime();
44          var distance = countDownDate - now;
45
46          var days = Math.floor(distance / (1000 * 60 * 60 * 24));
47          var hours = Math.floor(
48            (distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)
49          );
50          var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
51          var seconds = Math.floor((distance % (1000 * 60)) / 1000);
52
53          var daysStr = (days < 10 ? "0" + days : days).toString();
54          var hoursStr = (hours < 10 ? "0" + hours : hours).toString();
55          var minutesStr = (minutes < 10 ? "0" + minutes : minutes).toString();
56          var secondsStr = (seconds < 10 ? "0" + seconds : seconds).toString();
57
58          if ($element.find(".countdown-days").text() !== daysStr) {
59            $element.find(".countdown-days").text(daysStr);
60          }
61          if ($element.find(".countdown-hours").text() !== hoursStr) {
62            $element.find(".countdown-hours").text(hoursStr);
63          }
64          if ($element.find(".countdown-minutes").text() !== minutesStr) {
65            $element.find(".countdown-minutes").text(minutesStr);
66          }
67          if ($element.find(".countdown-seconds").text() !== secondsStr) {
68            $element.find(".countdown-seconds").text(secondsStr);
69          }
70
71          if (distance < 0) {
72            clearInterval(x);
73            $element.find(".countdown-days").text("00");
74            $element.find(".countdown-hours").text("00");
75            $element.find(".countdown-minutes").text("00");
76            $element.find(".countdown-seconds").text("00");
77
78            var expiredSection = $element.find(".expired-time-section");
79            var countdownWidget = $element.find(".count");
80
81            if (expiredSection.length && countdownWidget.length) {
82              expiredSection.show();
83              countdownWidget.hide();
84            }
85          }
86        }, 1000);
87
88        $element.data("interval", x);
89      }
90
91      var $element = $scope;
92      var endDate = $element.find("#countdown").data("date");
93
94      //
95      // Struktur ulang & tambahkan separator
96      var $countdown = $element.find("#countdown");
97      var $sections = $countdown.find(".countdown-section");
98
99      $sections.each(function (index) {
100        var $section = $(this);
101        var $number = $section.find(".time_sett");
102        var $label = $section.find(".countdown-label");
103
104        // Bungkus angka di dalam row tersendiri
105        if (!$section.find(".countdown-top-row").length) {
106          $number.wrap('<div class="countdown-top-row"></div>');
107        }
108      });
109
110      //
111
112      var existingInterval = $element.data("interval");
113      if (existingInterval) {
114        clearInterval(existingInterval);
115      }
116
117      updateCountdown($element, endDate);
118
119      $element.find("#countdown").on("change", function () {
120        endDate = $(this).data("date");
121
122        existingInterval = $element.data("interval");
123        if (existingInterval) {
124          clearInterval(existingInterval);
125        }
126
127        updateCountdown($element, endDate);
128      });
129    }
130  );
131});

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.