Display error message on translation panel
This commit is contained in:
parent
911a483896
commit
ab8bf6205c
|
@ -113,18 +113,20 @@ button.addEventListener(
|
||||||
);
|
);
|
||||||
|
|
||||||
async function translate(sourceWord, sourceLang, targetLang) {
|
async function translate(sourceWord, sourceLang, targetLang) {
|
||||||
const resultData = await T.translate(sourceWord, sourceLang, targetLang);
|
const result = await T.translate(sourceWord, sourceLang, targetLang);
|
||||||
showResult(resultData.resultText, resultData.candidateText);
|
showResult(result);
|
||||||
panelPosition(clickPosition);
|
panelPosition(clickPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showResult(resultText, candidateText) {
|
function showResult(result) {
|
||||||
panel.innerHTML = "<p class=result></p><p class=candidate>";
|
panel.innerHTML = "<p class=result></p><p class=candidate>";
|
||||||
const resultArea = panel.getElementsByClassName("result")[0];
|
const resultArea = panel.getElementsByClassName("result")[0];
|
||||||
const candidateArea = panel.getElementsByClassName("candidate")[0];
|
const candidateArea = panel.getElementsByClassName("candidate")[0];
|
||||||
|
|
||||||
resultArea.innerText = resultText;
|
resultArea.innerText = result.resultText;
|
||||||
if (S.get().ifShowCandidate) candidateArea.innerText = candidateText;
|
if (S.get().ifShowCandidate) candidateArea.innerText = result.candidateText;
|
||||||
|
if (result.statusText == "Service Unavailable")
|
||||||
|
candidateArea.innerText = browser.i18n.getMessage("unavailableError");
|
||||||
}
|
}
|
||||||
|
|
||||||
//パネル表示
|
//パネル表示
|
||||||
|
|
Loading…
Reference in a new issue