summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScriptKi77y <ellocodoce@gmail.com>2014-09-29 22:02:57 -0500
committerczaks <marcin@6irc.net>2014-10-05 17:49:30 +0200
commit2ece97d6858b98b3836840bca0da8f4f08fdc2f8 (patch)
treed8e6f1c237abe2c3612681acfa6b8561f637bd34
parent86eed0b3494f6d7cb516393bbed702bfda89b2c4 (diff)
Scroll hook thread polling adjusttment.
Fixed an issue with the scroll hook thread polling. Users scrolling near the bottom of the page are making upwards of 7-10 requests a second to the site. Added a small timer using the "poll_interval_mindelay" value to prevent unnecessary polling, one is enough during this minimum time delay.
-rw-r--r--js/auto-reload.js14
1 files changed, 13 insertions, 1 deletions
diff --git a/js/auto-reload.js b/js/auto-reload.js
index 19581b5e..8a4ab949 100644
--- a/js/auto-reload.js
+++ b/js/auto-reload.js
@@ -121,6 +121,18 @@ $(document).ready(function(){
clearInterval(countdown_interval);
}
+ var epoch = (new Date).getTime();
+ var epochold = epoch;
+
+ var timeDiff = function (delay) {
+ if((epoch-epochold) > delay) {
+ epochold = epoch = (new Date).getTime();
+ return true;
+ }else{
+ epoch = (new Date).getTime();
+ return;
+ }
+ }
var poll = function(manualUpdate) {
stop_auto_update();
@@ -185,7 +197,7 @@ $(document).ready(function(){
end_of_page = false;
return;
} else {
- if($("#auto_update_status").is(':checked')) {
+ if($("#auto_update_status").is(':checked') && timeDiff(poll_interval_mindelay)) {
poll(manualUpdate = true);
}
end_of_page = true;