diff --git a/js/common.js b/js/common.js index 0a6a93d..2746869 100644 --- a/js/common.js +++ b/js/common.js @@ -334,7 +334,7 @@ function RedditAPI(domain) { * @method */ RedditAPI.prototype.apiTransmit = function (type, url, data, cback) { - var req, apiTimeout; + var req, apiTimeout, notificationArea; function processResponse () { if (req.readyState === 4) { @@ -348,8 +348,12 @@ RedditAPI.prototype.apiTransmit = function (type, url, data, cback) { if (cback) { cback(JSON.parse(req.responseText)); } + + notificationArea.innerHTML = ''; + notificationArea.style.display = 'none'; return JSON.parse(req.responseText); } else { + notificationArea.innerHTML = '' + chrome.i18n.getMessage('api_error', req.status.toString()) + '' throw chrome.i18n.getMessage('api_error', req.status.toString()); } } @@ -360,9 +364,14 @@ RedditAPI.prototype.apiTransmit = function (type, url, data, cback) { throw chrome.i18n.getMessage('api_timeout', settings.get('timeoutLength').toString()); } + notificationArea = document.getElementById('notificationArea'); req = new XMLHttpRequest(); req.open(type, url, true); req.onreadystatechange = processResponse; + if (notificationArea) { + notificationArea.style.display = 'block'; + notificationArea.innerHTML = '' + chrome.i18n.getMessage('loading') + ''; + } req.send(data); if (settings.get('timeoutLength') !== 31) { apiTimeout = setTimeout(handleTimeout, settings.get('timeoutLength') * 1000);