Файл: public_html/js/timer.js
Строк: 86
<?php
var difference;
function CreateTimer(NowTime, CurrentTime, name) {
difference = NowTime - new Date();
setTimeout(function () {
Tick(CurrentTime, name);
}, 1000);
}
function Tick(CurrentTime, name) {
var now = new Date();
now.setTime(now.getTime() + difference)
var actionDate = CurrentTime + 1000;
var totalRemains = (actionDate - now.getTime());
if (totalRemains > 1)
{
var Seconds = (parseInt(totalRemains / 1000));
var Days = Math.floor(Seconds / 86400);
Seconds -= Days * 86400;
var Hours = Math.floor(Seconds / 3600);
Seconds -= Hours * (3600);
var Minutes = Math.floor(Seconds / 60);
Seconds -= Minutes * (60);
var TimeStr = ((Days > 0) ? Days + "д. " : "") + ((Hours > 0) ? (Hours + "ч. ") : "") + ((Minutes > 0) ? (Minutes + "м. ") : "") + ((Days == 0) ? (Seconds + "с.") : "");
document.getElementById(name.id).innerHTML = "" + TimeStr + "";
setTimeout(function () {
Tick(CurrentTime, name);
}, 1000);
} else {
location.reload()
}
}
var totalRemains;
function CreateTimerGo(NowTime, name) {
totalRemains = NowTime;
setTimeout(function () {
TickGo(name)
}, 1000 );
}
function TickGo(name) {
totalRemains = totalRemains + 1000;
var Seconds = (parseInt(totalRemains / 1000));
var Days = Math.floor(Seconds / 86400);
Seconds -= Days * 86400;
var Hours = Math.floor(Seconds / 3600);
Seconds -= Hours * (3600);
var Minutes = Math.floor(Seconds / 60);
Seconds -= Minutes * (60);
var TimeStr = ((Days > 0) ? Days + "д. " : "") + ((Hours > 0) ? (Hours + "ч. ") : "") + ((Minutes > 0) ? (Minutes + "м. ") : "") + Seconds + "с.";
document.getElementById(name.id).innerHTML = "" + TimeStr + "";
setTimeout(function () {
TickGo(name)
}, 1000 );
}
?>