From 7dcd2aa858f53af4fd5903a4861686da7754b2da Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Thu, 17 Jul 2014 15:32:38 -0700 Subject: [PATCH] Make an option for 'update stale index' functionality. --- builds/appchan-x.user.js | 5 ++++- builds/crx/script.js | 5 ++++- src/General/Config.coffee | 6 +++++- src/General/Index.coffee | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js index 25e21bbc6..52873c1fa 100644 --- a/builds/appchan-x.user.js +++ b/builds/appchan-x.user.js @@ -139,6 +139,7 @@ main: { 'Miscellaneous': { 'JSON Navigation': [true, 'Use JSON for loading the Board Index and Threads. Also allows searching and sorting the board index and infinite scolling.'], + 'Update Stale Index': [true, 'Updates the board index if it hasn\'t been updated in five or more minutes when 4chan gains browser focus (like switching tabs or windows).'], 'Catalog Links': [true, 'Add toggle link in header menu to turn Navigation links into links to each board\'s catalog.'], 'External Catalog': [false, 'Link to external catalog instead of the internal one.'], 'Desktop Notifications': [false, 'Enables desktop notifications across various appchan x features.'], @@ -4772,7 +4773,9 @@ Rice.nodes(this.navLinks); this.currentPage = this.getCurrentPage(); $.on(d, 'scroll', this.scroll); - $.on(window, 'focus', this.updateIfNeeded); + if (Conf['Update Stale Index']) { + $.on(window, 'focus', this.updateIfNeeded); + } $.on(this.pagelist, 'click', this.cb.pageNav); returnLink = $.el('a', { id: 'returnIcon', diff --git a/builds/crx/script.js b/builds/crx/script.js index 8b2237de7..62b68a696 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -114,6 +114,7 @@ main: { 'Miscellaneous': { 'JSON Navigation': [true, 'Use JSON for loading the Board Index and Threads. Also allows searching and sorting the board index and infinite scolling.'], + 'Update Stale Index': [true, 'Updates the board index if it hasn\'t been updated in five or more minutes when 4chan gains browser focus (like switching tabs or windows).'], 'Catalog Links': [true, 'Add toggle link in header menu to turn Navigation links into links to each board\'s catalog.'], 'External Catalog': [false, 'Link to external catalog instead of the internal one.'], 'Desktop Notifications': [false, 'Enables desktop notifications across various appchan x features.'], @@ -4826,7 +4827,9 @@ Rice.nodes(this.navLinks); this.currentPage = this.getCurrentPage(); $.on(d, 'scroll', this.scroll); - $.on(window, 'focus', this.updateIfNeeded); + if (Conf['Update Stale Index']) { + $.on(window, 'focus', this.updateIfNeeded); + } $.on(this.pagelist, 'click', this.cb.pageNav); returnLink = $.el('a', { id: 'returnIcon', diff --git a/src/General/Config.coffee b/src/General/Config.coffee index 7cff5133a..4bfb6bbcd 100644 --- a/src/General/Config.coffee +++ b/src/General/Config.coffee @@ -1,10 +1,14 @@ Config = main: 'Miscellaneous': - 'JSON Navigation' : [ + 'JSON Navigation': [ true 'Use JSON for loading the Board Index and Threads. Also allows searching and sorting the board index and infinite scolling.' ] + 'Update Stale Index': [ + true + 'Updates the board index if it hasn\'t been updated in five or more minutes when 4chan gains browser focus (like switching tabs or windows).' + ] 'Catalog Links': [ true 'Add toggle link in header menu to turn Navigation links into links to each board\'s catalog.' diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 6f8ebb91c..e9da351a9 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -115,7 +115,7 @@ Index = @currentPage = @getCurrentPage() $.on d, 'scroll', @scroll - $.on window, 'focus', @updateIfNeeded + $.on window, 'focus', @updateIfNeeded if Conf['Update Stale Index'] $.on @pagelist, 'click', @cb.pageNav returnLink = $.el 'a',