diff --git a/README.md b/README.md index 39bd61b..15fc966 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,8 @@ Run English Pal first, then run the test using pytest as follows: pytest --html= The above command will generate a HTML report file pytest_report.html after finishing executing test_add_word.py. Note: you need to install pytest-html package first: pip install pytest-html. +You may also want to use [webdriver-manager](https://pypi.org/project/webdriver-manager/) from PyPI, so that you can avoid tediously installing a web driver executable manually. However, my experience shows that webdriver-manager is too slow. For example, it took me 16 minutes to run 9 tests, while with the pre-installed web driver executable, it took less than 2 minutes. + ## TODO diff --git a/app/static/js/fillword.js b/app/static/js/fillword.js index b3a8b42..18461f0 100644 --- a/app/static/js/fillword.js +++ b/app/static/js/fillword.js @@ -1,5 +1,6 @@ -let isRead = true; -let isChoose = true; +// initialize from localStorage +let isRead = localStorage.getItem('readChecked') !== 'false'; // default to true +let isChoose = localStorage.getItem('chooseChecked') !== 'false'; function getWord() { return window.getSelection ? window.getSelection() : document.selection.createRange().text; @@ -11,6 +12,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 +26,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..e8a3cf8 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'; // default to true 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/templates/login.html b/app/templates/login.html index b8eb118..b0806b6 100644 --- a/app/templates/login.html +++ b/app/templates/login.html @@ -15,6 +15,10 @@ alert('输入不能为空!'); return false; } + if (password.includes(' ')) { + alert('输入不能包含空格!'); + return false; + } $.post( "/login", {'username': username, 'password': password}, function (response) { diff --git a/app/templates/mainpage_get.html b/app/templates/mainpage_get.html index e96e8dc..3ba0ece 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,22 @@ {% endfor %} {% endif %} +