From 320a99d4793e03c40cd9f4d8267264ab67bb5ede Mon Sep 17 00:00:00 2001 From: Hui Lan Date: Mon, 24 Apr 2023 11:38:16 +0800 Subject: [PATCH] Move Tan Yanmei's fillword.js to app/static/js/tanyanmei-fillword.js. Delete the strange folder static js. --- app/static/js/tanyanmei-fillword.js | 33 +++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 app/static/js/tanyanmei-fillword.js diff --git a/app/static/js/tanyanmei-fillword.js b/app/static/js/tanyanmei-fillword.js new file mode 100644 index 0000000..49a8bc2 --- /dev/null +++ b/app/static/js/tanyanmei-fillword.js @@ -0,0 +1,33 @@ +isRead = true; +isChoose = true; +var reader = window.speechSynthesis; // 全局定义朗读者,以便朗读和暂停 +reader.cancel();// 初始化时清空reader列表 +function getWord(){ + var word = window.getSelection?window.getSelection():document.selection.createRange().text; + return word; +} +function fillinWord(){ + var word = getWord(); + if (isRead) read(word); + if (!isChoose) return; + var element = document.getElementById("selected-words"); + element.value = element.value + " " + word; +} +document.getElementById("text-content").addEventListener("click", fillinWord, false); +function read(s){ + var msg = new SpeechSynthesisUtterance(s); + reader.speak(msg); + console.log("+++++++++++++"); +} + +function onReadClick(){ + isRead = !isRead; + if(!isRead){ + reader.cancel(); + } +} +function onChooseClick(){ + isChoose = !isChoose; +} + +∑∑