diff options
author | amzrk2 | 2020-06-16 16:09:04 +0800 |
---|---|---|
committer | amzrk2 | 2020-06-16 16:09:04 +0800 |
commit | f88c7b78f224bf746b831001ec8cef01693a4b3c (patch) | |
tree | 20fe1c16160171228b374c8718f858946162c8af /static/assets/js/fuji.min.js | |
parent | 03750a600a71df1276ccfcc7c817de5cb86e3e9f (diff) | |
download | hugo-theme-fuji-f88c7b78f224bf746b831001ec8cef01693a4b3c.tar.gz hugo-theme-fuji-f88c7b78f224bf746b831001ec8cef01693a4b3c.tar.bz2 hugo-theme-fuji-f88c7b78f224bf746b831001ec8cef01693a4b3c.zip |
Search page i18n
Diffstat (limited to 'static/assets/js/fuji.min.js')
-rw-r--r-- | static/assets/js/fuji.min.js | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/static/assets/js/fuji.min.js b/static/assets/js/fuji.min.js index 295ee61..6b0646d 100644 --- a/static/assets/js/fuji.min.js +++ b/static/assets/js/fuji.min.js @@ -95,8 +95,7 @@ function searchAll(key, index, counter) { weight: 1.0 }] }); - var result = fuse.search(key); - console.log(result); + var result = fuse.search(key); // console.log(result); if (result.length > 0) { document.getElementById('search-result').innerHTML = template('search-result-template', result); @@ -119,17 +118,20 @@ if (urlParams.has('s')) { xhr.open('GET', '/index.json', true); xhr.responseType = 'json'; - xhr.onerror = function (e) { + xhr.onerror = function () { infoElements[2].removeAttribute('style'); }; - xhr.onload = function () { + xhr.ontimeout = function () { + infoElements[2].removeAttribute('style'); + }; + + xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status === 200) { // use index json to search - console.log(xhr.response); - counter = searchAll(key, xhr.response, counter); - console.log(counter); + // console.log(xhr.response); + counter = searchAll(key, xhr.response, counter); // console.log(counter); if (counter === 'notFound') { infoElements[1].removeAttribute('style'); @@ -139,7 +141,6 @@ if (urlParams.has('s')) { infoElements[0].removeAttribute('style'); } } else { - console.error("Failed to get index.json, ".concat(xhr.status, " ").concat(xhr.statusText)); infoElements[2].removeAttribute('style'); } } |