Improved countdown timer
This commit is contained in:
parent
a0ae475ea4
commit
98c62258b4
@ -97,22 +97,27 @@
|
|||||||
: '') .
|
: '') .
|
||||||
'<p>Your ban was filed on <strong>' .
|
'<p>Your ban was filed on <strong>' .
|
||||||
formatDate($ban['set']) .
|
formatDate($ban['set']) .
|
||||||
'</strong>, and ' .
|
'</strong>, and <span id="expires">' .
|
||||||
($ban['expires'] ?
|
($ban['expires'] ?
|
||||||
'expires <span id="until">' . until($ban['expires']) . '</span> from now, which is on <strong><span id="enddate">' .
|
'expires <span id="countdown">' . until($ban['expires']) . '</span> from now, which is on <strong>' .
|
||||||
formatDate($ban['expires']) .
|
formatDate($ban['expires']) .
|
||||||
'</span></strong>
|
'</strong>
|
||||||
<script>
|
<script>
|
||||||
// return date("jS F, Y", $timestamp);
|
// return date("jS F, Y", $timestamp);
|
||||||
var secondsLeft = ' . ($ban['expires'] - time()) . '
|
var secondsLeft = ' . ($ban['expires'] - time()) . '
|
||||||
var end = new Date().getTime() + secondsLeft*1000;
|
var end = new Date().getTime() + secondsLeft*1000;
|
||||||
function updateExpiresTime() {
|
function updateExpiresTime() {
|
||||||
document.getElementById("until").innerHTML = until(end);
|
countdown.firstChild.nodeValue = until(end);
|
||||||
}
|
}
|
||||||
function until(end) {
|
function until(end) {
|
||||||
var now = new Date().getTime();
|
var now = new Date().getTime();
|
||||||
var diff = Math.round((end - now) / 1000); // in seconds
|
var diff = Math.round((end - now) / 1000); // in seconds
|
||||||
if (diff < 60) {
|
if (diff < 0) {
|
||||||
|
document.getElementById("expires").innerHTML = "has since expired. Refresh the page to continue.";
|
||||||
|
//location.reload(true);
|
||||||
|
clearInterval(int);
|
||||||
|
return "";
|
||||||
|
} else if (diff < 60) {
|
||||||
return diff + " second" + (diff == 1 ? "" : "s");
|
return diff + " second" + (diff == 1 ? "" : "s");
|
||||||
} else if (diff < 60*60) {
|
} else if (diff < 60*60) {
|
||||||
return (num = Math.round(diff/(60))) + " minute" + (num == 1 ? "" : "s");
|
return (num = Math.round(diff/(60))) + " minute" + (num == 1 ? "" : "s");
|
||||||
@ -126,11 +131,13 @@
|
|||||||
return (num = Math.round(diff/(60*60*365))) + " year" + (num == 1 ? "" : "s");
|
return (num = Math.round(diff/(60*60*365))) + " year" + (num == 1 ? "" : "s");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var countdown = document.getElementById("countdown");
|
||||||
|
|
||||||
updateExpiresTime();
|
updateExpiresTime();
|
||||||
setInterval(updateExpiresTime, 1000);
|
var int = setInterval(updateExpiresTime, 1000);
|
||||||
</script>'
|
</script>'
|
||||||
: '<em>will not expire</em>' ) .
|
: '<em>will not expire</em>.' ) .
|
||||||
'</p>
|
'</span></p>
|
||||||
<p>Your IP address is <strong>' . $_SERVER['REMOTE_ADDR'] . '</strong>.</p>
|
<p>Your IP address is <strong>' . $_SERVER['REMOTE_ADDR'] . '</strong>.</p>
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user