From c4535c0b0ce2bc063fd4a16458c0edef242fd8d5 Mon Sep 17 00:00:00 2001 From: Kerrick Long Date: Thu, 21 Jul 2011 18:33:50 -0500 Subject: [PATCH] Added notification area --- js/common.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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);