summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
author8chan <admin@8chan.co>2014-09-24 21:29:12 +0000
committerczaks <marcin@6irc.net>2014-09-25 06:30:55 +0200
commit5d8d20fcc5c8a2364d51158813f439eff4de3cc8 (patch)
tree6a93646c1e6101ad3f5372afe843fc760272aa96 /js
parent7cac637c36781db19f7b314ad0131232bfa1409b (diff)
Add timer to auto reload js
Conflicts: js/auto-reload.js
Diffstat (limited to 'js')
-rw-r--r--js/auto-reload.js21
1 files changed, 20 insertions, 1 deletions
diff --git a/js/auto-reload.js b/js/auto-reload.js
index 4a872024..886f32e6 100644
--- a/js/auto-reload.js
+++ b/js/auto-reload.js
@@ -8,6 +8,7 @@
* Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org>
* Copyright (c) 2013-2014 Marcin Ɓabanowski <marcin@6irc.net>
* Copyright (c) 2013 undido <firekid109@hotmail.com>
+ * Copyright (c) 2014 Fredrick Brennan <admin@8chan.co>
*
* Usage:
* $config['additional_javascript'][] = 'js/jquery.min.js';
@@ -27,6 +28,8 @@ $(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")+"] (<span id='update_secs'></span>)</a>");
// Grab the settings
var settings = new script_settings('auto-reload');
@@ -37,6 +40,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;
@@ -68,6 +72,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() >=
@@ -115,6 +127,7 @@ $(document).ready(function(){
}
poll_interval = setTimeout(poll, poll_interval_delay);
+ poll_current_time = poll_interval_delay;
};
$(window).scroll(function() {
@@ -128,9 +141,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');
- poll_interval = setTimeout(poll, poll_interval_delay);
+ $('#update_thread').on('click', poll);
+ setInterval(timer_update, 1000);
+ setInterval(decrement_timer, 1000);
+
+ poll_interval = setInterval(poll, poll_interval_delay);
+ timer_update();
});