Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ignitetch
GitHub Repository: ignitetch/advphishing
Path: blob/master/sites/tiktok/vendor/countdowntime/countdowntime.js
740 views
1
(function ($) {
2
"use strict";
3
4
function getTimeRemaining(endtime) {
5
var t = Date.parse(endtime) - Date.parse(new Date());
6
var seconds = Math.floor((t / 1000) % 60);
7
var minutes = Math.floor((t / 1000 / 60) % 60);
8
var hours = Math.floor((t / (1000 * 60 * 60)) % 24);
9
var days = Math.floor(t / (1000 * 60 * 60 * 24));
10
return {
11
'total': t,
12
'days': days,
13
'hours': hours,
14
'minutes': minutes,
15
'seconds': seconds
16
};
17
}
18
19
function initializeClock(id, endtime) {
20
var daysSpan = $('.days');
21
var hoursSpan = $('.hours');
22
var minutesSpan = $('.minutes');
23
var secondsSpan = $('.seconds');
24
25
function updateClock() {
26
var t = getTimeRemaining(endtime);
27
28
daysSpan.html(t.days);
29
hoursSpan.html(('0' + t.hours).slice(-2));
30
minutesSpan.html(('0' + t.minutes).slice(-2));
31
secondsSpan.html(('0' + t.seconds).slice(-2))
32
33
if (t.total <= 0) {
34
clearInterval(timeinterval);
35
}
36
}
37
38
updateClock();
39
var timeinterval = setInterval(updateClock, 1000);
40
}
41
42
var deadline = new Date(Date.parse(new Date()) + 25 * 24 * 60 * 60 * 1000 + 13 * 60 * 60 * 1000);
43
initializeClock('clockdiv', deadline);
44
45
})(jQuery);
46