Load nodes which are visible but not loaded yet.
authorBenjamin Smedberg <benjamin@smedbergs.us>
Mon, 14 Apr 2008 13:24:33 -0400
changeset 18 d4ea0f486b60485e08715df03a1f5a9ed4988535
parent 17 1115da66d337923f24189093db17c44e8fbe9414
child 19 26235cd436e1808ecc83f9232b8fee936c273c76
push id2
push userbsmedberg@mozilla.com
push dateMon, 14 Apr 2008 21:07:23 +0000
Load nodes which are visible but not loaded yet.
www/navigate.js
--- a/www/navigate.js
+++ b/www/navigate.js
@@ -397,16 +397,32 @@ function doLayout()
   drawParents(contextrev, -1);
 
   for each (let rev in revs) {
     if (!rev.gc)
       rev._x = null;
   }
   
   redraw();
+
+  if (loadMore.length) {
+    /* Load the unloaded nodes */
+    let repo = $('#select-repo')[0].value;
+    $.ajax(
+      {'url': BASEURL.replace('%REPO%', repo) + "jsoninfo?" +
+                ["node=" + rev.node for each (rev in loadMore)].join('&'),
+       'type': 'GET',
+       'dataType': 'json',
+       error: function(xhr, textStatus) {
+         alert("Request failed: " + textStatus + "\nurl: " + this.url);
+       },
+       success: processInfoData,
+      }
+    );
+  }
 }
 
 function redraw()
 {
   var cx = getCX();
 
   /**
    * Draw some text. Advance the translation down by 12px
@@ -487,25 +503,33 @@ function redraw()
     if (rev.gc)
       drawRev(rev);
   }
 }
 
 function processContextData(data)
 {
   for each (var nodeObj in data.nodes) {
-      getRevision(nodeObj.node).update(nodeObj);
+    getRevision(nodeObj.node).update(nodeObj);
   }
 
   if (this.changeContext)
     gContext = data.context;
 
   doLayout();
 }
 
+function processInfoData(data)
+{
+  for each (var infoNode in data) {
+    getRevision(infoNode.node).update(infoNode);
+  }
+  doLayout();
+}
+
 function startContext(hash)
 {
     var repo, context;
 
     if (hash == '') {
         repo = $('#select-repo')[0].value;
         context = $('#node-input')[0].value;
     }