notifier: add badge; bump version

This commit is contained in:
Andrew Dolgov 2010-02-17 15:53:38 +03:00
parent f0ea2da594
commit 01701654eb
4 changed files with 49 additions and 5 deletions

View File

@ -30,16 +30,30 @@ function update() {
var icon = new Object(); var icon = new Object();
var title = new Object(); var title = new Object();
var badge = new Object();
var showBadge = localStorage["show_badge"];
if (xhr.status == 200) { if (xhr.status == 200) {
var unread = parseInt(xhr.responseText); var unread = parseInt(xhr.responseText);
if (unread > 0) { if (unread > 0) {
icon.path = "images/alert.png";
icon.path = "images/alert.png";
title.title = "You have %s unread articles.".replace("%s", unread); 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 { } else {
icon.path = "images/normal.png"; icon.path = "images/normal.png";
title.title = "You have no unread articles."; title.title = "You have no unread articles.";
badge.text = "";
} }
localStorage["last_updated"] = d.getTime(); localStorage["last_updated"] = d.getTime();
@ -48,9 +62,13 @@ function update() {
localStorage["last_error"] = xhr.responseText; localStorage["last_error"] = xhr.responseText;
icon.path = "images/error.png"; 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.setTitle(title);
chrome.browserAction.setIcon(icon); chrome.browserAction.setIcon(icon);
@ -104,7 +122,7 @@ function init() {
chrome.tabs.create(cp); chrome.tabs.create(cp);
} }
}); });
window.setTimeout("timeout()", 1000); window.setTimeout("timeout()", 1000);

View File

@ -1,14 +1,14 @@
{ {
"name": "Tiny Tiny RSS Notifier", "name": "Tiny Tiny RSS Notifier",
"background_page": "background.html", "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", "description": "This extension displays the number of unread articles in your Tiny Tiny RSS installation",
"options_page": "options.html", "options_page": "options.html",
"icons": { "48": "images/icon.png", "128": "images/icon.png" }, "icons": { "48": "images/icon.png", "128": "images/icon.png" },
"browser_action": { "browser_action": {
"default_icon": "images/normal.png", "default_icon": "images/normal.png",
"default_title": "You have no unread articles.", "default_title": "You have no unread articles.",
"-popup": "popup.html" "popup.disabled": "popup.html"
}, },
"permissions": [ "permissions": [
"tabs", "http://*/*", "https://*/*" "tabs", "http://*/*", "https://*/*"

View File

@ -37,6 +37,8 @@ function save() {
new Effect.Highlight(f.update_interval); new Effect.Highlight(f.update_interval);
} }
localStorage['show_badge'] = (f.show_badge.checked) ? "1" : "0";
var d = new Date(); var d = new Date();
localStorage["prefs_updated"] = d.getTime(); localStorage["prefs_updated"] = d.getTime();
@ -64,6 +66,11 @@ function init() {
else else
f.update_interval.value = '15'; 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 last_updated = $('last_updated');
var d = new Date(); var d = new Date();
@ -128,6 +135,11 @@ p.last-updated {
<input name="update_interval" size="30" value=""/> <input name="update_interval" size="30" value=""/>
</fieldset> </fieldset>
<fieldset>
<label>Show badge:</label>
<input name="show_badge" type="checkbox" value="1"/>
</fieldset>
<input type="submit" value="Save"/> <input type="submit" value="Save"/>
</form> </form>

14
utils/notifier/popup.html Normal file
View File

@ -0,0 +1,14 @@
<html>
<style type="text/css">
ul {
padding : 0px;
margin : 0px;
}
</style>
<body>
<ul>
<li>Update</li>
</ul>
</body>
</html>