From f88c7b78f224bf746b831001ec8cef01693a4b3c Mon Sep 17 00:00:00 2001 From: amzrk2 Date: Tue, 16 Jun 2020 16:09:04 +0800 Subject: Search page i18n --- assets/js/fuji.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'assets/js/fuji.js') 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'); } } -- cgit v1.2.3