notifier: add ability to update feeds in tt-rss
This commit is contained in:
parent
aa60999b97
commit
a689cd4770
|
@ -2,6 +2,7 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
var last_updated = 0;
|
var last_updated = 0;
|
||||||
|
var feeds_last_updated = 0;
|
||||||
var prefs_last_updated = 0;
|
var prefs_last_updated = 0;
|
||||||
|
|
||||||
function param_escape(arg) {
|
function param_escape(arg) {
|
||||||
|
@ -11,7 +12,24 @@ function param_escape(arg) {
|
||||||
return escape(arg);
|
return escape(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function update_feeds() {
|
||||||
|
|
||||||
|
console.log("feeds update");
|
||||||
|
|
||||||
|
var requestUrl = localStorage["site_url"] + "/public.php?op=globalUpdateFeeds";
|
||||||
|
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
|
||||||
|
xhr.open("POST", requestUrl, true);
|
||||||
|
xhr.send();
|
||||||
|
|
||||||
|
var d = new Date();
|
||||||
|
localStorage["last_feeds_updated"] = d.getTime();
|
||||||
|
}
|
||||||
|
|
||||||
function update() {
|
function update() {
|
||||||
|
console.log("update");
|
||||||
|
|
||||||
var d = new Date();
|
var d = new Date();
|
||||||
var login = localStorage["login"];
|
var login = localStorage["login"];
|
||||||
var single_user = localStorage["single_user"];
|
var single_user = localStorage["single_user"];
|
||||||
|
@ -23,7 +41,6 @@ function update() {
|
||||||
|
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
|
|
||||||
|
|
||||||
xhr.open("POST", requestUrl, true);
|
xhr.open("POST", requestUrl, true);
|
||||||
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||||
xhr.send(params);
|
xhr.send(params);
|
||||||
|
@ -109,6 +126,7 @@ function timeout() {
|
||||||
|
|
||||||
var update_interval;
|
var update_interval;
|
||||||
var prefs_updated;
|
var prefs_updated;
|
||||||
|
var feeds_update_interval = 30 * 60 * 1000;
|
||||||
|
|
||||||
if (localStorage["update_interval"])
|
if (localStorage["update_interval"])
|
||||||
update_interval = localStorage["update_interval"] * 60 * 1000;
|
update_interval = localStorage["update_interval"] * 60 * 1000;
|
||||||
|
@ -126,14 +144,27 @@ function timeout() {
|
||||||
prefs_updated != prefs_last_updated) {
|
prefs_updated != prefs_last_updated) {
|
||||||
|
|
||||||
last_updated = d.getTime();
|
last_updated = d.getTime();
|
||||||
prefs_last_updated = prefs_updated;
|
|
||||||
try {
|
try {
|
||||||
update();
|
update();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
//
|
console.warn(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (localStorage['update_feeds'] == 1 && (d.getTime() > feeds_last_updated + feeds_update_interval || prefs_updated != prefs_last_updated)) {
|
||||||
|
|
||||||
|
feeds_last_updated = d.getTime();
|
||||||
|
|
||||||
|
try {
|
||||||
|
update_feeds();
|
||||||
|
} catch (e) {
|
||||||
|
console.warn(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
prefs_last_updated = prefs_updated;
|
||||||
|
|
||||||
window.setTimeout("timeout()", 1000);
|
window.setTimeout("timeout()", 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "Tiny Tiny RSS Notifier",
|
"name": "Tiny Tiny RSS Notifier",
|
||||||
"background_page": "background.html",
|
"background_page": "background.html",
|
||||||
"version": "0.4.2",
|
"version": "0.5",
|
||||||
"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" },
|
||||||
|
|
|
@ -40,6 +40,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";
|
localStorage['single_user'] = (f.single_user.checked) ? "1" : "0";
|
||||||
|
localStorage['update_feeds'] = (f.update_feeds.checked) ? "1" : "0";
|
||||||
|
|
||||||
var d = new Date();
|
var d = new Date();
|
||||||
|
|
||||||
|
@ -89,6 +90,11 @@ function init() {
|
||||||
else
|
else
|
||||||
f.single_user.checked = false;
|
f.single_user.checked = false;
|
||||||
|
|
||||||
|
if (localStorage['update_feeds'])
|
||||||
|
f.update_feeds.checked = localStorage['update_feeds'] == "1";
|
||||||
|
else
|
||||||
|
f.update_feeds.checked = false;
|
||||||
|
|
||||||
single_user_toggle();
|
single_user_toggle();
|
||||||
|
|
||||||
var last_updated = $('last_updated');
|
var last_updated = $('last_updated');
|
||||||
|
@ -97,8 +103,13 @@ function init() {
|
||||||
|
|
||||||
d.setTime(localStorage["last_updated"]);
|
d.setTime(localStorage["last_updated"]);
|
||||||
|
|
||||||
|
|
||||||
last_updated.innerHTML = d;
|
last_updated.innerHTML = d;
|
||||||
|
|
||||||
|
var feeds_last_updated = $('feeds-last-updated');
|
||||||
|
|
||||||
|
d.setTime(localStorage["last_feeds_updated"]);
|
||||||
|
|
||||||
|
feeds_last_updated.innerHTML = d;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -177,10 +188,16 @@ fieldset span.note {
|
||||||
<span class="note">(requires Tiny Tiny RSS 1.4.1 or trunk)</span>
|
<span class="note">(requires Tiny Tiny RSS 1.4.1 or trunk)</span>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<label>Periodically try to update tt-rss feeds:</label>
|
||||||
|
<input name="update_feeds" type="checkbox" value="1"/>
|
||||||
|
<span class="note">Please use this as a last resort method only in case you can't update your feeds <a target="_blank" href="http://tt-rss.org/wiki/UpdatingFeeds">in any other way</a>. Last updated: <span id='feeds-last-updated'>N/A</span></span>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
<input type="submit" value="Save"/>
|
<input type="submit" value="Save"/>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<p>Copyright © 2010
|
<p>Copyright © 2010-2012
|
||||||
<a target="_blank" href="http://tt-rss.org">Andrew Dolgov</a>.
|
<a target="_blank" href="http://tt-rss.org">Andrew Dolgov</a>.
|
||||||
Licensed under GNU GPL version 2.</p>
|
Licensed under GNU GPL version 2.</p>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue