From 5a622048644f962b1030193db784b50871b21525 Mon Sep 17 00:00:00 2001 From: AAAzsf <1536850375@qq.com> Date: Mon, 13 Jun 2022 15:56:58 +0800 Subject: [PATCH 1/4] =?UTF-8?q?BugFix407:=20fillword.js=20=E5=9C=A8?= =?UTF-8?q?=E5=88=92=E6=96=B0=E8=AF=8D=E5=90=8E=EF=BC=8C=E4=BC=9A=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E5=BC=80=E5=A7=8B=E8=AF=BB=E6=96=B0=E8=AF=8D=EF=BC=88?= =?UTF-8?q?=E4=B9=8B=E5=89=8D=E6=98=AF=E4=BC=9A=E8=AF=BB=E5=AE=8C=E4=B9=8B?= =?UTF-8?q?=E5=89=8D=E5=88=92=E7=9A=84=E8=AF=8D=E5=90=8E=E6=89=8D=E5=BC=80?= =?UTF-8?q?=E5=A7=8B=E8=AF=BB=E6=96=B0=E8=AF=8D=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/static/js/fillword.js | 1 + 1 file changed, 1 insertion(+) diff --git a/app/static/js/fillword.js b/app/static/js/fillword.js index 3e3fbd9..0b19de8 100644 --- a/app/static/js/fillword.js +++ b/app/static/js/fillword.js @@ -15,6 +15,7 @@ function fillinWord(){ } document.getElementById("text-content").addEventListener("click", fillinWord, false); function read(s){ + reader.cancel() var msg = new SpeechSynthesisUtterance(s); reader.speak(msg); } -- 2.17.1 From 72e23f4e13a8ee98628529dbfc2e21c339757015 Mon Sep 17 00:00:00 2001 From: AAAzsf <1536850375@qq.com> Date: Mon, 13 Jun 2022 16:33:03 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=AF=B9fillword.js=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E4=BA=86=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/static/js/fillword.js | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/app/static/js/fillword.js b/app/static/js/fillword.js index 0b19de8..71c9cca 100644 --- a/app/static/js/fillword.js +++ b/app/static/js/fillword.js @@ -1,30 +1,36 @@ -isRead = true; -isChoose = true; -var reader = window.speechSynthesis; // 全局定义朗读者,以便朗读和暂停 - +var isRead = true; +var isChoose = true; +const reader = window.speechSynthesis; // 全局定义朗读者,以便朗读和暂停 +//获取字符 function getWord(){ - var word = window.getSelection?window.getSelection():document.selection.createRange().text; - return word; + return window.getSelection?window.getSelection():document.selection.createRange().text; } -function fillinWord(){ - var word = getWord(); +//填充字符 +function fillingWord(){ + let word = getWord(); if (isRead) read(word); if (!isChoose) return; - var element = document.getElementById("selected-words"); + let element = document.getElementById("selected-words"); element.value = element.value + " " + word; } -document.getElementById("text-content").addEventListener("click", fillinWord, false); -function read(s){ +document.getElementById("text-content").addEventListener("click", fillingWord, false); +//朗读单词 +//@word 要朗读的单词 +function read(word){ + //关闭当前正在读的单词 reader.cancel() - var msg = new SpeechSynthesisUtterance(s); + //创建新的朗读任务 + let msg = new SpeechSynthesisUtterance(word); reader.speak(msg); } +//关闭正在读的单词 function onReadClick(){ - isRead = !isRead; + let isRead = !isRead; if(!isRead){ reader.cancel(); } } +//取消当前选择 function onChooseClick(){ isChoose = !isChoose; } \ No newline at end of file -- 2.17.1 From 4dc2c9c591182b0a271b44fb36b8bedd5e4db951 Mon Sep 17 00:00:00 2001 From: Lawrence-Appiah Date: Tue, 25 Apr 2023 15:51:39 +0800 Subject: [PATCH 3/4] Stop reading when user clicks next and previous button as well as selecting new text --- app/static/js/fillword.js | 92 +++----- app/templates/userpage_get.html | 375 +++++++++++++++++++++----------- 2 files changed, 277 insertions(+), 190 deletions(-) diff --git a/app/static/js/fillword.js b/app/static/js/fillword.js index ba249dd..573bb12 100644 --- a/app/static/js/fillword.js +++ b/app/static/js/fillword.js @@ -1,68 +1,44 @@ -let isRead = true; -let isChoose = true; -let reader = window.speechSynthesis; // 全局定义朗读者,以便朗读和暂停 -let current_position = 0; // 朗读文本的当前位置 -let original_position = 0; // 朗读文本的初始位置 -let to_speak = ""; // 朗读的初始内容 - +var isRead = true; +var isChoose = true; +const reader = window.speechSynthesis; // 全局定义朗读者,以便朗读和暂停 +//获取字符 function getWord() { - return window.getSelection ? window.getSelection() : document.selection.createRange().text; + return window.getSelection + ? window.getSelection() + : document.selection.createRange().text; } - -function fillInWord() { - let word = getWord(); - if (isRead) read(word); - if (!isChoose) return; - const element = document.getElementById("selected-words"); - element.value = element.value + " " + word; +//填充字符 +function fillingWord() { + let word = getWord(); + if (isRead) read(word); + if (!isChoose) return; + let element = document.getElementById("selected-words"); + element.value = element.value + " " + word; } - -document.getElementById("text-content").addEventListener("click", fillInWord, false); - -function makeUtterance(str, rate) { - let msg = new SpeechSynthesisUtterance(str); - msg.rate = rate; - msg.lang = "en-US"; // TODO: add language options menu - msg.onboundary = ev => { - if (ev.name == "word") { - current_position = ev.charIndex; - } - } - return msg; +document + .getElementById("text-content") + .addEventListener("click", fillingWord, false); +//朗读单词 +//@word 要朗读的单词 +function read(word) { + //关闭当前正在读的单词 + reader.cancel(); + //创建新的朗读任务 + let msg = new SpeechSynthesisUtterance(word); + reader.speak(msg); } - -const sliderValue = document.getElementById("rangeValue"); // 显示值 -const inputSlider = document.getElementById("rangeComponent"); // 滑块元素 -inputSlider.oninput = () => { - let value = inputSlider.value; // 获取滑块的值 - sliderValue.textContent = value + '×'; - if (!reader.speaking) return; - reader.cancel(); - let msg = makeUtterance(to_speak.substring(original_position + current_position), value); - original_position = original_position + current_position; - current_position = 0; - reader.speak(msg); -}; - -function read(s) { - to_speak = s.toString(); - original_position = 0; - current_position = 0; - let msg = makeUtterance(to_speak, inputSlider.value); - reader.speak(msg); -} - +//关闭正在读的单词 function onReadClick() { - isRead = !isRead; - if (!isRead) { - reader.cancel(); - } + let isRead = !isRead; + if (!isRead) { + reader.cancel(); + } } - +//取消当前选择 function onChooseClick() { - isChoose = !isChoose; + isChoose = !isChoose; } function stopRead() { - reader.cancel(); -} \ No newline at end of file + reader.cancel(); +} diff --git a/app/templates/userpage_get.html b/app/templates/userpage_get.html index b5e16aa..f210745 100644 --- a/app/templates/userpage_get.html +++ b/app/templates/userpage_get.html @@ -1,154 +1,265 @@ - - - - + + + + - {{ yml['header'] | safe }} - {% if yml['css']['item'] %} - {% for css in yml['css']['item'] %} - - {% endfor %} - {% endif %} - {% if yml['js']['head'] %} - {% for js in yml['js']['head'] %} - - {% endfor %} - {% endif %} + {{ yml['header'] | safe }} {% if yml['css']['item'] %} {% for css in + yml['css']['item'] %} + + {% endfor %} {% endif %} {% if yml['js']['head'] %} {% for js in + yml['js']['head'] %} + + {% endfor %} {% endif %} EnglishPal Study Room for {{ username }} - - -
-

English Pal for {{ username }} - {% if username == admin_name %} - 管理 + + +

+

+ English Pal for + {{ username }} + {% if username == admin_name %} + 管理 {% endif %} - 退出 - 重设密码 -

-{# {% for message in flashed_messages %}#} {# 根据user_service.userpage,取消了参数flashed_messages,因此注释了这段代码 #} -{# #} -{# {% endfor %}#} + 退出 + 重设密码 +

+ {# {% for message in flashed_messages %}#} {# + 根据user_service.userpage,取消了参数flashed_messages,因此注释了这段代码 + #} {# + + #} {# {% endfor %}#} - 下一篇 Next Article - {% if session.get('existing_articles') != None and session.get('existing_articles')["index"] !=0 %} - 上一篇 Previous Article - {% endif %} + + 下一篇 Next Article + + {% if session.get('existing_articles') != None and + session.get('existing_articles')["index"] !=0 %} + + 上一篇 Previous Article + + {% endif %} -

阅读文章并回答问题

-
+

阅读文章并回答问题

+
{% if today_article %} - -

Article added on: {{ today_article["date"] }}


-

-

{{ today_article["article_title"] }}


-

{{ today_article["article_body"] }}


-

{{ today_article['source'] }}


-

{{ today_article['question'] }}


- - -
-
- {% else %} - - {% endif %} -
- - 生词高亮 - 大声朗读 - 划词入库 -
-
-
- -
- + -
-

收集生词吧 (可以在正文中划词,也可以复制黏贴)

-
-
- - -
- {% if session.get['thisWord'] %} - - {% endif %} - - {% if d_len > 0 %} -

- 我的生词簿 - -

- -
- {% for x in lst3 %} - {% set word = x[0] %} - {% set freq = x[1] %} - {% if session.get('thisWord') == x[0] and session.get('time') == 1 %} - {% endif %} -

- {{ word }} - ( {{ freq }} ) - 熟悉 - 不熟悉 - 删除 -

- {% endfor %} + + + +
- - {% endif %} -
-{{ yml['footer'] | safe }} -{% if yml['js']['bottom'] %} - {% for js in yml['js']['bottom'] %} - - {% endfor %} -{% endif %} - - - + -- 2.17.1 From 9d9590328d565d623fd7b28a7282449ade4d800d Mon Sep 17 00:00:00 2001 From: Lawrence-Appiah Date: Wed, 26 Apr 2023 18:54:50 +0800 Subject: [PATCH 4/4] Stop reading when user clicks the next or previous button and also selecting new text(s) --- app/static/js/fillword.js | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/app/static/js/fillword.js b/app/static/js/fillword.js index c646e1b..a74e193 100644 --- a/app/static/js/fillword.js +++ b/app/static/js/fillword.js @@ -2,7 +2,6 @@ var isRead = true; var isChoose = true; const reader = window.speechSynthesis; // 全局定义朗读者,以便朗读和暂停 //获取字符 -<<<<<<< HEAD function getWord() { return window.getSelection ? window.getSelection() @@ -39,41 +38,3 @@ function onReadClick() { function onChooseClick() { isChoose = !isChoose; } - -function stopRead() { - reader.cancel(); -} -======= -function getWord(){ - return window.getSelection?window.getSelection():document.selection.createRange().text; -} -//填充字符 -function fillingWord(){ - let word = getWord(); - if (isRead) read(word); - if (!isChoose) return; - let element = document.getElementById("selected-words"); - element.value = element.value + " " + word; -} -document.getElementById("text-content").addEventListener("click", fillingWord, false); -//朗读单词 -//@word 要朗读的单词 -function read(word){ - //关闭当前正在读的单词 - reader.cancel() - //创建新的朗读任务 - let msg = new SpeechSynthesisUtterance(word); - reader.speak(msg); -} -//关闭正在读的单词 -function onReadClick(){ - let isRead = !isRead; - if(!isRead){ - reader.cancel(); - } -} -//取消当前选择 -function onChooseClick(){ - isChoose = !isChoose; -} ->>>>>>> 72e23f4e13a8ee98628529dbfc2e21c339757015 -- 2.17.1