aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortdro <tdro@noreply.example.com>2022-10-24 00:52:52 -0400
committertdro <tdro@noreply.example.com>2022-10-24 00:52:52 -0400
commitb204765687c5f65f945fb69f91dd225b9a8215b2 (patch)
tree7eccdfa0e207340c3edcc4d03473299b4dfbfe19
parent569e5136479d98e274c75a355635088b6b4a8723 (diff)
downloadcanory-b204765687c5f65f945fb69f91dd225b9a8215b2.tar.gz
canory-b204765687c5f65f945fb69f91dd225b9a8215b2.tar.bz2
canory-b204765687c5f65f945fb69f91dd225b9a8215b2.zip
static/js/fixedsearch: Camel case
-rw-r--r--assets/js/index.js23
-rw-r--r--static/js/fixedsearch.ts23
2 files changed, 20 insertions, 26 deletions
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"
diff --git a/static/js/fixedsearch.ts b/static/js/fixedsearch.ts
index 6e77b3f..4a24144 100644
--- a/static/js/fixedsearch.ts
+++ b/static/js/fixedsearch.ts
@@ -92,23 +92,20 @@
}
});
- 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();
}
/* Load script based on https://stackoverflow.com/a/55451823 */
- function load_script(url) {
+ function loadScript(url) {
return new Promise(function (resolve, reject) {
const script = document.createElement("script");
script.onerror = reject;
@@ -125,14 +122,14 @@
});
}
- let first_run = true; // allow us to delay loading json data unless search activated
+ let firstRun = true; // allow us to delay loading json data unless search activated
function initialize() {
- if (first_run) {
- load_script(window.location.origin + "/js/fuzzysort.js")
+ if (firstRun) {
+ loadScript(window.location.origin + "/js/fuzzysort.js")
.then(() => {
- first_run = false;
- fetch_JSON("/index.json", function (data) {
+ firstRun = false;
+ fetchJson("/index.json", function (data) {
const options = {
key: ["title"],
};