mirror of
https://github.com/vichan-devel/vichan.git
synced 2025-01-31 04:13:49 +01:00
Add timer to auto reload js
This commit is contained in:
parent
3ec7b4015f
commit
beff737c9e
@ -28,7 +28,7 @@ $(document).ready(function(){
|
||||
var poll_interval;
|
||||
|
||||
// Add an update link
|
||||
$('.boardlist.bottom').prev().after("<a href='#' id='update_thread' style='padding-left:10px'>["+_("Update thread")+"]</a>");
|
||||
$('.boardlist.bottom').prev().after("<a href='#' id='update_thread' style='padding-left:10px'>["+_("Update thread")+"] (<span id='update_secs'></span>)</a>");
|
||||
|
||||
// Grab the settings
|
||||
var settings = new script_settings('auto-reload');
|
||||
@ -39,6 +39,7 @@ $(document).ready(function(){
|
||||
|
||||
// number of ms to wait before reloading
|
||||
var poll_interval_delay = poll_interval_mindelay_bottom;
|
||||
var poll_current_time = poll_interval_delay;
|
||||
|
||||
var end_of_page = false;
|
||||
|
||||
@ -70,6 +71,14 @@ $(document).ready(function(){
|
||||
window_active = false;
|
||||
});
|
||||
|
||||
var timer_update = function() {
|
||||
$('#update_secs').text(poll_current_time/1000);
|
||||
}
|
||||
|
||||
var decrement_timer = function() {
|
||||
poll_current_time = poll_current_time - 1000;
|
||||
}
|
||||
|
||||
var recheck_activated = function() {
|
||||
if (new_posts && window_active &&
|
||||
$(window).scrollTop() + $(window).height() >=
|
||||
@ -117,6 +126,7 @@ $(document).ready(function(){
|
||||
}
|
||||
|
||||
poll_interval = setTimeout(poll, poll_interval_delay);
|
||||
poll_current_time = poll_interval_delay;
|
||||
};
|
||||
|
||||
$(window).scroll(function() {
|
||||
@ -130,11 +140,15 @@ $(document).ready(function(){
|
||||
|
||||
clearTimeout(poll_interval);
|
||||
poll_interval = setTimeout(poll, poll_interval_shortdelay);
|
||||
poll_current_time = poll_interval_shortdelay;
|
||||
end_of_page = true;
|
||||
}).trigger('scroll');
|
||||
|
||||
$('#update_thread').on('click', poll);
|
||||
setInterval(timer_update, 1000);
|
||||
setInterval(decrement_timer, 1000);
|
||||
|
||||
poll_interval = setTimeout(poll, poll_interval_delay);
|
||||
poll_interval = setInterval(poll, poll_interval_delay);
|
||||
timer_update();
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user