From 1d8671c5c78768c29dab349670cbcbbb88f5fda5 Mon Sep 17 00:00:00 2001 From: Lan Hui <1348141770@qq.com> Date: Tue, 2 Aug 2022 12:30:27 +0800 Subject: [PATCH] Refactor: use better function name --- app/static/js/highlight.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/static/js/highlight.js b/app/static/js/highlight.js index 8a48cd9..625fdc0 100644 --- a/app/static/js/highlight.js +++ b/app/static/js/highlight.js @@ -1,7 +1,7 @@ let isHighlight = true; function cancelBtnHandler() { - cancel_highLight(); + cancelHighlighting(); document.getElementById("text-content").removeEventListener("click", fillInWord, false); document.getElementById("text-content").removeEventListener("touchstart", fillInWord, false); document.getElementById("text-content").addEventListener("click", fillInWord2, false); @@ -37,11 +37,11 @@ function highLight() { document.getElementById("article").innerHTML = articleContent; } -function cancel_highLight() { - const list = pickedWords.value.split(" "); +function cancelHighlighting() { let articleContent = document.getElementById("article").innerText; 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) { for (let i = 0; i < list.length; ++i) { list[i] = list[i].replace(/(^\s*)|(\s*$)/g, ""); @@ -68,13 +68,13 @@ function fillInWord() { } function fillInWord2() { - cancel_highLight(); + cancelHighlighting(); } function ChangeHighlight() { if (isHighlight) { isHighlight = false; - cancel_highLight(); + cancelHighlighting(); } else { isHighlight = true; highLight();