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] =?UTF-8?q?=E5=AF=B9fillword.js=E8=BF=9B=E8=A1=8C=E4=BA=86?=
 =?UTF-8?q?=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