forked from mrlan/EnglishPal
Use better variable names
parent
9927515b11
commit
1dfe370983
|
@ -23,10 +23,10 @@ function getWord() {
|
||||||
function highLight() {
|
function highLight() {
|
||||||
if (!isHighlight) return;
|
if (!isHighlight) return;
|
||||||
let txt = document.getElementById("article").innerText;
|
let txt = document.getElementById("article").innerText;
|
||||||
let sel_word1 = document.getElementById("selected-words");
|
let picked_words = document.getElementById("selected-words");
|
||||||
let sel_word2 = document.getElementById("selected-words2");
|
let dictionary_words = document.getElementById("selected-words2");
|
||||||
if (sel_word1 != null) {
|
if (picked_words != null) {
|
||||||
const list = sel_word1.value.split(" ");
|
const list = picked_words.value.split(" ");
|
||||||
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, ""); //消除字符串两边空字符
|
||||||
if (list[i] !== "" && "<mark>".indexOf(list[i]) === -1 && "</mark>".indexOf(list[i]) === -1) {
|
if (list[i] !== "" && "<mark>".indexOf(list[i]) === -1 && "</mark>".indexOf(list[i]) === -1) {
|
||||||
|
@ -35,8 +35,8 @@ function highLight() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sel_word2 != null) {
|
if (dictionary_words != null) {
|
||||||
const list2 = sel_word2.value.split(" ");
|
const list2 = dictionary_words.value.split(" ");
|
||||||
for (let i = 0; i < list2.length; ++i) {
|
for (let i = 0; i < list2.length; ++i) {
|
||||||
list2[i] = list2[i].replace(/(^\s*)|(\s*$)/g, "");
|
list2[i] = list2[i].replace(/(^\s*)|(\s*$)/g, "");
|
||||||
if (list2[i] !== "" && "<mark>".indexOf(list2[i]) === -1 && "</mark>".indexOf(list2[i]) === -1) {
|
if (list2[i] !== "" && "<mark>".indexOf(list2[i]) === -1 && "</mark>".indexOf(list2[i]) === -1) {
|
||||||
|
@ -49,11 +49,11 @@ function highLight() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancel_highLight() {
|
function cancel_highLight() {
|
||||||
const list = sel_word1.value.split(" ");
|
const list = picked_words.value.split(" ");
|
||||||
let txt = document.getElementById("article").innerText;
|
let txt = document.getElementById("article").innerText;
|
||||||
let sel_word1 = document.getElementById("selected-words");
|
let picked_words = document.getElementById("selected-words");
|
||||||
const sel_word2 = document.getElementById("selected-words2");
|
const dictionary_words = document.getElementById("selected-words2");
|
||||||
if (sel_word1 != null) {
|
if (picked_words != 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, "");
|
||||||
if (list[i] !== "") {
|
if (list[i] !== "") {
|
||||||
|
@ -61,10 +61,10 @@ function cancel_highLight() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sel_word2 != null) {
|
if (dictionary_words != null) {
|
||||||
let list2 = sel_word1.value.split(" ");
|
let list2 = picked_words.value.split(" ");
|
||||||
for (let i = 0; i < list2.length; ++i) {
|
for (let i = 0; i < list2.length; ++i) {
|
||||||
list2 = sel_word2.value.split(" ");
|
list2 = dictionary_words.value.split(" ");
|
||||||
list2[i] = list2[i].replace(/(^\s*)|(\s*$)/g, "");
|
list2[i] = list2[i].replace(/(^\s*)|(\s*$)/g, "");
|
||||||
if (list2[i] !== "") {
|
if (list2[i] !== "") {
|
||||||
txt = txt.replace("<mark>" + list[i] + "</mark>", "list[i]");
|
txt = txt.replace("<mark>" + list[i] + "</mark>", "list[i]");
|
||||||
|
|
Loading…
Reference in New Issue