diff options
author | Andrew Dolgov <[email protected]> | 2010-02-19 23:33:15 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2010-02-19 23:33:15 +0300 |
commit | 36d146f8e234bf0b74f3d937fa4e1b47b9b58935 (patch) | |
tree | 0f8345902f4ca67e783ba5c01c49e538b544d2ef /utils/notifier/background.html | |
parent | 8182e64788287b2f413ab9edfdcf8b0bdb3c08ae (diff) |
notifier: fix icons; support single-user mode
Diffstat (limited to 'utils/notifier/background.html')
-rw-r--r-- | utils/notifier/background.html | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/utils/notifier/background.html b/utils/notifier/background.html index fdca37e90..bee00560b 100644 --- a/utils/notifier/background.html +++ b/utils/notifier/background.html @@ -14,6 +14,9 @@ function param_escape(arg) { function update() { var d = new Date(); var login = localStorage["login"]; + var single_user = localStorage["single_user"]; + + if (single_user == "1") login = "admin"; var requestUrl = localStorage["site_url"] + "/backend.php"; var params = "op=getUnread&fresh=1&login=" + param_escape(login); @@ -33,6 +36,12 @@ function update() { var badge = new Object(); var badge_color = new Object(); + // init stuff + icon.path = "images/normal.png"; + title.title = ""; + badge.text = ""; + badge_color.color = [0, 0, 0, 0]; + var show_badge = localStorage["show_badge"] == "1"; var show_fresh = localStorage["show_fresh"] == "1"; @@ -41,21 +50,24 @@ function update() { var unread = parseInt(response[0]); - var fresh; + if (isNaN(unread)) unread = 0; + var fresh; + if (response.length == 2) fresh = parseInt(response[1]); else fresh = 0; + if (isNaN(fresh)) fresh = 0; + if (unread > 0) { icon.path = "images/alert.png"; title.title = "You have %s unread articles.".replace("%s", unread); - if (show_fresh) { + if (show_fresh && fresh > 0) { badge.text = fresh + ""; badge_color.color = [0, 200, 0, 255]; - } else { badge.text = unread + ""; badge_color.color = [255, 0, 0, 255]; @@ -67,12 +79,9 @@ function update() { var errorMsg = xhr.responseText.split(";")[1]; title.title = "Error: %s.".replace("%s", errorMsg.trim()); - badge.text = ""; } else { - icon.path = "images/normal.png"; title.title = "You have no unread articles."; - badge.text = ""; } localStorage["last_updated"] = d.getTime(); |