diff options
Diffstat (limited to 'popup.js')
-rw-r--r-- | popup.js | 32 |
1 files changed, 4 insertions, 28 deletions
@@ -895,18 +895,7 @@ function runThePopup() { clearTimes(); } else { - let errorMessage = ""; - - if([400, 429, 409, 502, 0].includes(response.statusCode)) { - //treat them the same - if (response.statusCode == 503) response.statusCode = 502; - - errorMessage = chrome.i18n.getMessage(response.statusCode + "") + " " + chrome.i18n.getMessage("errorCode") + response.statusCode; - } else { - errorMessage = chrome.i18n.getMessage("connectionError") + response.statusCode; - } - - document.getElementById("submitTimesInfoMessage").innerText = errorMessage; + document.getElementById("submitTimesInfoMessage").innerText = getErrorMessage(response.statusCode); document.getElementById("submitTimesInfoMessageContainer").style.display = "unset"; SB.submitTimesInfoMessageContainer.style.display = "unset"; @@ -1138,7 +1127,7 @@ function runThePopup() { SB.usernameInput.style.display = "none"; SB.setUsernameStatusContainer.style.display = "unset"; - SB.setUsernameStatus.innerText = "Couldn't connect to server. Error code: " + xmlhttp.status; + SB.setUsernameStatus.innerText = getErrorMessage(xmlhttp.status); } }); }); @@ -1160,15 +1149,7 @@ function runThePopup() { SB.setUsernameStatus.innerText = chrome.i18n.getMessage("success"); } else if (xmlhttp.readyState == 4) { - let errorMessage = ""; - - if([400, 429, 409, 502].includes(xmlhttp.status)) { - errorMessage = chrome.i18n.getMessage(xmlhttp.status); - } else { - errorMessage = chrome.i18n.getMessage("connectionError") + xmlhttp.status; - } - - SB.setUsernameStatus.innerText = errorMessage; + SB.setUsernameStatus.innerText = getErrorMessageI(xmlhttp.status); } }); }); @@ -1224,12 +1205,7 @@ function runThePopup() { //failure: duplicate vote addVoteMessage(chrome.i18n.getMessage("voteFail"), UUID) } else if (response.successType == -1) { - if (response.statusCode == 502) { - addVoteMessage(chrome.i18n.getMessage("serverDown"), UUID) - } else { - //failure: unknown error - addVoteMessage(chrome.i18n.getMessage("connectionError") + response.statusCode, UUID) - } + addVoteMessage(getErrorMessage(response.statusCode), UUID) } } }); |