var last_feeds = [];
+var init_params = {};
+
+var db = false;
+var store = false;
var _active_feed_id = false;
var _active_feed_offset = false;
}
}
+function get_visible_article_ids() {
+ try {
+ var elems = $("headlines-content").getElementsByTagName("LI");
+ var ids = [];
+
+ for (var i = 0; i < elems.length; i++) {
+ if (elems[i].id && elems[i].id.match("A-")) {
+ ids.push(elems[i].id.replace("A-", ""));
+ }
+ }
+
+ return ids;
+
+ } catch (e) {
+ exception_error("get_visible_article_ids", e);
+ }
+}
+
function catchup_visible_articles(callback) {
try {
- if (confirm(__("Mark all displayed articles as read?"))) {
+ var ids = get_visible_article_ids();
+
+ if (confirm(__("Mark %d displayed articles as read?").replace("%d", ids.length))) {
- var elems = $("headlines-content").getElementsByTagName("LI");
- var ids = [];
-
- for (var i = 0; i < elems.length; i++) {
- if (elems[i].id && elems[i].id.match("A-")) {
- ids.push(elems[i].id.replace("A-", ""));
- }
- }
-
var query = "?op=rpc&subop=catchupSelected" +
"&cmode=0&ids=" + param_escape(ids);
function load_more() {
try {
- viewfeed(_active_feed_id, _active_feed_offset + 10);
+ var pr = $("H-LOADING-IMG");
+
+ if (pr) Element.show(pr);
+
+ viewfeed(_active_feed_id, _active_feed_offset + 10, false, false, true,
+ function() {
+ var pr = $("H-LOADING-IMG");
+
+ if (pr) Element.hide(pr);
+ });
} catch (e) {
exception_error("load_more", e);
}
}
-function update() {
+function update(callback) {
try {
console.log('updating feeds...');
fatal_error_check(transport);
parse_feeds(transport);
set_selected_feed(_active_feed_id);
+
+ if (callback) callback(transport);
} });
_update_timeout = window.setTimeout('update()', 5*1000);
function view_update() {
try {
- viewfeed(_active_feed_id, _active_feed_offset, false, true);
+ viewfeed(_active_feed_id, _active_feed_offset, false, true, true);
update();
} catch (e) {
exception_error("view_update", e);
}
}
-function viewfeed(feed_id, offset, replace, no_effects) {
+function viewfeed(feed_id, offset, replace, no_effects, no_indicator, callback) {
try {
if (!feed_id) feed_id = _active_feed_id;
console.log(query);
- var img = $("F-" + feed_id).getElementsByTagName("IMG")[0];
+ if ($("F-" + feed_id)) {
+ var img = $("F-" + feed_id).getElementsByTagName("IMG")[0];
- img.setAttribute("orig_src", img.src);
- img.src = 'images/indicator_tiny.gif';
+ if (img && !no_indicator) {
+ img.setAttribute("orig_src", img.src);
+ img.src = 'images/indicator_tiny.gif';
+ }
+ }
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
+ Element.hide("overlay");
+
fatal_error_check(transport);
parse_headlines(transport, replace, no_effects);
- set_selected_feed(feed_id);
+ set_selected_feed(feed_id);
_active_feed_offset = offset;
- img.src = img.getAttribute("orig_src");
+
+ if (img && !no_indicator)
+ img.src = img.getAttribute("orig_src");
+
+ if (callback) callback(transport);
+
} });
} catch (e) {
function get_feed_icon(feed) {
try {
if (feed.has_icon)
- return 'icons/' + feed.id + '.ico';
+ return getInitParam('icons_location') + "/" + feed.id + '.ico';
if (feed.id == -1)
return 'images/mark_set.png';
if (article.excerpt.trim() == "")
article.excerpt = __("Click to expand article.");
- var tmp_html = "<li id=\"A-"+article.id+"\" "+style+" class=\"unread\">" +
+ var li_class = "unread";
+
+ var fresh_max = getInitParam("fresh_article_max_age") * 60 * 60;
+ var d = new Date();
+
+ if (d.getTime() / 1000 - article.updated < fresh_max)
+ li_class = "fresh";
+
+ var tmp_html = "<li id=\"A-"+article.id+"\" "+style+" class=\""+li_class+"\">" +
icon_part +
"<div class='digest-check'>" +
}
}
- if (pr) {
- $('headlines-content').appendChild(pr);
- if (!no_effects) new Effect.ScrollTo(inserted);
- } else {
- $('headlines-content').innerHTML += "<li id='H-MORE-PROMPT'>" +
- "<div class='body'>" +
- "<a href=\"javascript:catchup_visible_articles()\">" +
- __("Mark as read") + "</a> | " +
- "<a href=\"javascript:load_more()\">" +
- __("Load more...") + "</a>" +
- "<img style=\"display : none\" "+
+ var ids = get_visible_article_ids();
+
+ if (ids.length > 0) {
+ if (pr) {
+ $('headlines-content').appendChild(pr);
+ if (!no_effects) new Effect.ScrollTo(inserted);
+ } else {
+ $('headlines-content').innerHTML += "<li id='H-MORE-PROMPT'>" +
+ "<div class='body'>" +
+ "<a href=\"javascript:catchup_visible_articles()\">" +
+ __("Mark as read") + "</a> | " +
+ "<a href=\"javascript:load_more()\">" +
+ __("Load more...") + "</a>" +
+ "<img style=\"display : none\" "+
"id=\"H-LOADING-IMG\" src='images/indicator_tiny.gif'>" +
- "</div></li>";
+ "</div></li>";
+ }
+ } else {
+ // FIXME : display some kind of "nothing to see here" prompt here
}
if (replace && !no_effects)
}
}
-function init() {
+function init_second_stage() {
try {
-
new Ajax.Request("backend.php", {
parameters: "backend.php?op=rpc&subop=digest-init",
onComplete: function(transport) {
_update_timeout = window.setTimeout('update()', 5*1000);
} });
+ } catch (e) {
+ exception_error("init_second_stage", e);
+ }
+}
+
+function init() {
+ try {
+
+ new Ajax.Request("backend.php", {
+ parameters: "?op=rpc&subop=sanityCheck",
+ onComplete: function(transport) {
+ backend_sanity_check_callback(transport);
+ } });
+
} catch (e) {
exception_error("digest_init", e);
}