1
0
Fork 0

Refactor: use better function name

Bug412-JiangLetian-Refactor
Lan Hui 2022-08-02 12:30:27 +08:00
parent 8cb34e56ba
commit 1d8671c5c7
1 changed files with 6 additions and 6 deletions

View File

@ -1,7 +1,7 @@
let isHighlight = true; let isHighlight = true;
function cancelBtnHandler() { function cancelBtnHandler() {
cancel_highLight(); cancelHighlighting();
document.getElementById("text-content").removeEventListener("click", fillInWord, false); document.getElementById("text-content").removeEventListener("click", fillInWord, false);
document.getElementById("text-content").removeEventListener("touchstart", fillInWord, false); document.getElementById("text-content").removeEventListener("touchstart", fillInWord, false);
document.getElementById("text-content").addEventListener("click", fillInWord2, false); document.getElementById("text-content").addEventListener("click", fillInWord2, false);
@ -37,11 +37,11 @@ function highLight() {
document.getElementById("article").innerHTML = articleContent; document.getElementById("article").innerHTML = articleContent;
} }
function cancel_highLight() { function cancelHighlighting() {
const list = pickedWords.value.split(" ");
let articleContent = document.getElementById("article").innerText; let articleContent = document.getElementById("article").innerText;
let pickedWords = document.getElementById("selected-words"); let pickedWords = document.getElementById("selected-words");
const dictionaryWords = document.getElementById("selected-words2"); const dictionaryWords = document.getElementById("selected-words2");
const list = pickedWords.value.split(" ");
if (pickedWords != null) { if (pickedWords != null) {
for (let i = 0; i < list.length; ++i) { for (let i = 0; i < list.length; ++i) {
list[i] = list[i].replace(/(^\s*)|(\s*$)/g, ""); list[i] = list[i].replace(/(^\s*)|(\s*$)/g, "");
@ -68,13 +68,13 @@ function fillInWord() {
} }
function fillInWord2() { function fillInWord2() {
cancel_highLight(); cancelHighlighting();
} }
function ChangeHighlight() { function ChangeHighlight() {
if (isHighlight) { if (isHighlight) {
isHighlight = false; isHighlight = false;
cancel_highLight(); cancelHighlighting();
} else { } else {
isHighlight = true; isHighlight = true;
highLight(); highLight();