From 41e061cd2eb1ab4c8e3436e4c09b536286383cb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=85=A7=E7=8E=B2?= <1994836463@qq.com> Date: Thu, 11 Apr 2024 18:27:16 +0800 Subject: [PATCH] revert 48f440c1b5d395870a3d47e9e535398d7c28dd11 Bug545-huanghuiling --- app/static/js/fillword.js | 8 ++------ app/static/js/highlight.js | 16 ---------------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/app/static/js/fillword.js b/app/static/js/fillword.js index bd5d5a2..b967633 100644 --- a/app/static/js/fillword.js +++ b/app/static/js/fillword.js @@ -9,12 +9,8 @@ function fillInWord() { let word = getWord(); if (isRead) Reader.read(word, inputSlider.value); if (!isChoose) return; - let element = document.getElementById("selected-words"); - let index = (String)(element.value).indexOf(word); - localStorage.setItem("nowWord",element.value); - if(index === -1){ - element.value = element.value + " " + word; - } + const element = document.getElementById("selected-words"); + element.value = element.value + " " + word; } document.getElementById("text-content").addEventListener("click", fillInWord, false); diff --git a/app/static/js/highlight.js b/app/static/js/highlight.js index d7d72c2..0cea31a 100644 --- a/app/static/js/highlight.js +++ b/app/static/js/highlight.js @@ -33,22 +33,6 @@ function highLight() { allWords = pickedWords.value + " "; } const list = allWords.split(" ");//将所有的生词放入一个list中,用于后续处理 - //判断获取的单词不能为空 - if(word !== null && word !== "" && word !== " "){ - let articleContent_fb2 = articleContent; - if(localStorage.getItem("nowWord").indexOf(word) !== -1){ - while(articleContent_fb2.toLowerCase().indexOf(word.toLowerCase()) !== -1){ - // 找到副本中和list[i]匹配的第一个单词(第一种匹配情况),并赋值给list[i]。 - const index = articleContent_fb2.toLowerCase().indexOf(word.toLowerCase()); - word = articleContent_fb2.substring(index, index + word.length); - articleContent_fb2 = articleContent_fb2.substring(index + word.length); // 使用副本中list[i]之后的子串替换掉副本 - articleContent = articleContent.replace(new RegExp(""+word+"", "g"), word) - } - pickedWords.value = localStorage.getItem("nowWord").replace(word,""); - document.getElementById("article").innerHTML = articleContent; - return; - } - } for (let i = 0; i < list.length; ++i) { list[i] = list[i].replace(/(^\s*)|(\s*$)/g, ""); //消除单词两边的空字符 list[i] = list[i].replace('|', "");