notifier: fix icons; support single-user mode
This commit is contained in:
parent
8182e64788
commit
36d146f8e2
|
@ -14,6 +14,9 @@ function param_escape(arg) {
|
||||||
function update() {
|
function update() {
|
||||||
var d = new Date();
|
var d = new Date();
|
||||||
var login = localStorage["login"];
|
var login = localStorage["login"];
|
||||||
|
var single_user = localStorage["single_user"];
|
||||||
|
|
||||||
|
if (single_user == "1") login = "admin";
|
||||||
|
|
||||||
var requestUrl = localStorage["site_url"] + "/backend.php";
|
var requestUrl = localStorage["site_url"] + "/backend.php";
|
||||||
var params = "op=getUnread&fresh=1&login=" + param_escape(login);
|
var params = "op=getUnread&fresh=1&login=" + param_escape(login);
|
||||||
|
@ -33,6 +36,12 @@ function update() {
|
||||||
var badge = new Object();
|
var badge = new Object();
|
||||||
var badge_color = 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_badge = localStorage["show_badge"] == "1";
|
||||||
var show_fresh = localStorage["show_fresh"] == "1";
|
var show_fresh = localStorage["show_fresh"] == "1";
|
||||||
|
|
||||||
|
@ -41,6 +50,8 @@ function update() {
|
||||||
|
|
||||||
var unread = parseInt(response[0]);
|
var unread = parseInt(response[0]);
|
||||||
|
|
||||||
|
if (isNaN(unread)) unread = 0;
|
||||||
|
|
||||||
var fresh;
|
var fresh;
|
||||||
|
|
||||||
if (response.length == 2)
|
if (response.length == 2)
|
||||||
|
@ -48,14 +59,15 @@ function update() {
|
||||||
else
|
else
|
||||||
fresh = 0;
|
fresh = 0;
|
||||||
|
|
||||||
|
if (isNaN(fresh)) fresh = 0;
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
if (show_fresh) {
|
if (show_fresh && fresh > 0) {
|
||||||
badge.text = fresh + "";
|
badge.text = fresh + "";
|
||||||
badge_color.color = [0, 200, 0, 255];
|
badge_color.color = [0, 200, 0, 255];
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
badge.text = unread + "";
|
badge.text = unread + "";
|
||||||
badge_color.color = [255, 0, 0, 255];
|
badge_color.color = [255, 0, 0, 255];
|
||||||
|
@ -67,12 +79,9 @@ function update() {
|
||||||
var errorMsg = xhr.responseText.split(";")[1];
|
var errorMsg = xhr.responseText.split(";")[1];
|
||||||
|
|
||||||
title.title = "Error: %s.".replace("%s", errorMsg.trim());
|
title.title = "Error: %s.".replace("%s", errorMsg.trim());
|
||||||
badge.text = "";
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
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();
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 477 B After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
Before Width: | Height: | Size: 263 B |
Binary file not shown.
Before Width: | Height: | Size: 496 B After Width: | Height: | Size: 1.1 KiB |
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "Tiny Tiny RSS Notifier",
|
"name": "Tiny Tiny RSS Notifier",
|
||||||
"background_page": "background.html",
|
"background_page": "background.html",
|
||||||
"version": "0.3",
|
"version": "0.4",
|
||||||
"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" },
|
||||||
|
|
|
@ -39,6 +39,7 @@ function save() {
|
||||||
|
|
||||||
localStorage['show_badge'] = (f.show_badge.checked) ? "1" : "0";
|
localStorage['show_badge'] = (f.show_badge.checked) ? "1" : "0";
|
||||||
localStorage['show_fresh'] = (f.show_fresh.checked) ? "1" : "0";
|
localStorage['show_fresh'] = (f.show_fresh.checked) ? "1" : "0";
|
||||||
|
localStorage['single_user'] = (f.single_user.checked) ? "1" : "0";
|
||||||
|
|
||||||
var d = new Date();
|
var d = new Date();
|
||||||
|
|
||||||
|
@ -49,6 +50,12 @@ function save() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function single_user_toggle() {
|
||||||
|
var f = document.forms['options'];
|
||||||
|
|
||||||
|
f.login.disabled = f.single_user.checked;
|
||||||
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
var f = document.forms['options'];
|
var f = document.forms['options'];
|
||||||
|
|
||||||
|
@ -77,6 +84,13 @@ function init() {
|
||||||
else
|
else
|
||||||
f.show_fresh.checked = false;
|
f.show_fresh.checked = false;
|
||||||
|
|
||||||
|
if (localStorage['single_user'])
|
||||||
|
f.single_user.checked = localStorage['single_user'] == "1";
|
||||||
|
else
|
||||||
|
f.single_user.checked = false;
|
||||||
|
|
||||||
|
single_user_toggle();
|
||||||
|
|
||||||
var last_updated = $('last_updated');
|
var last_updated = $('last_updated');
|
||||||
|
|
||||||
var d = new Date();
|
var d = new Date();
|
||||||
|
@ -141,6 +155,12 @@ fieldset span.note {
|
||||||
<input name="login" size="30" value=""/>
|
<input name="login" size="30" value=""/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<label>Single-user mode:</label>
|
||||||
|
<input name="single_user" onchange="single_user_toggle()"
|
||||||
|
type="checkbox" value="1"/>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label>Update interval (in minutes):</label>
|
<label>Update interval (in minutes):</label>
|
||||||
<input name="update_interval" size="30" value=""/>
|
<input name="update_interval" size="30" value=""/>
|
||||||
|
|
Loading…
Reference in New Issue