Add waiting time option
This commit is contained in:
parent
d3bcce91b6
commit
bb6bf77df7
|
@ -86,6 +86,16 @@
|
||||||
"secondTargetLangCaptionLabel": {
|
"secondTargetLangCaptionLabel": {
|
||||||
"message": "Select the second target language."
|
"message": "Select the second target language."
|
||||||
},
|
},
|
||||||
|
"waitTimeLabel": {
|
||||||
|
"message": "Waiting time to translate"
|
||||||
|
},
|
||||||
|
"waitTimeCaptionLabel": {
|
||||||
|
"message":
|
||||||
|
"Specify the waiting time from the input of a character to the start of translation. (millisecond)"
|
||||||
|
},
|
||||||
|
"waitTime2CaptionLabel": {
|
||||||
|
"message": "If you translate it many times in a short time, it may become unusable for a while."
|
||||||
|
},
|
||||||
|
|
||||||
"menuLabel": {
|
"menuLabel": {
|
||||||
"message": "Context menu"
|
"message": "Context menu"
|
||||||
|
|
|
@ -170,6 +170,22 @@
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<li class="optionContainer new">
|
||||||
|
<div class=optionText>
|
||||||
|
<p class=waitTimeLabel>翻訳までの待ち時間</p>
|
||||||
|
<p class="caption waitTimeCaptionLabel">文字が入力されてから翻訳を開始するまでの待ち時間を指定します。(ミリ秒)</p>
|
||||||
|
<p class="caption waitTime2CaptionLabel">短時間に何回も翻訳すると,しばらくの間利用できなくなることがあります。</p>
|
||||||
|
</div>
|
||||||
|
<div class=optionForm>
|
||||||
|
<label>
|
||||||
|
<input id=waitTime class=saveByChange type=number value=500 min=0 placeholder=500>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,8 @@ textarea.addEventListener("paste", resize);
|
||||||
textarea.addEventListener("keydown", resize);
|
textarea.addEventListener("keydown", resize);
|
||||||
|
|
||||||
textarea.addEventListener("keyup", function(event) {
|
textarea.addEventListener("keyup", function(event) {
|
||||||
//if (event.keyCode == 13) resize();
|
if (sourceWord == textarea.value) return;
|
||||||
|
|
||||||
resize();
|
resize();
|
||||||
inputText();
|
inputText();
|
||||||
});
|
});
|
||||||
|
@ -145,9 +146,23 @@ function textAreaClick() {
|
||||||
textarea.select();
|
textarea.select();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let inputTimer;
|
||||||
//文字入力時の処理
|
//文字入力時の処理
|
||||||
async function inputText() {
|
function inputText() {
|
||||||
sourceWord = textarea.value;
|
sourceWord = textarea.value;
|
||||||
|
const waitTime = S.get().waitTime;
|
||||||
|
|
||||||
|
clearTimeout(inputTimer);
|
||||||
|
inputTimer = setTimeout(() => {
|
||||||
|
runTranslation();
|
||||||
|
}, waitTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function runTranslation() {
|
||||||
|
if (sourceWord == "") {
|
||||||
|
showResult("", "");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const resultData = await T.translate(sourceWord, "auto", langList.value);
|
const resultData = await T.translate(sourceWord, "auto", langList.value);
|
||||||
changeSecondLang(defaultTargetLang, resultData.sourceLanguage, resultData.percentage);
|
changeSecondLang(defaultTargetLang, resultData.sourceLanguage, resultData.percentage);
|
||||||
|
|
Loading…
Reference in a new issue