diff --git a/app/static/js/fillword.js b/app/static/js/fillword.js index b3a8b42..82f00ea 100644 --- a/app/static/js/fillword.js +++ b/app/static/js/fillword.js @@ -1,5 +1,5 @@ -let isRead = true; -let isChoose = true; +let isRead = localStorage.getItem('readChecked') !== 'false'; +let isChoose = localStorage.getItem('chooseChecked') !== 'false'; function getWord() { return window.getSelection ? window.getSelection() : document.selection.createRange().text; @@ -11,6 +11,7 @@ function fillInWord() { if (!isChoose) return; const element = document.getElementById("selected-words"); element.value = element.value + " " + word; + localStorage.setItem('selectedWords', element.value); } document.getElementById("text-content").addEventListener("click", fillInWord, false); @@ -24,13 +25,15 @@ inputSlider.oninput = () => { function onReadClick() { isRead = !isRead; + localStorage.setItem('readChecked', isRead); } function onChooseClick() { isChoose = !isChoose; + localStorage.setItem('chooseChecked', isChoose); } // 如果网页刷新,停止播放声音 if (performance.getEntriesByType("navigation")[0].type == "reload") { Reader.stopRead(); -} \ No newline at end of file +} diff --git a/app/static/js/highlight.js b/app/static/js/highlight.js index 76b4793..42d3aaf 100644 --- a/app/static/js/highlight.js +++ b/app/static/js/highlight.js @@ -1,4 +1,4 @@ -let isHighlight = true; +let isHighlight = localStorage.getItem('highlightChecked') !== 'false'; function cancelBtnHandler() { cancelHighlighting(); @@ -39,7 +39,7 @@ function highLight() { } totalSet = new Set([...totalSet, ...matches]); } - } + } // 删除所有的mark标签,防止标签发生嵌套 articleContent = articleContent.replace(/<(mark)[^>]*>/gi, ""); articleContent = articleContent.replace(/<(\/mark)[^>]*>/gi, ""); @@ -73,6 +73,7 @@ function toggleHighlighting() { isHighlight = true; highLight(); } + localStorage.setItem('highlightChecked', isHighlight); } showBtnHandler(); \ No newline at end of file diff --git a/app/static/wordfreqapp.db b/app/static/wordfreqapp.db new file mode 100644 index 0000000..312881a Binary files /dev/null and b/app/static/wordfreqapp.db differ diff --git a/app/templates/mainpage_get.html b/app/templates/mainpage_get.html index e96e8dc..5c57c91 100644 --- a/app/templates/mainpage_get.html +++ b/app/templates/mainpage_get.html @@ -34,9 +34,9 @@
粘贴1篇文章 (English only)
{% if d_len > 0 %}最常见的词
@@ -53,5 +53,20 @@ {% endfor %} {% endif %} +