]> git.wh0rd.org - tt-rss.git/blobdiff - digest.js
add some more lockfiles to update_daemon2
[tt-rss.git] / digest.js
index b788535fc067c617b1bfe3474276252fa84099e5..98ae14d8c1b16aa83fbdf5e6f685424cad511d53 100644 (file)
--- a/digest.js
+++ b/digest.js
@@ -1,4 +1,8 @@
 var last_feeds = [];
+var init_params = {};
+
+var db = false;
+var store = false;
 
 var _active_feed_id = false;
 var _active_feed_offset = false;
@@ -43,9 +47,8 @@ function catchup_feed(feed_id, callback) {
        }
 }
 
-function catchup_visible_articles(callback) {
+function get_visible_article_ids() {
        try {
-
                var elems = $("headlines-content").getElementsByTagName("LI");
                var ids = [];
                        
@@ -55,6 +58,18 @@ function catchup_visible_articles(callback) {
                        }
                }
 
+               return ids;
+
+       } catch (e) {
+               exception_error("get_visible_article_ids", e);
+       }
+}
+
+function catchup_visible_articles(callback) {
+       try {
+
+               var ids = get_visible_article_ids();
+
                if (confirm(__("Mark %d displayed articles as read?").replace("%d", ids.length))) {
 
                        var query = "?op=rpc&subop=catchupSelected" +
@@ -249,11 +264,13 @@ function viewfeed(feed_id, offset, replace, no_effects, no_indicator, callback)
 
                console.log(query);
 
-               var img = $("F-" + feed_id).getElementsByTagName("IMG")[0];
+               if ($("F-" + feed_id)) {
+                       var img = $("F-" + feed_id).getElementsByTagName("IMG")[0];
 
-               if (img && !no_indicator) {
-                       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", {
@@ -309,7 +326,7 @@ function find_feed(feeds, feed_id) {
 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';
@@ -401,7 +418,15 @@ function add_headline_entry(article, feed, no_effects) {
                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'>" +
@@ -551,19 +576,25 @@ function parse_headlines(transport, replace, no_effects) {
                                }
                        }
 
-                       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) 
@@ -577,9 +608,8 @@ function parse_headlines(transport, 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) {
@@ -588,6 +618,20 @@ function init() {
                                _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);
        }