diff options
author | Ajay Ramachandran <[email protected]> | 2019-12-13 23:37:11 -0500 |
---|---|---|
committer | GitHub <[email protected]> | 2019-12-13 23:37:11 -0500 |
commit | b30acaac78d23d66e64c74c328c096693bdd224b (patch) | |
tree | 362c26b5056da0dd54cf64341b705e58d14f6171 /popup.js | |
parent | 3d01ffee1b9b02097870aad8c3cd2226607c2ef2 (diff) | |
parent | 46ac6542243ab19de9495e774f07f195476a8eea (diff) | |
download | SponsorBlock-b30acaac78d23d66e64c74c328c096693bdd224b.tar.gz SponsorBlock-b30acaac78d23d66e64c74c328c096693bdd224b.zip |
Merge pull request #195 from ajayyy/experimental-ajay11.9.9
Small Fixes
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) } } }); |