1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-25 16:00:22 +01:00

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.
This commit is contained in:
ScriptKi77y 2014-09-29 22:02:57 -05:00
parent 10861c8012
commit 0f7220fa40

View File

@ -129,6 +129,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();
@ -194,7 +206,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;