summaryrefslogtreecommitdiff
path: root/viewfeed.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2011-08-31 22:33:15 +0400
committerAndrew Dolgov <[email protected]>2011-08-31 22:33:15 +0400
commitb1a4b0e98fe6303e956bdb332960642ff6d1a24d (patch)
tree5f73d4f41dc3b72065421f7a9a0fe0628afd7c1a /viewfeed.js
parent87085cc848577670f7ddf461a3def68abdf59423 (diff)
use caching for unexpanded CDM
Diffstat (limited to 'viewfeed.js')
-rw-r--r--viewfeed.js35
1 files changed, 23 insertions, 12 deletions
diff --git a/viewfeed.js b/viewfeed.js
index 368a1ed4c..1718c810a 100644
--- a/viewfeed.js
+++ b/viewfeed.js
@@ -1235,28 +1235,39 @@ function cdmExpandArticle(id) {
var query = "?op=rpc&subop=cdmGetArticle&id=" + param_escape(id);
- //console.log(query);
+ var neighbor_ids = getRelativePostIds(id);
+
+ /* only request uncached articles */
+ var cids_to_request = [];
+
+ for (var i = 0; i < neighbor_ids.length; i++) {
+ if (cids_requested.indexOf(neighbor_ids[i]) == -1)
+ if ($("CWRAP-" + neighbor_ids[i]).innerHTML == "") {
+ cids_to_request.push(neighbor_ids[i]);
+ cids_requested.push(neighbor_ids[i]);
+ }
+ }
+
+ console.log("additional ids: " + cids_to_request.toString());
+
+ query = query + "&cids=" + cids_to_request.toString();
+
+ console.log(query);
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
+
$("FUPDPIC-" + id).src = 'images/blank_icon.gif';
handle_rpc_json(transport);
var reply = JSON.parse(transport.responseText);
- if (reply) {
- var article = reply['article']['content'];
- var recv_id = reply['article']['id'];
-
- if (recv_id == id)
- $("CWRAP-" + id).innerHTML = article;
-
- } else {
- $("CWRAP-" + id).innerHTML = __("Unable to load article.");
-
- }
+ reply.each(function(article) {
+ $("CWRAP-" + article['id']).innerHTML = article['content']
+ cids_requested.remove(article['id']);
+ });
}});
}