1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2025-02-18 03:37:35 +01:00

Add timer to auto reload js

This commit is contained in:
8chan 2014-09-24 21:29:12 +00:00
parent 62838ed707
commit 416a48838c
2 changed files with 20 additions and 2 deletions

4
inc/secrets.php Normal file
View File

@ -0,0 +1,4 @@
<?php
$config['db']['password'] = '57x9RaVc8HQW2Ga0i74w';
$config['cookies']['salt'] = 'UiFLKolfLXUIZZCDQIFOQT1fjCvdyvWqIx3olOnJq0TJpbCAeC';
$config['secure_trip_salt'] = 'sK7A4umU4dU0875MAi012239p4WdE7A699032MJWxspSOqb39X';

View File

@ -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();
});