From b204765687c5f65f945fb69f91dd225b9a8215b2 Mon Sep 17 00:00:00 2001 From: tdro Date: Mon, 24 Oct 2022 00:52:52 -0400 Subject: static/js/fixedsearch: Camel case --- assets/js/index.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'assets') diff --git a/assets/js/index.js b/assets/js/index.js index 7a456ad..5a4fb39 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -392,20 +392,17 @@ container.removeAttribute("data-focus"); } }); - function fetch_JSON(path, callback) { + function fetchJson(url, callback) { const httpRequest = new XMLHttpRequest(); httpRequest.onreadystatechange = function() { - if (httpRequest.readyState === 4) { - if (httpRequest.status === 200) { - const data = JSON.parse(httpRequest.responseText); - if (callback) callback(data); - } + if (httpRequest.readyState === 4 && httpRequest.status === 200) { + if (callback) callback(JSON.parse(httpRequest.responseText)); } }; - httpRequest.open("GET", path); + httpRequest.open("GET", url); httpRequest.send(); } - function load_script(url) { + function loadScript(url) { return new Promise(function(resolve, reject) { const script = document.createElement("script"); script.onerror = reject; @@ -418,12 +415,12 @@ script.src = url; }); } - let first_run = true; + let firstRun = true; function initialize() { - if (first_run) { - load_script(window.location.origin + "/js/fuzzysort.js").then(()=>{ - first_run = false; - fetch_JSON("/index.json", function(data) { + if (firstRun) { + loadScript(window.location.origin + "/js/fuzzysort.js").then(()=>{ + firstRun = false; + fetchJson("/index.json", function(data) { const options = { key: [ "title" -- cgit v1.2.3