diff --git a/fancy-settings/manifest.js b/fancy-settings/manifest.js index 7bf51fd..488ede8 100755 --- a/fancy-settings/manifest.js +++ b/fancy-settings/manifest.js @@ -32,14 +32,16 @@ this.manifest = { "name": "timeoutLength", "type": "slider", "label": "", - "max": 15, + "max": 16, "min": 1, "step": 1, "display": true, "displayModifier": function(value) { if(value === 1) return value.toString() + " second"; - return value.toString() + " seconds"; + if(value <= 15) + return value.toString() + " seconds"; + return "Do not timeout; Only error when the API is down." } }, { diff --git a/js/common.js b/js/common.js index a59df77..4ef4026 100644 --- a/js/common.js +++ b/js/common.js @@ -183,7 +183,7 @@ BrowserAction.prototype.setBadgeLoading = function (tabId) { BrowserAction.prototype.setBadgeError = function (tabId, text) { chrome.browserAction.setBadgeText({'text': '×', 'tabId': tabId}); chrome.browserAction.setTitle({'title': text, 'tabId': tabId}); - chrome.browserAction.setBadgeBackgroundColor({'color': [255, 0, 255, 255], 'tabId': tabId}); + chrome.browserAction.setBadgeBackgroundColor({'color': [200, 0, 0, 255], 'tabId': tabId}); chrome.browserAction.setPopup({popup: '', tabId: tabId}); chrome.browserAction.onClicked.addListener(function(tab) { reddit.getInfo(tab.url, tab.id); @@ -316,14 +316,14 @@ RedditAPI.prototype.getInfo = function (url, tabId) { button.setBadgeFor(url, tabId); return true; } else { - throw 'Error loading info from the API. HTTP Status: ' + req.status; + button.setBadgeError(tabId, 'API Error. HTTP Status: ' + req.status + '. Click to try again.'); } } } function handleTimeout () { req.abort(); - button.setBadgeError(tabId, 'The Reddit API Timed Out. Click to try loading again.'); + button.setBadgeError(tabId, 'API Timeout after ' + settings.get('timeoutLength') + '. Click to try again.'); } button.setBadgeLoading(tabId); @@ -342,7 +342,9 @@ RedditAPI.prototype.getInfo = function (url, tabId) { req.open('GET', reqUrl, true); req.onreadystatechange = processInfo; req.send(null); - apiTimeout = setTimeout(handleTimeout, settings.get('timeoutLength') * 1000); + if (settings.get('timeoutLength') !== 16) { + apiTimeout = setTimeout(handleTimeout, settings.get('timeoutLength') * 1000); + } }; /**