2022-07-18 16:00:08 +08:00
|
|
|
|
let isRead = true;
|
|
|
|
|
let isChoose = true;
|
2022-01-26 21:10:09 +08:00
|
|
|
|
|
2022-07-18 16:00:08 +08:00
|
|
|
|
function getWord() {
|
|
|
|
|
return window.getSelection ? window.getSelection() : document.selection.createRange().text;
|
2022-01-26 21:10:09 +08:00
|
|
|
|
}
|
2022-07-18 16:00:08 +08:00
|
|
|
|
|
|
|
|
|
function fillInWord() {
|
|
|
|
|
let word = getWord();
|
2023-05-25 17:35:31 +08:00
|
|
|
|
if (isRead) Reader.read(word, inputSlider.value);
|
2022-07-18 16:00:08 +08:00
|
|
|
|
if (!isChoose) return;
|
2024-04-11 19:09:26 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
2022-07-18 16:00:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
document.getElementById("text-content").addEventListener("click", fillInWord, false);
|
|
|
|
|
|
2023-05-25 17:35:31 +08:00
|
|
|
|
const sliderValue = document.getElementById("rangeValue");
|
|
|
|
|
const inputSlider = document.getElementById("rangeComponent");
|
2022-07-18 16:00:08 +08:00
|
|
|
|
inputSlider.oninput = () => {
|
2023-05-25 17:35:31 +08:00
|
|
|
|
let value = inputSlider.value;
|
2022-07-18 16:00:08 +08:00
|
|
|
|
sliderValue.textContent = value + '×';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function onReadClick() {
|
2022-01-26 21:10:09 +08:00
|
|
|
|
isRead = !isRead;
|
|
|
|
|
}
|
2022-07-18 16:00:08 +08:00
|
|
|
|
|
|
|
|
|
function onChooseClick() {
|
2022-01-26 21:10:09 +08:00
|
|
|
|
isChoose = !isChoose;
|
2022-07-18 16:00:08 +08:00
|
|
|
|
}
|