From 13b39cf85cd934468e37f45fde5d0b19324ce25e Mon Sep 17 00:00:00 2001 From: Lan Hui <1348141770@qq.com> Date: Mon, 18 Jul 2022 15:57:23 +0800 Subject: [PATCH] Use better variable names. --- app/static/js/fillword.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/static/js/fillword.js b/app/static/js/fillword.js index 6fd7aad..505808e 100644 --- a/app/static/js/fillword.js +++ b/app/static/js/fillword.js @@ -1,8 +1,8 @@ let isRead = true; let isChoose = true; let reader = window.speechSynthesis; // 全局定义朗读者,以便朗读和暂停 -let cur_position = 0; // 朗读文本的当前位置 -let orig_position = 0; // 朗读文本的初始位置 +let current_position = 0; // 朗读文本的当前位置 +let original_position = 0; // 朗读文本的初始位置 let to_speak = ""; // 朗读的初始内容 function getWord() { @@ -25,7 +25,7 @@ function makeUtterance(str, rate) { msg.lang = "en-US"; // TODO: add language options menu msg.onboundary = ev => { if (ev.name == "word") { - cur_position = ev.charIndex; + current_position = ev.charIndex; } } return msg; @@ -38,16 +38,16 @@ inputSlider.oninput = () => { sliderValue.textContent = value + '×'; if (!reader.speaking) return; reader.cancel(); - let msg = makeUtterance(to_speak.substring(orig_position + cur_position), value); - orig_position = orig_position + cur_position; - cur_position = 0; + let msg = makeUtterance(to_speak.substring(original_position + current_position), value); + original_position = original_position + current_position; + current_position = 0; reader.speak(msg); }; function read(s) { to_speak = s.toString(); - orig_position = 0; - cur_position = 0; + original_position = 0; + current_position = 0; let msg = makeUtterance(to_speak, inputSlider.value); reader.speak(msg); } @@ -61,4 +61,4 @@ function onReadClick() { function onChooseClick() { isChoose = !isChoose; -} \ No newline at end of file +}