diff options
author | Andrew Dolgov <[email protected]> | 2010-11-13 02:09:30 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2010-11-13 02:09:30 +0300 |
commit | dd1c068056bc6ac18a4832f7c7dd4376c17f9b14 (patch) | |
tree | 1e6944a05ffd1aa7a5cf50d793d372e01c06769b | |
parent | 62b800b47cadf623dfd0178554a1d7251f5b979e (diff) |
implement ajax loading of cdm content when not in expand mode
-rw-r--r-- | functions.php | 12 | ||||
-rw-r--r-- | modules/backend-rpc.php | 27 | ||||
-rw-r--r-- | viewfeed.js | 25 |
3 files changed, 58 insertions, 6 deletions
diff --git a/functions.php b/functions.php index 9df02f839..2865f68e2 100644 --- a/functions.php +++ b/functions.php @@ -5341,9 +5341,9 @@ 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\"/>"; @@ -5418,14 +5418,14 @@ } } -# if ($expand_cdm) { + if ($expand_cdm) { $article_content = sanitize_rss($link, $line["content_preview"], false, false, $feed_site_url); if (!$article_content) $article_content = " "; -# } else { -# $article_content = ''; -# } + } else { + $article_content = ''; + } print "<div id=\"POSTNOTE-$id\">"; if ($line['note']) { diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index 874f547c3..a6d495feb 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -1146,6 +1146,33 @@ 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>"; } ?> diff --git a/viewfeed.js b/viewfeed.js index a5654eb45..99f6f3e4c 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -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; |