PageSourceSearch

https://www.goodmorning.com/wp-content/plugins/gm-promos/assets/js/promotionTimer.js?ver=30

js goodmorning.com collected 2026-10-04 01:58:10 UTC 3,378 bytes, 101 lines download raw bytes

1function promoNow()
2{
3    var now = false;
4    var cookies = document.cookie.split(';');
5    for(var i=0; i<cookies.length; ++i)
6    {
7        cookies[i] = cookies[i].split('=');
8        if(cookies[i][0].trim() == 'promoNow')
9        {
10            now = decodeURIComponent(cookies[i][1].trim());
11            break;
12        }
13    }
14    if(now && now != 'clear')
15    {
16        parsed = now.split('::')[0].split('-');
17        if(parsed.length == 6)
18        {
19            parsed = new Date(
20                parsed[0],
21                parsed[1]-1,
22                parsed[2],
23                parsed[3],
24                parsed[4],
25                parsed[5]);
26            if(parsed instanceof Date && !isNaN(parsed))
27                return parsed;
28        }
29        alert(
30            "promoNow is badly formatted (" + now
31            +"). It should be YYYY-MM-DD-HH-MM-SS.");
32    }
33    return new Date();
34}
35
36document.addEventListener( "DOMContentLoaded", function(){
37    const timeEndDefault = TIMER_SETTINGS["timestamp-end-seconds"];
38    const timeEnds = TIMER_SETTINGS["promo-timestamp-ends"];
39    const timerSelector = '.countdown-timer.promotion';
40    const messages = TIMER_SETTINGS["messages"];
41
42    var timers = document.querySelectorAll(timerSelector);
43    for(i = 0; i < timers.length; ++i)
44    {
45        const timer = timers[i];
46        var message = null;
47        if (messages && 'promoid' in timer.dataset)
48            message = messages[timer.dataset.promoid];
49        if(!message) continue;
50
51        const parentElem = timer.closest('.sys-countdown-parent');
52        if(!parentElem) continue;
53        const messageElem = parentElem.querySelector('.sys-countdown-message');
54        if(!messageElem) continue;
55        messageElem.innerHTML = message;
56    }
57
58    function setTimers()
59    {
60        const now = promoNow();
61        const timers = document.querySelectorAll(timerSelector);
62        for(i = 0; i < timers.length; ++i)
63        {
64            const timer = timers[i];
65
66            var endTimestamp;
67            if (timeEnds && 'promoid' in timer.dataset)
68                endTimestamp = timeEnds[timer.dataset.promoid]
69            else if('end' in timer.dataset)
70                endTimestamp = new Date(timer.dataset.end).getTime()/1000;
71            else if(timeEndDefault)
72                endTimestamp = timeEndDefault;
73            else
74                continue;
75            var timeLeft = Math.max(endTimestamp * 1000 - now, 0)/1000;
76
77            let days = Math.floor(timeLeft / (60*60*24));
78            let hours = Math.floor(timeLeft / (60*60)) % 24;
79            let minutes = Math.floor(timeLeft / 60) % 60;
80            let seconds = Math.floor(timeLeft) % 60;
81
82            if(hours < 10) hours = "0" + hours;
83            if(minutes < 10) minutes= "0" + minutes;
84            if(seconds < 10) seconds = "0" + seconds;
85
86            let timerString = "";
87            if (days)
88            {
89                if(days < 10) days = "0" + days;
90                timerString += "<span class='days'>" + days +"</span>";
91            }
92            timerString += "<span class='hours'>" + hours + "</span>";
93            timerString += "<span class='minutes'>" + minutes + "</span>";
94            timerString += "<span class='seconds'>" + seconds + "</span>";
95
96            timer.innerHTML = timerString;
97        }
98    }
99    setTimers();
100    setInterval( setTimers, 1000);
101});

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.