Code: Select all
<?php
if (isset($clock_count))
{
$display.="
<script>
var startTime = ".$clock_count.";
var timer;
window.onload = function() {
//set the initial time
var clock = document.getElementById('clock');
clock.innerHTML = startTime;
//start the timer
timer = setInterval(function() {
//remove a second
startTime--;
//a little bit of trickery to make sure the 0th second is counted, but only 0 appears on the clock
if (startTime < 0) {
clock.innerHTML = 0;
//alert('The timer went off!');";
if (isset($clock_reload) && $clock_reload==true) $display.="location.reload();";
$display.="clearInterval(timer);
} else {
clock.innerHTML = startTime;
}
}, 1000);
};
</script>
<div id='clock'></div>
<?php
";
}
?>