]> git.wh0rd.org Git - tt-rss.git/commitdiff
more digest page improvements
authorAndrew Dolgov <fox@bah.org.ru>
Thu, 9 Sep 2010 17:44:04 +0000 (21:44 +0400)
committerAndrew Dolgov <fox@bah.org.ru>
Thu, 9 Sep 2010 17:44:04 +0000 (21:44 +0400)
digest.css
digest.js
modules/backend-rpc.php

index 62852adb0f703d71f59aa34a7d2a69a0c1cac3a2..3c770b765bc7196d047e30c2046643633753a52d 100644 (file)
@@ -156,6 +156,7 @@ a:hover {
 #headlines ul#headlines-content li {
        margin : 0px 0px 10px 0px;
        color : #909090;
+       clear : left;
 }
 
 #headlines ul#headlines-content a.title {
@@ -164,12 +165,16 @@ a:hover {
 }
 
 #headlines ul#headlines-content div.excerpt {
-       margin-left : 22px;
        color : #404040;
 }
 
+#headlines ul#headlines-content div.body {
+       margin-left : 21px;
+}
+
 #headlines ul#headlines-content div.info {
-       margin-left : 22px;
+       margin-top : 2px;
+       font-size : 11px;
 }
 
 #headlines ul#headlines-content div.info a {
index 3d58ca95f1596be28c320a99fbe8e9c48ca6632e..f27f15f863413496ebe124ff1afcad0a552eece1 100644 (file)
--- a/digest.js
+++ b/digest.js
@@ -1,12 +1,29 @@
 var last_feeds = [];
 
-function view(feed_id) {
+var _active_feed_id = false;
+var _active_feed_offset = false;
+
+function viewfeed(feed_id, offset) {
        try {
 
+               if (!feed_id) feed_id = _active_feed_id;
+
+               if (!offset) 
+                       offset = 0;
+               else
+                       offset = _active_feed_offset + offset;
+
+               var query = "backend.php?op=rpc&subop=digest-update&feed_id=" + feed_id +
+                               "&offset=" + offset;
+
+               console.log(query);
+
                new Ajax.Request("backend.php", {
-                       parameters: "backend.php?op=rpc&subop=digest-init&feed_id=" + feed_id,
+                       parameters: query, 
                        onComplete: function(transport) {
                                digest_update(transport);
+                               _active_feed_id = feed_id;
+                               _active_feed_offset = offset;
                                } });
 
        } catch (e) {
@@ -61,7 +78,7 @@ function add_feed_entry(feed) {
 
                var tmp_html = "<li>" + 
                        icon_part +
-                       "<a href=\"#\" onclick=\"view("+feed.id+")\">" + feed.title +
+                       "<a href=\"#\" onclick=\"viewfeed("+feed.id+")\">" + feed.title +
                        "<div class='unread-ctr'>" + feed.unread + "</div>" +   
                        "</li>";
 
@@ -89,15 +106,15 @@ function add_headline_entry(article, feed) {
                var icon_part = "";
 
                if (article.has_icon) 
-                       icon_part = "<img alt='zz' src='icons/" + article.feed_id + ".ico'/>";
+                       icon_part = "<img src='icons/" + article.feed_id + ".ico'/>";
 
                var tmp_html = "<li>" + 
                        icon_part +
                        "<a class='title'>" + article.title + "</a>" +
-                       "<div class='excerpt'>" + article.excerpt + "</div>" +
+                       "<div class='body'><div class='excerpt'>" + article.excerpt + "</div>" +
                        "<div class='info'><a>" + feed.title + "</a> " + " @ " + 
                                new Date(article.updated * 1000) + "</div>" +
-                       "</li>";
+                       "</div></li>";
 
                $("headlines-content").innerHTML += tmp_html;
 
@@ -112,15 +129,17 @@ function digest_update(transport) {
                var headlines = transport.responseXML.getElementsByTagName('headlines')[0];
 
                if (feeds) {
-                       last_feeds = feeds;
-
                        feeds = eval("(" + feeds.firstChild.nodeValue + ")");
 
+                       last_feeds = feeds;
+
                        $('feeds-content').innerHTML = "";
 
                        for (var i = 0; i < feeds.length; i++) {
                                add_feed_entry(feeds[i]);
                        }
+               } else {
+                       feeds = last_feeds;
                }
 
                if (headlines) {
@@ -128,11 +147,18 @@ function digest_update(transport) {
 
                        $('headlines-content').innerHTML = "";
 
+                       Element.hide('headlines-content');
+
                        for (var i = 0; i < headlines.length; i++) {
                                add_headline_entry(headlines[i], find_feed(feeds, headlines[i].feed_id));
                        }
 
-                       $('headlines-content').innerHTML += "<li><a>More articles...</a></li>";
+                       $('headlines-content').innerHTML += "<li>" +
+                               "<div class='body'><a href=\"#\" onclick=\"viewfeed(false, 10)\">" +
+                               __("More articles...") + "</a></div></li>";
+
+                       new Effect.Appear('headlines-content');
+
                }
 
        } catch (e) {
@@ -147,6 +173,7 @@ function digest_init() {
                        parameters: "backend.php?op=rpc&subop=digest-init",
                        onComplete: function(transport) {
                                digest_update(transport);
+                               window.setTimeout('viewfeed(-4)', 100);
                                } });
 
        } catch (e) {
index edf2ae2e4d254dfdbc48eaa22ddce50449451ab6..80eda7c3f592a047aa774718511a91254091c3ff 100644 (file)
                        return;
                }
 
-               if ($subop == "digest-init") {
+               if ($subop == "digest-update") {
                        $feed_id = db_escape_string($_REQUEST['feed_id']);
-
+                       $offset = db_escape_string($_REQUEST['offset']);
+               
                        if (!$feed_id) $feed_id = -4;
+                       if (!$offset) $offset = 0;
+
 
+                       print "<rpc-reply>";
+
+                       $headlines = api_get_headlines($link, $feed_id, 10, $offset,
+                               '', ($feed_id == -4), true, false, "unread", "updated DESC");
+
+                       //function api_get_headlines($link, $feed_id, $limit, $offset,
+                       //              $filter, $is_cat, $show_excerpt, $show_content, $view_mode) {
+
+                       print "<headlines><![CDATA[" . json_encode($headlines) . "]]></headlines>";
+
+                       print "</rpc-reply>";
+                       return;
+               }
+
+               if ($subop == "digest-init") {
                        print "<rpc-reply>";
 
                        $tmp_feeds = api_get_feeds($link, false, true, false, 0);
 
                        print "<feeds><![CDATA[" . json_encode($feeds) . "]]></feeds>";
 
-                       $headlines = api_get_headlines($link, $feed_id, 10, 0,
-                               '', ($feed_id == -4), true, false, "all_articles", "updated DESC");
-
-                       //function api_get_headlines($link, $feed_id, $limit, $offset,
-                       //              $filter, $is_cat, $show_excerpt, $show_content, $view_mode) {
-
-                       print "<headlines><![CDATA[" . json_encode($headlines) . "]]></headlines>";
                        print "</rpc-reply>";
                        return;
                }