summaryrefslogtreecommitdiffstats
path: root/assets/js/fuji.js
diff options
context:
space:
mode:
authoramzrk22020-06-16 16:09:04 +0800
committeramzrk22020-06-16 16:09:04 +0800
commitf88c7b78f224bf746b831001ec8cef01693a4b3c (patch)
tree20fe1c16160171228b374c8718f858946162c8af /assets/js/fuji.js
parent03750a600a71df1276ccfcc7c817de5cb86e3e9f (diff)
downloadhugo-theme-fuji-f88c7b78f224bf746b831001ec8cef01693a4b3c.tar.gz
hugo-theme-fuji-f88c7b78f224bf746b831001ec8cef01693a4b3c.tar.bz2
hugo-theme-fuji-f88c7b78f224bf746b831001ec8cef01693a4b3c.zip
Search page i18n
Diffstat (limited to 'assets/js/fuji.js')
-rw-r--r--assets/js/fuji.js14
1 files changed, 8 insertions, 6 deletions
diff --git a/assets/js/fuji.js b/assets/js/fuji.js
index bf9eabc..14d63bc 100644
--- a/assets/js/fuji.js
+++ b/assets/js/fuji.js
@@ -105,7 +105,7 @@ function searchAll(key, index, counter) {
],
});
let result = fuse.search(key);
- console.log(result);
+ // console.log(result);
if (result.length > 0) {
document.getElementById('search-result').innerHTML = template('search-result-template', result);
return [new Date().getTime() - counter, result.length];
@@ -124,16 +124,19 @@ if (urlParams.has('s')) {
let xhr = new XMLHttpRequest();
xhr.open('GET', '/index.json', true);
xhr.responseType = 'json';
- xhr.onerror = (e) => {
+ xhr.onerror = () => {
infoElements[2].removeAttribute('style');
};
- xhr.onload = () => {
+ xhr.ontimeout = () => {
+ infoElements[2].removeAttribute('style');
+ };
+ xhr.onreadystatechange = () => {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
// use index json to search
- console.log(xhr.response);
+ // console.log(xhr.response);
counter = searchAll(key, xhr.response, counter);
- console.log(counter);
+ // console.log(counter);
if (counter === 'notFound') {
infoElements[1].removeAttribute('style');
} else {
@@ -142,7 +145,6 @@ if (urlParams.has('s')) {
infoElements[0].removeAttribute('style');
}
} else {
- console.error(`Failed to get index.json, ${xhr.status} ${xhr.statusText}`);
infoElements[2].removeAttribute('style');
}
}