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 ++++++++------ assets/scss/_fuji-style/_content.scss | 7 ++++++- i18n/en.toml | 9 +++++++++ i18n/ja.toml | 9 +++++++++ i18n/nl.toml | 9 +++++++++ i18n/zh-hans.toml | 9 +++++++++ i18n/zh-hant.toml | 9 +++++++++ layouts/_default/search.html | 8 ++++---- static/assets/css/fuji.min.css | 5 ++++- static/assets/css/fuji.min.css.map | 2 +- static/assets/js/fuji.min.js | 17 +++++++++-------- static/assets/js/fuji.min.js.map | 2 +- 12 files changed, 78 insertions(+), 22 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'); } } diff --git a/assets/scss/_fuji-style/_content.scss b/assets/scss/_fuji-style/_content.scss index 10003ef..2cfd184 100644 --- a/assets/scss/_fuji-style/_content.scss +++ b/assets/scss/_fuji-style/_content.scss @@ -187,8 +187,13 @@ article { button { flex: 0 1 auto; - padding: 0 0.75rem; + padding: 0 0.5rem; word-break: keep-all; height: 2.5rem; + + ion-icon { + height: 100%; + font-size: 1.6rem; + } } } diff --git a/i18n/en.toml b/i18n/en.toml index f260aa9..84cbd94 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -42,3 +42,12 @@ [tagsCurrentTag] other = "Posts with the tag {{ .Title }}: " + +[searchSuccess] + other = "[NUM] results ([TIME] ms)" + +[searchNotFound] + other = "Results not found" + +[searchFailed] + other = "Failed to load index file" diff --git a/i18n/ja.toml b/i18n/ja.toml index b9d5133..5e1d863 100644 --- a/i18n/ja.toml +++ b/i18n/ja.toml @@ -42,3 +42,12 @@ [tagsCurrentTag] other = "タグ {{ .Title }} を持つ記事:" + +[searchSuccess] + other = "[NUM] 件 ([TIME] ミリ秒)" + +[searchNotFound] + other = "検索できませんでした" + +[searchFailed] + other = "インデックスを取得できません" diff --git a/i18n/nl.toml b/i18n/nl.toml index 6593ac6..ff8cacf 100644 --- a/i18n/nl.toml +++ b/i18n/nl.toml @@ -42,3 +42,12 @@ [tagsCurrentTag] other = "Alle posts met de tag {{ .Title }}: " + +[searchSuccess] + other = "[NUM] results ([TIME] ms) [Translation Help Needed]" + +[searchNotFound] + other = "Results not found [Translation Help Needed]" + +[searchFailed] + other = "Failed to load index file [Translation Help Needed]" diff --git a/i18n/zh-hans.toml b/i18n/zh-hans.toml index f4eec4e..37387a0 100644 --- a/i18n/zh-hans.toml +++ b/i18n/zh-hans.toml @@ -42,3 +42,12 @@ [tagsCurrentTag] other = "拥有标签 {{ .Title }} 的文章:" + +[searchSuccess] + other = "找到 [NUM] 条结果 (用时 [TIME] 毫秒)" + +[searchNotFound] + other = "未找到结果" + +[searchFailed] + other = "无法获取索引" diff --git a/i18n/zh-hant.toml b/i18n/zh-hant.toml index d6ba777..f629617 100644 --- a/i18n/zh-hant.toml +++ b/i18n/zh-hant.toml @@ -42,3 +42,12 @@ [tagsCurrentTag] other = "擁有標籤 {{ .Title }} 的文章:" + +[searchSuccess] + other = "[NUM] 項結果 (搜尋時間 [TIME] 毫秒)" + +[searchNotFound] + other = "未找到結果" + +[searchFailed] + other = "無法獲取索引" diff --git a/layouts/_default/search.html b/layouts/_default/search.html index c37d6b9..8948e45 100644 --- a/layouts/_default/search.html +++ b/layouts/_default/search.html @@ -5,14 +5,14 @@
- +
- - - + + +