From 0f7220fa403fba4e7ecbbf59f1365faf72748ce1 Mon Sep 17 00:00:00 2001 From: ScriptKi77y Date: Mon, 29 Sep 2014 22:02:57 -0500 Subject: [PATCH 1/2] 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. --- js/auto-reload.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/js/auto-reload.js b/js/auto-reload.js index 0e408637..2c4a8c4a 100644 --- a/js/auto-reload.js +++ b/js/auto-reload.js @@ -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; From e9352a2ea87264941c96ee4d4ef686a24dc68f32 Mon Sep 17 00:00:00 2001 From: ScriptKi77y Date: Tue, 30 Sep 2014 01:58:23 -0500 Subject: [PATCH 2/2] Quick fix to remove lag.. Executing a function to make a get request while simultaneously triggering a scroll event within the executed scroll event is probably not the best idea. This still needs work, there should probably be something else used to check for updates, such as an event where page has focus or something else that doesn't get called so many times, preferably something that reduces the timer instead. This is just a quick fix to stop all the lag on threads when scrolling near the bottom. --- js/auto-reload.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/auto-reload.js b/js/auto-reload.js index 2c4a8c4a..8543b703 100644 --- a/js/auto-reload.js +++ b/js/auto-reload.js @@ -211,7 +211,7 @@ $(document).ready(function(){ } end_of_page = true; } - }).trigger('scroll'); + }); $('#update_thread').on('click', function() { poll(manualUpdate = true); return false; });