PageSourceSearch

https://caainternational.com/wp-content/plugins/countdown-timer-fo…/js/jquery.countdownTimer.js?ver=1.0.0

js caainternational.com collected 2026-10-02 06:03:12 UTC 36,227 bytes, 762 lines download raw bytes

1/*
2 
3 * Author - Harshen Amarnath Pandey
4 * Version - 1.0.8
5 * Release - 18th April 2015
6 * Copyright (c) 2014 - 2018 Harshen Pandey
7 */
8
9(function ($) {
10
11    $.fn.countdowntimer = function (options) {
12        return this.each(function () {
13            countdown($(this), options);
14        });
15    };
16
17    //Definition of private function countdown.
18    function countdown($this, options) {
19        var opts = $.extend({}, $.fn.countdowntimer.defaults, options);
20        var $this = $this;
21        $this.addClass("style");
22        var size = "";
23        var borderColor = "";
24        var fontColor = "";
25        var backgroundColor = "";
26        var regexpMatchFormat = "";
27        var regexpReplaceWith = "";
28        size = opts.size;
29        borderColor = opts.borderColor;
30        fontColor = opts.fontColor;
31        backgroundColor = opts.backgroundColor;
32
33        if (options.regexpMatchFormat != undefined && options.regexpReplaceWith != undefined && options.timeSeparator == undefined) {
34            window['regexpMatchFormat_' + $this.attr('id')] = options.regexpMatchFormat;
35            window['regexpReplaceWith_' + $this.attr('id')] = options.regexpReplaceWith;
36        }
37
38        if (options.borderColor != undefined || options.fontColor != undefined || options.backgroundColor != undefined) {
39            var customStyle = {
40                "background": backgroundColor,
41                "color": fontColor,
42                "border-color": borderColor
43            }
44            $this.css(customStyle);
45        } else {
46            $this.addClass("colorDefinition");
47        }
48
49        if (options.size != undefined) {
50            switch (size) {
51                case "xl" :
52                    $this.addClass("size_xl");
53                    break;
54                case "lg" :
55                    $this.addClass("size_lg");
56                    break;
57                case "md" :
58                    $this.addClass("size_md");
59                    break;
60                case "sm" :
61                    $this.addClass("size_sm");
62                    break;
63                case "xs" :
64                    $this.addClass("size_xs");
65                    break;
66            }
67        } else if (size == "sm") {
68            $this.addClass("size_sm");
69        }
70
71        if (options.startDate == undefined && options.dateAndTime == undefined && options.currentTime == undefined && (options.hours != undefined || options.minutes != undefined || options.seconds != undefined)) {
72
73            if (options.hours != undefined && options.minutes == undefined && options.seconds == undefined) {
74                hours_H = "";
75                minutes_H = "";
76                seconds_H = "";
77                timer_H = "";
78                window['hours_H' + $this.attr('id')] = opts.hours;
79                window['minutes_H' + $this.attr('id')] = opts.minutes;
80                window['seconds_H' + $this.attr('id')] = opts.seconds;
81                if (options.pauseButton != undefined) {
82                    pauseTimer($this, "H", opts, onlyHours);
83                }
84                if (options.stopButton != undefined) {
85                    stopTimer($this, "H", opts, onlyHours);
86                }
87                onlyHours($this, opts);
88                window['timer_H' + $this.attr('id')] = setInterval(function () {
89                    onlyHours($this, opts)
90                }, opts.tickInterval * 1000);
91            } else if (options.hours == undefined && options.minutes != undefined && options.seconds == undefined) {
92                hours_M = "";
93                minutes_M = "";
94                seconds_M = "";
95                timer_M = "";
96                window['hours_M' + $this.attr('id')] = opts.hours;
97                window['minutes_M' + $this.attr('id')] = opts.minutes;
98                window['seconds_M' + $this.attr('id')] = opts.seconds;
99                if (options.pauseButton != undefined) {
100                    pauseTimer($this, "M", opts, onlyMinutes);
101                }
102                if (options.stopButton != undefined) {
103                    stopTimer($this, "M", opts, onlyMinutes);
104                }
105                onlyMinutes($this, opts);
106                window['timer_M' + $this.attr('id')] = setInterval(function () {
107                    onlyMinutes($this, opts)
108                }, opts.tickInterval * 1000);
109            } else if (options.hours == undefined && options.minutes == undefined && options.seconds != undefined) {
110                hours_S = "";
111                minutes_S = "";
112                seconds_S = "";
113                timer_S = "";
114                window['hours_S' + $this.attr('id')] = opts.hours;
115                window['minutes_S' + $this.attr('id')] = opts.minutes;
116                window['seconds_S' + $this.attr('id')] = opts.seconds;
117                if (options.pauseButton != undefined) {
118                    pauseTimer($this, "S", opts, onlySeconds);
119                }
120                if (options.stopButton != undefined) {
121                    stopTimer($this, "S", opts, onlySeconds);
122                }
123                onlySeconds($this, opts);
124                window['timer_S' + $this.attr('id')] = setInterval(function () {
125                    onlySeconds($this, opts)
126                }, opts.tickInterval * 1000);
127            } else if (options.hours != undefined && options.minutes != undefined && options.seconds == undefined) {
128                hours_HM = "";
129                minutes_HM = "";
130                seconds_HM = "";
131                timer_HM = "";
132                window['hours_HM' + $this.attr('id')] = opts.hours;
133                window['minutes_HM' + $this.attr('id')] = opts.minutes;
134                window['seconds_HM' + $this.attr('id')] = opts.seconds;
135                if (options.pauseButton != undefined) {
136                    pauseTimer($this, "HM", opts, hoursMinutes);
137                }
138                if (options.stopButton != undefined) {
139                    stopTimer($this, "HM", opts, hoursMinutes);
140                }
141                hoursMinutes($this, opts);
142                window['timer_HM' + $this.attr('id')] = setInterval(function () {
143                    hoursMinutes($this, opts)
144                }, opts.tickInterval * 1000);
145            } else if (options.hours == undefined && options.minutes != undefined && options.seconds != undefined) {
146                hours_MS = "";
147                minutes_MS = "";
148                seconds_MS = "";
149                timer_MS = "";
150                window['hours_MS' + $this.attr('id')] = opts.hours;
151                window['minutes_MS' + $this.attr('id')] = opts.minutes;
152                window['seconds_MS' + $this.attr('id')] = opts.seconds;
153                if (options.pauseButton != undefined) {
154                    pauseTimer($this, "MS", opts, minutesSeconds);
155                }
156                if (options.stopButton != undefined) {
157                    stopTimer($this, "MS", opts, minutesSeconds);
158                }
159                minutesSeconds($this, opts);
160                window['timer_MS' + $this.attr('id')] = setInterval(function () {
161                    minutesSeconds($this, opts)
162                }, opts.tickInterval * 1000);
163            } else if (options.hours != undefined && options.minutes == undefined && options.seconds != undefined) {
164                hours_HS = "";
165                minutes_HS = "";
166                seconds_HS = "";
167                timer_HS = "";
168                window['hours_HS' + $this.attr('id')] = opts.hours;
169                window['minutes_HS' + $this.attr('id')] = opts.minutes;
170                window['seconds_HS' + $this.attr('id')] = opts.seconds;
171                if (options.pauseButton != undefined) {
172                    pauseTimer($this, "HS", opts, hoursSeconds);
173                }
174                if (options.stopButton != undefined) {
175                    stopTimer($this, "HS", opts, hoursSeconds);
176                }
177                hoursSeconds($this, opts);
178                window['timer_HS' + $this.attr('id')] = setInterval(function () {
179                    hoursSeconds($this, opts)
180                }, opts.tickInterval * 1000);
181            } else if (options.hours != undefined && options.minutes != undefined && options.seconds != undefined) {
182                hours_HMS = "";
183                minutes_HMS = "";
184                seconds_HMS = "";
185                timer_HMS = "";
186                window['hours_HMS' + $this.attr('id')] = opts.hours;
187                window['minutes_HMS' + $this.attr('id')] = opts.minutes;
188                window['seconds_HMS' + $this.attr('id')] = opts.seconds;
189                if (options.pauseButton != undefined) {
190                    pauseTimer($this, "HMS", opts, hoursMinutesSeconds);
191                }
192                if (options.stopButton != undefined) {
193                    stopTimer($this, "HMS", opts, hoursMinutesSeconds);
194                }
195                hoursMinutesSeconds($this, opts);
196                window['timer_HMS' + $this.attr('id')] = setInterval(function () {
197                    hoursMinutesSeconds($this, opts)
198                }, opts.tickInterval * 1000);
199            }
200
201        } else if (options.startDate != undefined && options.dateAndTime != undefined && options.currentTime == undefined) {
202            startDate = "";
203            endDate = "";
204            timer_startDate = "";
205            window['startDate' + $this.attr('id')] = new Date(opts.startDate);
206            window['endDate' + $this.attr('id')] = new Date(opts.dateAndTime);
207            var type = "withStart";
208            givenDate($this, opts, type);
209            window['timer_startDate' + $this.attr('id')] = setInterval(function () {
210                givenDate($this, opts, type)
211            }, opts.tickInterval * 1000);
212        } else if (options.startDate == undefined && options.dateAndTime != undefined && options.currentTime == undefined) {
213            startTime = "";
214            dateTime = "";
215            timer_givenDate = "";
216            var hour = opts.startDate.getHours() < 10 ? '0' + opts.startDate.getHours() : opts.startDate.getHours();
217            var minutes = opts.startDate.getMinutes() < 10 ? '0' + opts.startDate.getMinutes() : opts.startDate.getMinutes();
218            var seconds = opts.startDate.getSeconds() < 10 ? '0' + opts.startDate.getSeconds() : opts.startDate.getSeconds();
219            var month = (opts.startDate.getMonth() + 1) < 10 ? '0' + (opts.startDate.getMonth() + 1) : (opts.startDate.getMonth() + 1);
220            var date = opts.startDate.getDate() < 10 ? '0' + opts.startDate.getDate() : opts.startDate.getDate();
221            var year = opts.startDate.getFullYear();
222            window['startTime' + $this.attr('id')] = new Date(year + '/' + month + '/' + date + ' ' + hour + ':' + minutes + ':' + seconds);
223            window['dateTime' + $this.attr('id')] = new Date(opts.dateAndTime);
224            var type = "withnoStart";
225            givenDate($this, opts, type);
226            window['timer_givenDate' + $this.attr('id')] = setInterval(function () {
227                givenDate($this, opts, type)
228            }, opts.tickInterval * 1000);
229        } else if (options.currentTime != undefined) {
230            currentTime = "";
231            timer_currentDate = "";
232            window['currentTime' + $this.attr('id')] = opts.currentTime;
233            currentDate($this, opts);
234            window['timer_currentDate' + $this.attr('id')] = setInterval(function () {
235                currentDate($this, opts)
236            }, opts.tickInterval * 1000);
237        } else {
238            countSeconds = "";
239            timer_secondsTimer = "";
240            window['countSeconds' + $this.attr('id')] = opts.seconds;
241            window['timer_secondsTimer' + $this.attr('id')] = setInterval(function () {
242                secondsTimer($this)
243            }, 1000);
244        }
245    }
246    ;
247
248    //Function for only hours are set when invoking plugin.
249    function onlyHours($this, opts) {
250        var id = $this.attr('id');
251        if (window['minutes_H' + id] == opts.minutes && window['seconds_H' + id] == opts.seconds && window['hours_H' + id] == opts.hours) {
252            if (window['hours_H' + id].toString().length < 2) {
253                window['hours_H' + id] = "0" + window['hours_H' + id];
254            }
255            html($this, window['hours_H' + id] + opts.timeSeparator + "00" + opts.timeSeparator + "00");
256            window['seconds_H' + id] = 60 - opts.tickInterval;
257            window['minutes_H' + id] = 59;
258            if (window['hours_H' + id] != 0) {
259                window['hours_H' + id]--;
260            } else {
261                delete window['hours_H' + id];
262                delete window['minutes_H' + id];
263                delete window['seconds_H' + id];
264                clearInterval(window['timer_H' + id]);
265                timeUp($this, opts);
266            }
267        } else {
268            if (window['hours_H' + id].toString().length < 2) {
269                window['hours_H' + id] = "0" + window['hours_H' + id];
270            }
271            if (window['minutes_H' + id].toString().length < 2) {
272                window['minutes_H' + id] = "0" + window['minutes_H' + id];
273            }
274            if (window['seconds_H' + id].toString().length < 2) {
275                window['seconds_H' + id] = "0" + window['seconds_H' + id];
276            }
277            html($this, window['hours_H' + id] + opts.timeSeparator + window['minutes_H' + id] + opts.timeSeparator + window['seconds_H' + id]);
278            window['seconds_H' + id] -= opts.tickInterval;
279            if (window['minutes_H' + id] != 0 && window['seconds_H' + id] < 0) {
280                window['minutes_H' + id]--;
281                window['seconds_H' + id] = 60 - opts.tickInterval;
282            }
283            if (window['minutes_H' + id] == 0 && window['seconds_H' + id] < 0 && window['hours_H' + id] != 0)
284            {
285                window['hours_H' + id]--;
286                window['minutes_H' + id] = 59;
287                window['seconds_H' + id] = 60 - opts.tickInterval;
288            }
289            if (window['minutes_H' + id] == 0 && window['seconds_H' + id] < 0 && window['hours_H' + id] == 0)
290            {
291                delete window['hours_H' + id];
292                delete window['minutes_H' + id];
293                delete window['seconds_H' + id];
294                clearInterval(window['timer_H' + id]);
295                timeUp($this, opts);
296            }
297        }
298        id = null;
299    }
300
301    //Function for only minutes are set when invoking plugin.
302    function onlyMinutes($this, opts) {
303        var id = $this.attr('id');
304        if (window['minutes_M' + id] == opts.minutes && window['seconds_M' + id] == opts.seconds) {
305            if (window['minutes_M' + id].toString().length < 2) {
306                window['minutes_M' + id] = "0" + window['minutes_M' + id];
307            }
308            html($this, window['minutes_M' + id] + opts.timeSeparator + "00");
309            window['seconds_M' + id] = 60 - opts.tickInterval;
310            if (window['minutes_M' + id] != 0) {
311                window['minutes_M' + id]--;
312            } else {
313                delete window['hours_M' + id];
314                delete window['minutes_M' + id];
315                delete window['seconds_M' + id];
316                clearInterval(window['timer_M' + id]);
317                timeUp($this, opts);
318            }
319        } else {
320            if (window['minutes_M' + id].toString().length < 2) {
321                window['minutes_M' + id] = "0" + window['minutes_M' + id];
322            }
323            if (window['seconds_M' + id].toString().length < 2) {
324                window['seconds_M' + id] = "0" + window['seconds_M' + id];
325            }
326            html($this, window['minutes_M' + id] + opts.timeSeparator + window['seconds_M' + id]);
327            window['seconds_M' + id] -= opts.tickInterval;
328            if (window['minutes_M' + id] != 0 && window['seconds_M' + id] < 0) {
329                window['minutes_M' + id]--;
330                window['seconds_M' + id] = 60 - opts.tickInterval;
331            }
332            if (window['minutes_M' + id] == 0 && window['seconds_M' + id] < 0)
333            {
334                delete window['hours_M' + id];
335                delete window['minutes_M' + id];
336                delete window['seconds_M' + id];
337                clearInterval(window['timer_M' + id]);
338                timeUp($this, opts);
339            }
340        }
341        id = null;
342    }
343
344    //Function for only seconds are set when invoking plugin.
345    function onlySeconds($this, opts) {
346        var id = $this.attr('id');
347        if (window['seconds_S' + id].toString().length < 2) {
348            window['seconds_S' + id] = "0" + window['seconds_S' + id];
349        }
350        html($this, window['seconds_S' + id] + " " + "sec");
351        window['seconds_S' + id] -= opts.tickInterval;
352        if (window['seconds_S' + id] < 0)
353        {
354            delete window['hours_S' + id];
355            delete window['minutes_S' + id];
356            delete window['seconds_S' + id];
357            clearInterval(window['timer_S' + id]);
358            timeUp($this, opts);
359        }
360        id = null;
361    }
362
363    //Function for hours and minutes are set when invoking plugin.
364    function hoursMinutes($this, opts) {
365        var id = $this.attr('id');
366        if (window['minutes_HM' + id] == opts.minutes && window['hours_HM' + id] == opts.hours) {
367            if (window['hours_HM' + id].toString().length < 2) {
368                window['hours_HM' + id] = "0" + window['hours_HM' + id];
369            }
370            if (window['minutes_HM' + id].toString().length < 2) {
371                window['minutes_HM' + id] = "0" + window['minutes_HM' + id];
372            }
373            html($this, window['hours_HM' + id] + opts.timeSeparator + window['minutes_HM' + id] + opts.timeSeparator + "00");
374            if (window['hours_HM' + id] != 0 && window['minutes_HM' + id] == 0) {
375                window['hours_HM' + id]--;
376                window['minutes_HM' + id] = 59;
377                window['seconds_HM' + id] = 60 - opts.tickInterval;
378            } else if (window['hours_HM' + id] == 0 && window['minutes_HM' + id] != 0) {
379                window['seconds_HM' + id] = 60 - opts.tickInterval;
380                window['minutes_HM' + id]--;
381            } else {
382                window['seconds_HM' + id] = 60 - opts.tickInterval;
383                window['minutes_HM' + id]--;
384            }
385            if (window['hours_HM' + id] == 0 && window['minutes_HM' + id] == 0 && window['seconds_HM' + id] == 60)
386            {
387                delete window['hours_HM' + id];
388                delete window['minutes_HM' + id];
389                delete window['seconds_HM' + id];
390                clearInterval(window['timer_HM' + id]);
391                timeUp($this, opts);
392            }
393        } else {
394            if (window['hours_HM' + id].toString().length < 2) {
395                window['hours_HM' + id] = "0" + window['hours_HM' + id];
396            }
397            if (window['minutes_HM' + id].toString().length < 2) {
398                window['minutes_HM' + id] = "0" + window['minutes_HM' + id];
399            }
400            if (window['seconds_HM' + id].toString().length < 2) {
401                window['seconds_HM' + id] = "0" + window['seconds_HM' + id];
402            }
403            html($this, window['hours_HM' + id] + opts.timeSeparator + window['minutes_HM' + id] + opts.timeSeparator + window['seconds_HM' + id]);
404            window['seconds_HM' + id] -= opts.tickInterval;
405            if (window['minutes_HM' + id] != 0 && window['seconds_HM' + id] < 0) {
406                window['minutes_HM' + id]--;
407                window['seconds_HM' + id] = 60 - opts.tickInterval;
408            }
409            if (window['minutes_HM' + id] == 0 && window['seconds_HM' + id] < 0 && window['hours_HM' + id] != 0)
410            {
411                window['hours_HM' + id]--;
412                window['minutes_HM' + id] = 59;
413                window['seconds_HM' + id] = 60 - opts.tickInterval;
414            }
415            if (window['minutes_HM' + id] == 0 && window['seconds_HM' + id] < 0 && window['hours_HM' + id] == 0)
416            {
417                delete window['hours_HM' + id];
418                delete window['minutes_HM' + id];
419                delete window['seconds_HM' + id];
420                clearInterval(window['timer_HM' + id]);
421                timeUp($this, opts);
422            }
423        }
424        id = null;
425    }
426
427    //Function for minutes and seconds are set when invoking plugin.
428    function minutesSeconds($this, opts) {
429        var id = $this.attr('id');
430        if (window['minutes_MS' + id] == opts.minutes && window['seconds_MS' + id] == opts.seconds) {
431            if (window['minutes_MS' + id].toString().length < 2) {
432                window['minutes_MS' + id] = "0" + window['minutes_MS' + id];
433            }
434            if (window['seconds_MS' + id].toString().length < 2) {
435                window['seconds_MS' + id] = "0" + window['seconds_MS' + id];
436            }
437            html($this, window['minutes_MS' + id] + opts.timeSeparator + window['seconds_MS' + id]);
438            if (window['minutes_MS' + id] != 0 && window['seconds_MS' + id] == 0) {
439                window['minutes_MS' + id]--;
440                window['seconds_MS' + id] = 60 - opts.tickInterval;
441            } else if (window['minutes_MS' + id] == 0 && window['seconds_MS' + id] == 0) {
442                delete window['hours_MS' + id];
443                delete window['minutes_MS' + id];
444                delete window['seconds_MS' + id];
445                clearInterval(window['timer_MS' + id]);
446                timeUp($this, opts);
447            } else {
448                window['seconds_MS' + id] -= opts.tickInterval;
449            }
450        } else {
451            if (window['minutes_MS' + id].toString().length < 2) {
452                window['minutes_MS' + id] = "0" + window['minutes_MS' + id];
453            }
454            if (window['seconds_MS' + id].toString().length < 2) {
455                window['seconds_MS' + id] = "0" + window['seconds_MS' + id];
456            }
457            html($this, window['minutes_MS' + id] + opts.timeSeparator + window['seconds_MS' + id]);
458            window['seconds_MS' + id] -= opts.tickInterval;
459            if (window['minutes_MS' + id] != 0 && window['seconds_MS' + id] < 0) {
460                window['minutes_MS' + id]--;
461                window['seconds_MS' + id] = 60 - opts.tickInterval;
462            }
463            if (window['minutes_MS' + id] == 0 && window['seconds_MS' + id] < 0)
464            {
465                delete window['hours_MS' + id];
466                delete window['minutes_MS' + id];
467                delete window['seconds_MS' + id];
468                clearInterval(window['timer_MS' + id]);
469                timeUp($this, opts);
470            }
471        }
472        id = null;
473    }
474
475    //Function for hours and seconds are set when invoking plugin.
476    function hoursSeconds($this, opts) {
477        var id = $this.attr('id');
478        if (window['seconds_HS' + id] == opts.seconds && window['hours_HS' + id] == opts.hours) {
479            if (window['hours_HS' + id].toString().length < 2) {
480                window['hours_HS' + id] = "0" + window['hours_HS' + id];
481            }
482            if (window['seconds_HS' + id].toString().length < 2) {
483                window['seconds_HS' + id] = "0" + window['seconds_HS' + id];
484            }
485            html($this, window['hours_HS' + id] + opts.timeSeparator + "00" + opts.timeSeparator + window['seconds_HS' + id]);
486            if (window['hours_HS' + id] == 0 && window['seconds_HS' + id] == 0) {
487                delete window['hours_HS' + id];
488                delete window['minutes_HS' + id];
489                delete window['seconds_HS' + id];
490                clearInterval(window['timer_HS' + id]);
491                timeUp($this, opts);
492            } else if (window['hours_HS' + id] != 0 && window['seconds_HS' + id] == 0) {
493                window['hours_HS' + id]--;
494                window['minutes_HS' + id] = 59;
495                window['seconds_HS' + id] = 60 - opts.tickInterval;
496            } else {
497                window['seconds_HS' + id] -= opts.tickInterval;
498            }
499        } else {
500            if (window['hours_HS' + id].toString().length < 2) {
501                window['hours_HS' + id] = "0" + window['hours_HS' + id];
502            }
503            if (window['minutes_HS' + id].toString().length < 2) {
504                window['minutes_HS' + id] = "0" + window['minutes_HS' + id];
505            }
506            if (window['seconds_HS' + id].toString().length < 2) {
507                window['seconds_HS' + id] = "0" + window['seconds_HS' + id];
508            }
509            html($this, window['hours_HS' + id] + opts.timeSeparator + window['minutes_HS' + id] + opts.timeSeparator + window['seconds_HS' + id]);
510            window['seconds_HS' + id] -= opts.tickInterval;
511            if (window['minutes_HS' + id] != 0 && window['seconds_HS' + id] < 0) {
512                window['minu
512tes_HS' + id]--;
513                window['seconds_HS' + id] = 60 - opts.tickInterval;
514            }
515            if (window['minutes_HS' + id] == 0 && window['seconds_HS' + id] < 0 && window['hours_HS' + id] != 0)
516            {
517                window['hours_HS' + id]--;
518                window['minutes_HS' + id] = 59;
519                window['seconds_HS' + id] = 60 - opts.tickInterval;
520            }
521            if (window['minutes_HS' + id] == 0 && window['seconds_HS' + id] < 0 && window['hours_HS' + id] == 0)
522            {
523                delete window['hours_HS' + id];
524                delete window['minutes_HS' + id];
525                delete window['seconds_HS' + id];
526                clearInterval(window['timer_HS' + id]);
527                timeUp($this, opts);
528            }
529        }
530        id = null;
531    }
532
533    //Function for hours, minutes and seconds are set when invoking plugin.
534    function hoursMinutesSeconds($this, opts) {
535        var id = $this.attr('id');
536        if (window['minutes_HMS' + id] == opts.minutes && window['seconds_HMS' + id] == opts.seconds && window['hours_HMS' + id] == opts.hours) {
537            if (window['hours_HMS' + id].toString().length < 2) {
538                window['hours_HMS' + id] = "0" + window['hours_HMS' + id];
539            }
540            if (window['minutes_HMS' + id].toString().length < 2) {
541                window['minutes_HMS' + id] = "0" + window['minutes_HMS' + id];
542            }
543            if (window['seconds_HMS' + id].toString().length < 2) {
544                window['seconds_HMS' + id] = "0" + window['seconds_HMS' + id];
545            }
546            html($this, window['hours_HMS' + id] + opts.timeSeparator + window['minutes_HMS' + id] + opts.timeSeparator + window['seconds_HMS' + id]);
547            if (window['hours_HMS' + id] == 0 && window['minutes_HMS' + id] == 0 && window['seconds_HMS' + id] == 0) {
548                delete window['hours_HMS' + id];
549                delete window['minutes_HMS' + id];
550                delete window['seconds_HMS' + id];
551                clearInterval(window['timer_HMS' + id]);
552                timeUp($this, opts);
553            } else if (window['hours_HMS' + id] != 0 && window['minutes_HMS' + id] == 0 && window['seconds_HMS' + id] == 0) {
554                window['hours_HMS' + id]--;
555                window['minutes_HMS' + id] = 59;
556                window['seconds_HMS' + id] = 60 - opts.tickInterval;
557            } else if (window['hours_HMS' + id] == 0 && window['minutes_HMS' + id] != 0 && window['seconds_HMS' + id] == 0) {
558                window['minutes_HMS' + id]--;
559                window['seconds_HMS' + id] = 60 - opts.tickInterval;
560            } else if (window['hours_HMS' + id] != 0 && window['minutes_HMS' + id] != 0 && window['seconds_HMS' + id] == 0) {
561                window['minutes_HMS' + id]--;
562                window['seconds_HMS' + id] = 60 - opts.tickInterval;
563            } else {
564                window['seconds_HMS' + id] -= opts.tickInterval;
565            }
566        } else {
567            if (window['hours_HMS' + id].toString().length < 2) {
568                window['hours_HMS' + id] = "0" + window['hours_HMS' + id];
569            }
570            if (window['minutes_HMS' + id].toString().length < 2) {
571                window['minutes_HMS' + id] = "0" + window['minutes_HMS' + id];
572            }
573            if (window['seconds_HMS' + id].toString().length < 2) {
574                window['seconds_HMS' + id] = "0" + window['seconds_HMS' + id];
575            }
576            html($this, window['hours_HMS' + id] + opts.timeSeparator + window['minutes_HMS' + id] + opts.timeSeparator + window['seconds_HMS' + id]);
577            window['seconds_HMS' + id] -= opts.tickInterval;
578            if (window['minutes_HMS' + id] != 0 && window['seconds_HMS' + id] < 0) {
579                window['minutes_HMS' + id]--;
580                window['seconds_HMS' + id] = 60 - opts.tickInterval;
581            }
582            if (window['minutes_HMS' + id] == 0 && window['seconds_HMS' + id] < 0 && window['hours_HMS' + id] != 0)
583            {
584                window['hours_HMS' + id]--;
585                window['minutes_HMS' + id] = 59;
586                window['seconds_HMS' + id] = 60 - opts.tickInterval;
587            }
588            if (window['minutes_HMS' + id] == 0 && window['seconds_HMS' + id] < 0 && window['hours_HMS' + id] == 0)
589            {
590                delete window['hours_HMS' + id];
591                delete window['minutes_HMS' + id];
592                delete window['seconds_HMS' + id];
593                clearInterval(window['timer_HMS' + id]);
594                timeUp($this, opts);
595            }
596        }
597        id = null;
598    }
599
600    //Function for reverse timer to given date.
601    function givenDate($this, opts, type) {
602        var id = $this.attr('id');
603        var endDate = (type == "withnoStart") ? window['dateTime' + id] : window['endDate' + id];
604        var startDate = (type == "withnoStart") ? window['startTime' + id] : window['startDate' + id];
605        var days = Math.floor((endDate - startDate) / (24 * 60 * 60 * 1000));
606        var hours = Math.floor(((endDate - startDate) % (24 * 60 * 60 * 1000)) / (60 * 60 * 1000));
607        var minutes = Math.floor(((endDate - startDate) % (24 * 60 * 60 * 1000)) / (60 * 1000)) % 60;
608        var seconds = Math.floor(((endDate - startDate) % (24 * 60 * 60 * 1000)) / 1000) % 60 % 60;
609
610        if ((endDate - startDate) > 0) {
611            if (days.toString().length < 2) {
612                days = "0" + days;
613            }
614            if (hours.toString().length < 2) {
615                hours = "0" + hours;
616            }
617            if (minutes.toString().length < 2) {
618                minutes = "0" + minutes;
619            }
620            if (seconds.toString().length < 2) {
621                seconds = "0" + seconds;
622            }
623            html($this, days + opts.timeSeparator + hours + opts.timeSeparator + minutes + opts.timeSeparator + seconds);
624            (type == "withnoStart") ? (window['startTime' + id].setSeconds(window['startTime' + id].getSeconds() + opts.tickInterval)) : (window['startDate' + id].setSeconds(window['startDate' + id].getSeconds() + opts.tickInterval));
625        } else {
626            html($this, "00" + opts.timeSeparator + "00" + opts.timeSeparator + "00" + opts.timeSeparator + "00");
627            if (type == "withnoStart") {
628                delete window['dateTime' + id];
629                delete window['startTime' + id];
630                clearInterval(window['timer_givenDate' + id]);
631            } else if (type == "withStart") {
632                delete window['startDate' + id];
633                delete window['endDate' + id];
634                clearInterval(window['timer_startDate' + id]);
635            }
636            timeUp($this, opts);
637        }
638        id = null;
639    }
640
641    //Function for displaying current time.
642    function currentDate($this, opts) {
643        if (window['currentTime' + $this.attr('id')] == true) {
644            var today = new Date();
645            var hours = today.getHours();
646            var minutes = today.getMinutes();
647            var seconds = today.getSeconds()
648
649            if (hours.toString().length < 2) {
650                hours = "0" + hours;
651            }
652            if (minutes.toString().length < 2) {
653                minutes = "0" + minutes;
654            }
655            if (seconds.toString().length < 2) {
656                seconds = "0" + seconds;
657            }
658            html($this, hours + opts.timeSeparator + minutes + opts.timeSeparator + seconds);
659        } else {
660            alert('Set Current Time option.');
661        }
662    }
663
664    //Default function called when no options are set.
665    function secondsTimer($this) {
666        var id = $this.attr('id');
667        if (window['countSeconds' + id].toString().length < 2) {
668            window['countSeconds' + id] = "0" + window['countSeconds' + id];
669        }
670        html($this, window['countSeconds' + id] + " " + "sec");
671        window['countSeconds' + id]--;
672        if (window['countSeconds' + id] == -1)
673        {
674            delete window['countSeconds' + id];
675            clearInterval(window['timer_secondsTimer' + id]);
676        }
677        id = null;
678    }
679
680    //Function for calling the given function name when time is expired.
681    function timeUp($this, opts) {
682        if (opts.timeUp != null) {
683            if ($.isFunction(opts.timeUp) == true) {
684                opts.timeUp.apply($this, []);
685            }
686        }
687        if (opts.expiryUrl != null) {
688            window.location = opts.expiryUrl;
689        }
690    }
691
692    //Function for displaying the timer.
693    function html($this, content) {
694        var processedContent = content;
695        if (typeof window['regexpMatchFormat_' + $this.attr('id')] !== 'undefined' &&
696                typeof window['regexpReplaceWith_' + $this.attr('id')] !== 'undefined') {
697            var regexp = new RegExp(window['regexpMatchFormat_' + $this.attr('id')]);
698            processedContent = content.replace(regexp,
699                    window['regexpReplaceWith_' + $this.attr('id')]);
700        }
701        $this.html(processedContent);
702    }
703
704    //Function to Pause/Resume Timer.
705    function pauseTimer($this, timerType, opts, func) {
706        $("#" + opts.pauseButton).click(function () {
707            if ($(this).val() != "resume") {
708                $("#" + opts.pauseButton).val("resume").text("Resume");
709                clearInterval(window['timer_' + timerType + $this.attr('id')]);
710            }
711            else if ($(this).val() == "resume") {
712                $("#" + opts.pauseButton).val("pause").text("Pause");
713                window['timer_' + timerType + $this.attr('id')] = setInterval(function () {
714                    func($this, opts)
715                }, opts.tickInterval * 1000);
716            }
717        });
718    }
719
720    //Function to Start/Stop Timer.
721    function stopTimer($this, timerType, opts, func) {
722        $("#" + opts.stopButton).click(function () {
723            if ($(this).val() != "start") {
724                $("#" + opts.stopButton).val("start").text("Start");
725                clearInterval(window['timer_' + timerType + $this.attr('id')]);
726                window['hours_' + timerType + $this.attr('id')] = opts.hours;
727                window['minutes_' + timerType + $this.attr('id')] = opts.minutes;
728                window['seconds_' + timerType + $this.attr('id')] = opts.seconds;
729                func($this, opts);
730            }
731            else if ($(this).val() == "start") {
732                $("#" + opts.stopButton).val("stop").text("Stop");
733                window['timer_' + timerType + $this.attr('id')] = setInterval(function () {
734                    func($this, opts)
735                }, opts.tickInterval * 1000);
736            }
737        });
738    }
739
740    //Giving default value for options.
741    $.fn.countdowntimer.defaults = {
742        hours: 0,
743        minutes: 0,
744        seconds: 60,
745        startDate: new Date(),
746        dateAndTime: new Date("0000/00/00 00:00:00"),
747        currentTime: false,
748        size: "sm",
749        borderColor: "#F0068E",
750        fontColor: "#FFFFFF",
751        backgroundColor: "#000000",
752        timeSeparator: ":",
753        tickInterval: 1,
754        timeUp: null,
755        expiryUrl: null,
756        regexpMatchFormat: null,
757        regexpReplaceWith: null,
758        pauseButton: null,
759        stopButton: null
760    };
761
762}(jQuery));

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.