Файл: gamele.ru/js/timers.js
Строк: 49
<?php
function getTime(element) {
part = element.split(":");
for(j=0; j<3; j++){
if(part[j].charAt(0) == "0")
part[j] = part[j].substring(1, part[j].length);
}
hours = parseInt(part[0]);
minutes = parseInt(part[1]);
seconds = parseInt(part[2]);
time = hours*60*60+minutes*60+seconds;
return time;
}
function formatTime(time) {
hours = Math.floor(time/3600);
minutes = Math.floor(time/60) % 60;
seconds = time % 60;
timeString = '';
if(hours < 10)
timeString += "0";
timeString += hours + ":";
if(minutes < 10)
timeString += "0";
timeString += minutes + ":";
if(seconds < 10)
timeString += "0";
timeString += seconds;
return timeString;
}
function StartTimer(element) {
var today = document.getElementById(element).innerHTML;
today = getTime(today);
today -= 1;
if(today < 0){
document.location.href = document.location.href;
}
document.getElementById(element).innerHTML = formatTime(today);
}
?>