]> git.wh0rd.org Git - tt-rss.git/commitdiff
digest: ajax loading for zoom()
authorAndrew Dolgov <fox@bah.org.ru>
Sun, 12 Sep 2010 15:52:15 +0000 (19:52 +0400)
committerAndrew Dolgov <fox@bah.org.ru>
Sun, 12 Sep 2010 15:52:15 +0000 (19:52 +0400)
digest.js
modules/backend-rpc.php

index 4faee1f6c54943028764835a2bf97144de2383c7..4183d70c5e1cf71cc29ee73312d8d90b213181d9 100644 (file)
--- a/digest.js
+++ b/digest.js
@@ -102,24 +102,28 @@ function set_selected_feed(feed_id) {
        }
 }
 
-function zoom(article_id) {
+function zoom(elem, article_id) {
        try {
-               var elem = $('A-' + article_id);
+               //alert(elem + "/" + article_id);
 
-               if (elem) {
-                       var divs = elem.getElementsByTagName('DIV');
-                       
-                       for (var i = 0; i < divs.length; i++) {
-                               if (divs[i].className == 'excerpt') 
-                                       Element.hide(divs[i]);
+               elem.innerHTML = "<img src='images/indicator_tiny.gif'> " +
+                       __("Loading, please wait...");
 
-                               if (divs[i].className == 'content') 
-                                       Element.show(divs[i]);
-                       }
-               }
+               new Ajax.Request("backend.php", {
+                       parameters: "?op=rpc&subop=digest-get-contents&article_id=" +
+                               article_id,
+                       onComplete: function(transport) {
+                               fatal_error_check(transport);
+
+                               if (transport.responseXML) {
+                                       var article = transport.responseXML.getElementsByTagName('article')[0];
+                                       elem.innerHTML = article.firstChild.nodeValue;
+                               } else {
+                                       elem.innerHTML = __("Error: unable to load article.");
+                               }
+                               
+                               } });
 
-               //catchup_article(article_id, 
-               //      function() { update(); });
 
        } catch (e) {
                exception_error("zoom", e);
@@ -346,10 +350,8 @@ function add_headline_entry(article, feed, no_effects) {
                                "onclick=\"return view("+article.id+")\" class='title'>" + 
                                article.title + "</a>" +
                        "<div class='body'>" + 
-                       "<div title=\""+__("Click to expand article")+"\" onclick=\"zoom("+article.id+")\" class='excerpt'>" + 
+                       "<div title=\""+__("Click to expand article")+"\" onclick=\"zoom(this, "+article.id+")\" class='excerpt'>" + 
                                article.excerpt + "</div>" +
-                       "<div style='display : none' class='content'>" + 
-                               article.content + "</div>" +
                        "<div class='info'><a href=\#\" onclick=\"viewfeed("+feed.id+")\">" + 
                                feed.title + "</a> " + tags_part + " @ " + 
                                new Date(article.updated * 1000) + "</div>" +
index a0e4e77df97fc13bbc0ee7c7c5e75c89178b851f..592c8ab28f4cc9199812497309fdd34c8fcc175c 100644 (file)
                        return;
                }
 
+               if ($subop == "digest-get-contents") {
+                       $article_id = db_escape_string($_REQUEST['article_id']);
+
+                       $result = db_query($link, "SELECT content 
+                               FROM ttrss_entries, ttrss_user_entries
+                               WHERE id = '$article_id' AND ref_id = id AND owner_uid = ".$_SESSION['uid']);
+
+                       print "<rpc-reply>";
+
+                       print "<article id=\"$article_id\"><![CDATA[";
+
+                       $content = sanitize_rss($link, db_fetch_result($result, 0, "content"));
+
+                       print $content;
+
+                       print "]]></article>";
+
+                       print "</rpc-reply>";
+
+                       return;
+               }
+
                if ($subop == "digest-update") {
                        $feed_id = db_escape_string($_REQUEST['feed_id']);
                        $offset = db_escape_string($_REQUEST['offset']);
                        print "<rpc-reply>";
 
                        $headlines = api_get_headlines($link, $feed_id, 10, $offset,
-                               '', ($feed_id == -4), true, true, "unread", "updated DESC");
+                               '', ($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) {
                                if ($f['id'] > 0 || $f['id'] == -4) array_push($feeds, $f);
                        }
 
-                       function feeds_sort_by_unread_rev($a, $b) {
-                               $a = $a['unread'];
-                               $b = $b['unread'];
-
-                               if ($a == $b) {
-                                       return 0;
-                               }
-                               return ($a < $b) ? 1 : -1;
-                       }
-
-                       //uasort($feeds, 'feeds_sort_by_unread_rev');
-                       //$feeds = array_slice($feeds, 0, 10);
-
                        print "<feeds><![CDATA[" . json_encode($feeds) . "]]></feeds>";
 
                        print "</rpc-reply>";