Final version of jquery pause / resume for page refresh

This commit is contained in:
laf
2015-03-08 21:33:40 +00:00
parent 01a8b97900
commit fa3944cd8f
2 changed files with 54 additions and 7 deletions
+47 -7
View File
@@ -342,15 +342,55 @@ if (is_array($sql_debug) && is_array($php_debug)) {
if ($no_refresh !== TRUE && $config['page_refresh'] != 0) {
$refresh = $config['page_refresh'] * 1000;
echo('<script> type="text/javascript">
echo('<script type="text/javascript">
$(document).ready(function() {
setInterval("refreshPage()", '. $refresh .');
$("#countdown_timer_status").html("<img src=\"images/16/clock_pause.png\"> Pause");
var Countdown = {
sec: '. $config['page_refresh'] .',
Start: function() {
var cur = this;
this.interval = setInterval(function() {
$("#countdown_timer_status").html("<img src=\"images/16/clock_pause.png\"> Pause");
cur.sec -= 1;
display_time = cur.sec;
if (display_time == 0) {
location.reload();
}
if (display_time % 1 === 0 && display_time <= 300) {
$("#countdown_timer").html("<img src=\"images/16/clock.png\"> Refresh in " + display_time);
}
}, 1000);
},
Pause: function() {
clearInterval(this.interval);
$("#countdown_timer_status").html("<img src=\"images/16/clock_play.png\"> Resume");
delete this.interval;
},
Resume: function() {
if (!this.interval) this.Start();
}
};
Countdown.Start();
$("#countdown_timer_status").click("", function(event) {
event.preventDefault();
if (Countdown.interval) {
Countdown.Pause();
} else {
Countdown.Resume();
}
});
$("#countdown_timer").click("", function(event) {
event.preventDefault();
});
});
function refreshPage() {
location.reload();
}
</script>');
}