PageSourceSearch

https://abo.nzz.ch/wp-content/themes/niobe/resources/scripts/niobe-countdown.js?ver=1.9.38

js nzz.ch collected 2026-09-24 06:55:06 UTC 2,556 bytes, 92 lines download raw bytes

1(function () {
2  'use strict';
3
4  function pad(n) {
5    return n < 10 ? '0' + n : String(n);
6  }
7
8  function initCountdown(el) {
9    var endTime = parseInt(el.getAttribute('data-countdown-end'), 10) * 1000;
10    var days = el.querySelector('[data-unit="days"]');
11    var hours = el.querySelector('[data-unit="hours"]');
12    var minutes = el.querySelector('[data-unit="minutes"]');
13    var seconds = el.querySelector('[data-unit="seconds"]');
14
15    function tick() {
16      var remaining = Math.max(0, endTime - Date.now());
17
18      if (remaining === 0) {
19        days.textContent = '00';
20        hours.textContent = '00';
21        minutes.textContent = '00';
22        seconds.textContent = '00';
23        el.style.display = 'none';
24        return;
25      }
26
27      var totalSeconds = Math.floor(remaining / 1000);
28      var d = Math.floor(totalSeconds / 86400);
29      var h = Math.floor((totalSeconds % 86400) / 3600);
30      var m = Math.floor((totalSeconds % 3600) / 60);
31      var s = totalSeconds % 60;
32
33      days.textContent = pad(d);
34      hours.textContent = pad(h);
35      minutes.textContent = pad(m);
36      seconds.textContent = pad(s);
37
38      setTimeout(tick, 1000);
39    }
40
41    tick();
42  }
43
44  function initAllCountdowns() {
45    document.querySelectorAll('.wp-block-newobe-countdown[data-countdown-end]').forEach(initCountdown);
46  }
47
48  function initProductSingleCountdown(el) {
49    var endTime = parseInt(el.getAttribute('data-countdown-end'), 10) * 1000;
50    var timeEl = el.querySelector('.newobe-product-single__countdown-time');
51    var remaining = endTime - Date.now();
52
53    if (remaining <= 0 || remaining >= 86400 * 1000) {
54      return;
55    }
56
57    el.style.display = '';
58
59    function tick() {
60      var left = Math.max(0, endTime - Date.now());
61
62      if (left === 0) {
63        el.style.display = 'none';
64        return;
65      }
66
67      var total = Math.floor(left / 1000);
68      var h = Math.floor(total / 3600);
69      var m = Math.floor((total % 3600) / 60);
70      var s = total % 60;
71
72      timeEl.textContent = pad(h) + ':' + pad(m) + ':' + pad(s);
73      setTimeout(tick, 1000);
74    }
75
76    tick();
77  }
78
79  function initAllProductSingleCountdowns() {
80    document.querySelectorAll('.newobe-product-single__countdown[data-countdown-end]').forEach(initProductSingleCountdown);
81  }
82
83  if (document.readyState === 'loading') {
84    document.addEventListener('DOMContentLoaded', function () {
85      initAllCountdowns();
86      initAllProductSingleCountdowns();
87    });
88  } else {
89    initAllCountdowns();
90    initAllProductSingleCountdowns();
91  }
92})();

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.