]> git.wh0rd.org Git - tt-rss.git/commitdiff
implement ajax loading of cdm content when not in expand mode
authorAndrew Dolgov <fox@fakecake.org>
Fri, 12 Nov 2010 23:09:30 +0000 (02:09 +0300)
committerAndrew Dolgov <fox@fakecake.org>
Fri, 12 Nov 2010 23:09:30 +0000 (02:09 +0300)
functions.php
modules/backend-rpc.php
viewfeed.js

index 9df02f839494132ecbfcaacf7db3f1623480146d..2865f68e24158ac15a408fb7109aa23729256885 100644 (file)
                                                        title=\"".htmlspecialchars($line["feed_title"])."\"
                                                        onclick=\"viewfeed($feed_id)\">$feed_icon_img</span>";
                                        }
-                                       print "</div>";
-
                                        print "<div class=\"updPic\">$update_pic</div>";
+
+                                       print "</div>";
                                
                                        print "<input type=\"checkbox\" onclick=\"toggleSelectRowById(this, 
                                                        'RROW-$id')\" class=\"feedCheckBox\" id=\"RCHK-$id\"/>";
                                                }
                                        }
 
-#                                      if ($expand_cdm) {
+                                       if ($expand_cdm) {
                                                $article_content = sanitize_rss($link, $line["content_preview"], 
                                                        false, false, $feed_site_url);
 
                                                if (!$article_content) $article_content = "&nbsp;";
-#                                      } else {
-#                                              $article_content = '';
-#                                      }
+                                       } else {
+                                               $article_content = '';
+                                       }
 
                                        print "<div id=\"POSTNOTE-$id\">";
                                        if ($line['note']) {
index 874f547c32c038ea9ca9251b02063f993f50d692..a6d495feb23dabc4452dc1a4f988a935d0bbbf76 100644 (file)
                        return;
                }
 
+               if ($subop == "cdmGetArticle") {
+                       $id = db_escape_string($_REQUEST["id"]);
+
+                       $result = db_query($link, "SELECT content, 
+                               ttrss_feeds.site_url AS site_url FROM ttrss_user_entries, ttrss_feeds, 
+                               ttrss_entries
+                               WHERE feed_id = ttrss_feeds.id AND ref_id = '$id' AND 
+                               ttrss_entries.id = ref_id AND
+                               ttrss_user_entries.owner_uid = ".$_SESSION["uid"]);
+
+                       if (db_num_rows($result) != 0) {
+                               $line = db_fetch_assoc($result);
+
+                               $article_content = sanitize_rss($link, $line["content"], 
+                                       false, false, $line['site_url']);
+                       
+                       } else {
+                               $article_content = '';
+                       }
+
+                       print "<rpc-reply><article id=\"$id\"><![CDATA[";
+                       print "$article_content";
+                       print "]]></article></rpc-reply>";
+
+                       return;
+               }
+
                print "<rpc-reply><error>Unknown method: $subop</error></rpc-reply>";
        }
 ?>
index a5654eb45bf4a3f91207e437a23786f35bb44da5..99f6f3e4c1581063130b8f51155648782b7b41a2 100644 (file)
@@ -2001,8 +2001,33 @@ function cdmExpandArticle(id) {
                elem = $("CICD-" + id);
 
                if (!Element.visible(elem)) {
+                       $("FUPDPIC-" + id).src = "images/indicator_tiny.gif";
+                       $("CWRAP-" + id).innerHTML = "<div class=\"insensitive\">" + 
+                               __("Loading, please wait...") + "</div>";
                        Element.show(elem);
                        Element.hide("CEXC-" + id);
+
+                       var query = "?op=rpc&subop=cdmGetArticle&id=" + param_escape(id);
+
+                       //console.log(query);
+
+                       new Ajax.Request("backend.php", {
+                               parameters: query,
+                               onComplete: function(transport) { 
+                                       $("FUPDPIC-" + id).src = 'images/blank_icon.gif';
+
+                                       if (transport.responseXML) {
+                                               var article = transport.responseXML.getElementsByTagName("article")[0];
+                                               var recv_id = article.getAttribute("id");
+
+                                               if (recv_id == id)
+                                                       $("CWRAP-" + id).innerHTML = article.firstChild.nodeValue;
+
+                                       } else {
+                                               $("CWRAP-" + id).innerHTML = __("Unable to load article.");
+
+                                       }
+                       }});
                }
 
                var new_offset = $("RROW-" + id).offsetTop;