typos and code cosmetics

This commit is contained in:
tophf 2017-12-11 23:45:21 +03:00
parent 50b489478c
commit c3d9e8030b
2 changed files with 8 additions and 10 deletions

View File

@ -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", "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" "description": "Displayed in style manager when unable to connect to the background page"
}, },
"genericErrorOccurred": { "genericError": {
"message": "An error occured:", "message": "Error",
"description": "Used in various places to indicate some error occured. The error message is shown on the next line." "description": "Used in various places to indicate some error occurred."
}, },
"genericDisabledLabel": { "genericDisabledLabel": {
"message": "Disabled", "message": "Disabled",

View File

@ -238,18 +238,16 @@ window.addEventListener('showStyles:done', function _() {
} }
function loadMoreIfNeeded(event) { function loadMoreIfNeeded(event) {
let prefetchPages = 0; let pageToPrefetch = displayedPage;
if (event instanceof Event) { if (event instanceof Event) {
const scroller = document.scrollingElement; if ((loadMoreIfNeeded.prefetchedPage || 0) <= pageToPrefetch &&
if (scroller.scrollTop > scroller.scrollHeight / 2 && document.scrollingElement.scrollTop > document.scrollingElement.scrollHeight / 2) {
(loadMoreIfNeeded.prefetchedPage || 0) <= displayedPage) { loadMoreIfNeeded.prefetchedPage = ++pageToPrefetch;
prefetchPages = 1;
loadMoreIfNeeded.prefetchedPage = displayedPage + 1;
} else { } else {
return; return;
} }
} }
if (processedResults.length < (displayedPage + prefetchPages) * DISPLAY_PER_PAGE) { if (processedResults.length < pageToPrefetch * DISPLAY_PER_PAGE) {
setTimeout(load, DELAY_BEFORE_SEARCHING_STYLES); setTimeout(load, DELAY_BEFORE_SEARCHING_STYLES);
} }
} }