From 01701654eb01257ef96882ed5840a29355a353be Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 17 Feb 2010 15:53:38 +0300 Subject: notifier: add badge; bump version --- utils/notifier/background.html | 24 +++++++++++++++++++++--- utils/notifier/manifest.json | 4 ++-- utils/notifier/options.html | 12 ++++++++++++ utils/notifier/popup.html | 14 ++++++++++++++ 4 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 utils/notifier/popup.html (limited to 'utils/notifier') diff --git a/utils/notifier/background.html b/utils/notifier/background.html index a26e9fc47..8a3acb2be 100644 --- a/utils/notifier/background.html +++ b/utils/notifier/background.html @@ -30,16 +30,30 @@ function update() { var icon = new Object(); var title = new Object(); + var badge = new Object(); + + var showBadge = localStorage["show_badge"]; if (xhr.status == 200) { var unread = parseInt(xhr.responseText); if (unread > 0) { - icon.path = "images/alert.png"; + + icon.path = "images/alert.png"; title.title = "You have %s unread articles.".replace("%s", unread); + badge.text = unread + ""; + } else if (unread == -1) { + icon.path = "images/error.png"; + + 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(); @@ -48,9 +62,13 @@ function update() { localStorage["last_error"] = xhr.responseText; icon.path = "images/error.png"; - title.title = "Error (%s) while requesting article information.".replace("%s", xhr.status); + title.title = "Error (%s) while updating.".replace("%s", xhr.status); } + if (showBadge !== "1") badge.text = ""; + + chrome.browserAction.setBadgeText(badge); + chrome.browserAction.setTitle(title); chrome.browserAction.setIcon(icon); @@ -104,7 +122,7 @@ function init() { chrome.tabs.create(cp); } - }); + }); window.setTimeout("timeout()", 1000); diff --git a/utils/notifier/manifest.json b/utils/notifier/manifest.json index 59630f922..f0f00953a 100644 --- a/utils/notifier/manifest.json +++ b/utils/notifier/manifest.json @@ -1,14 +1,14 @@ { "name": "Tiny Tiny RSS Notifier", "background_page": "background.html", - "version": "0.1", + "version": "0.2", "description": "This extension displays the number of unread articles in your Tiny Tiny RSS installation", "options_page": "options.html", "icons": { "48": "images/icon.png", "128": "images/icon.png" }, "browser_action": { "default_icon": "images/normal.png", "default_title": "You have no unread articles.", - "-popup": "popup.html" + "popup.disabled": "popup.html" }, "permissions": [ "tabs", "http://*/*", "https://*/*" diff --git a/utils/notifier/options.html b/utils/notifier/options.html index 99ae0787d..d7becf222 100644 --- a/utils/notifier/options.html +++ b/utils/notifier/options.html @@ -37,6 +37,8 @@ function save() { new Effect.Highlight(f.update_interval); } + localStorage['show_badge'] = (f.show_badge.checked) ? "1" : "0"; + var d = new Date(); localStorage["prefs_updated"] = d.getTime(); @@ -64,6 +66,11 @@ function init() { else f.update_interval.value = '15'; + if (localStorage['show_badge']) + f.show_badge.checked = localStorage['show_badge'] == "1"; + else + f.show_badge.checked = true; + var last_updated = $('last_updated'); var d = new Date(); @@ -128,6 +135,11 @@ p.last-updated { +
+ + +
+ diff --git a/utils/notifier/popup.html b/utils/notifier/popup.html new file mode 100644 index 000000000..de75dfbee --- /dev/null +++ b/utils/notifier/popup.html @@ -0,0 +1,14 @@ + + + + + + -- cgit v1.2.3