From c3d9e8030bfeb4d9fd554684f6538cd0bf3e95f0 Mon Sep 17 00:00:00 2001 From: tophf Date: Mon, 11 Dec 2017 23:45:21 +0300 Subject: [PATCH] typos and code cosmetics --- _locales/en/messages.json | 6 +++--- popup/search-results.js | 12 +++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 50649128..7e4ca834 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -202,9 +202,9 @@ "message": "Cannot function properly because of a known bug in this version of Firefox: chrome.extension.getBackgroundPage() doesn't return a valid result", "description": "Displayed in style manager when unable to connect to the background page" }, - "genericErrorOccurred": { - "message": "An error occured:", - "description": "Used in various places to indicate some error occured. The error message is shown on the next line." + "genericError": { + "message": "Error", + "description": "Used in various places to indicate some error occurred." }, "genericDisabledLabel": { "message": "Disabled", diff --git a/popup/search-results.js b/popup/search-results.js index d49cf82c..abf619cf 100755 --- a/popup/search-results.js +++ b/popup/search-results.js @@ -238,18 +238,16 @@ window.addEventListener('showStyles:done', function _() { } function loadMoreIfNeeded(event) { - let prefetchPages = 0; + let pageToPrefetch = displayedPage; if (event instanceof Event) { - const scroller = document.scrollingElement; - if (scroller.scrollTop > scroller.scrollHeight / 2 && - (loadMoreIfNeeded.prefetchedPage || 0) <= displayedPage) { - prefetchPages = 1; - loadMoreIfNeeded.prefetchedPage = displayedPage + 1; + if ((loadMoreIfNeeded.prefetchedPage || 0) <= pageToPrefetch && + document.scrollingElement.scrollTop > document.scrollingElement.scrollHeight / 2) { + loadMoreIfNeeded.prefetchedPage = ++pageToPrefetch; } else { return; } } - if (processedResults.length < (displayedPage + prefetchPages) * DISPLAY_PER_PAGE) { + if (processedResults.length < pageToPrefetch * DISPLAY_PER_PAGE) { setTimeout(load, DELAY_BEFORE_SEARCHING_STYLES); } }