From 8d75042f02d9ba216dfa20fa254d5e8801fc9690 Mon Sep 17 00:00:00 2001 From: derv82 Date: Sun, 3 Dec 2017 15:34:44 -0800 Subject: [PATCH] Address part of PR feedback. Main diff: Wrapped onDOMready() & SearchResults() function in IIFE closure. * [X] const SearchResults = ... // should be inside a closure (IIFE @ Top) * [X] SearchUserstyles should be firstLetterLowercase * [X] Don't fetch category on load; use regexp to derive category. (left 'HEAD' code commented-out). * [X] Don't use XMLHttpRequest() anymore (used in 3 places?): Use download() which accepts custom request params. * [X] Remove unused getters ('getCurrentPage' & others?) * [X] const BASE_USO_URL = 'https://userstyles.org'; @ top of searchResults closure. Refer elsewhere. * [X] const searchUrl = new URL... should be a single multiline statement (new URL('...' +\ '...' * [X] .innerHTML = ... // use .textContent = ... instead * [X] Don't use `setAttribute` on 'disabled': $('..-prev').disabled = currentDisplayedPage <= 1 || loading * [X] Don't use .indexOf() on strings, use .includes() * [X] Move onDOMReady() code to top of file. --- popup.html | 4 +- popup/search-results.js | 901 +++++++++++++++++++--------------------- 2 files changed, 438 insertions(+), 467 deletions(-) diff --git a/popup.html b/popup.html index 92c024ec..0464a0e8 100644 --- a/popup.html +++ b/popup.html @@ -85,7 +85,7 @@