Path: blob/master/sites/tiktok/vendor/countdowntime/countdowntime.js
740 views
(function ($) {1"use strict";23function getTimeRemaining(endtime) {4var t = Date.parse(endtime) - Date.parse(new Date());5var seconds = Math.floor((t / 1000) % 60);6var minutes = Math.floor((t / 1000 / 60) % 60);7var hours = Math.floor((t / (1000 * 60 * 60)) % 24);8var days = Math.floor(t / (1000 * 60 * 60 * 24));9return {10'total': t,11'days': days,12'hours': hours,13'minutes': minutes,14'seconds': seconds15};16}1718function initializeClock(id, endtime) {19var daysSpan = $('.days');20var hoursSpan = $('.hours');21var minutesSpan = $('.minutes');22var secondsSpan = $('.seconds');2324function updateClock() {25var t = getTimeRemaining(endtime);2627daysSpan.html(t.days);28hoursSpan.html(('0' + t.hours).slice(-2));29minutesSpan.html(('0' + t.minutes).slice(-2));30secondsSpan.html(('0' + t.seconds).slice(-2))3132if (t.total <= 0) {33clearInterval(timeinterval);34}35}3637updateClock();38var timeinterval = setInterval(updateClock, 1000);39}4041var deadline = new Date(Date.parse(new Date()) + 25 * 24 * 60 * 60 * 1000 + 13 * 60 * 60 * 1000);42initializeClock('clockdiv', deadline);4344})(jQuery);4546