couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cml...@apache.org
Subject svn commit: r659505 - in /incubator/couchdb/trunk/share/www: script/browse.js style/layout.css
Date Fri, 23 May 2008 11:28:12 GMT
Author: cmlenz
Date: Fri May 23 04:28:10 2008
New Revision: 659505

URL: http://svn.apache.org/viewvc?rev=659505&view=rev
Log:
Futon changes to correctly display reduce results.

Modified:
    incubator/couchdb/trunk/share/www/script/browse.js
    incubator/couchdb/trunk/share/www/style/layout.css

Modified: incubator/couchdb/trunk/share/www/script/browse.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/script/browse.js?rev=659505&r1=659504&r2=659505&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/script/browse.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/script/browse.js [utf-8] Fri May 23 04:28:10 2008
@@ -363,7 +363,7 @@
       if (resp.offset === undefined) {
         resp.offset = 0;
       }
-      if (resp.offset > 0) {
+      if (resp.total_rows !== null && resp.offset > 0) {
         $("#paging a.prev").attr("href", "#" + (resp.offset - options.count)).click(function()
{
           var firstDoc = resp.rows[0];
           page.updateDocumentListing({
@@ -377,7 +377,7 @@
       } else {
         $("#paging a.prev").removeAttr("href");
       }
-      if (resp.total_rows - resp.offset > options.count) {
+      if (resp.total_rows !== null && resp.total_rows - resp.offset > options.count)
{
         $("#paging a.next").attr("href", "#" + (resp.offset + options.count)).click(function()
{
           var lastDoc = resp.rows[resp.rows.length - 1];
           page.updateDocumentListing({
@@ -392,29 +392,41 @@
         $("#paging a.next").removeAttr("href");
       }
 
-      for (var i = 0; i < resp.rows.length; i++) {
-        var row = resp.rows[i];
+      if (resp.total_rows != null) {
+        for (var i = 0; i < resp.rows.length; i++) {
+          var row = resp.rows[i];
+          var tr = $("<tr></tr>");
+          var key = row.key;
+          $("<td class='key'><a href='document.html?" + encodeURIComponent(db.name)
+
+            "/" + encodeURIComponent(row.id) + "'><em></em><br>" +
+            "<span class='docid'>ID:&nbsp;" + row.id + "</span></a></td>")
+            .find("em").text(key !== null ? prettyPrintJSON(key, 0, "") : "null").end()
+            .appendTo(tr);
+          var value = row.value;
+          $("<td class='value'></td>").text(
+            value !== null ? prettyPrintJSON(value, 0, "") : "null"
+          ).appendTo(tr).dblclick(function() {
+            location.href = this.previousSibling.firstChild.href;
+          });
+          tr.appendTo("#documents tbody.content");
+        }
+        $("#documents tbody.footer td span").text(
+          "Showing " + Math.min(resp.total_rows, resp.offset + 1) + "-" +
+          (resp.offset + resp.rows.length) + " of " + resp.total_rows +
+          " document" + (resp.total_rows != 1 ? "s" : ""));
+        $("#documents").removeClass("reduced");
+      } else {
         var tr = $("<tr></tr>");
-        var key = row.key;
-        $("<td class='key'><a href='document.html?" + encodeURIComponent(db.name)
+
-          "/" + encodeURIComponent(row.id) + "'><em></em><br>" +
-          "<span class='docid'>ID:&nbsp;" + row.id + "</span></a></td>")
-          .find("em").text(key !== null ? prettyPrintJSON(key, 0, "") : "null").end()
-          .appendTo(tr);
-        var value = row.value;
+        $("<td class='key'></td>").appendTo(tr);
         $("<td class='value'></td>").text(
-          value !== null ? prettyPrintJSON(value, 0, "") : "null"
-        ).appendTo(tr).dblclick(function() {
-          location.href = this.previousSibling.firstChild.href;
-        });
+          resp.result !== null ? prettyPrintJSON(resp.result) : "null"
+        ).appendTo(tr);
         tr.appendTo("#documents tbody.content");
+        $("#documents tbody.footer td span").text("Showing reduce result");
+        $("#documents").addClass("reduced");
       }
-
       $("#documents tbody tr:odd").addClass("odd");
-      $("#documents tbody.footer td span").text(
-        "Showing " + Math.min(resp.total_rows, resp.offset + 1) + "-" +
-        (resp.offset + resp.rows.length) + " of " + resp.total_rows +
-        " document" + (resp.total_rows != 1 ? "s" : ""));
+
       $(document.body).removeClass("loading");
     }
     options.success = handleResults;

Modified: incubator/couchdb/trunk/share/www/style/layout.css
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/style/layout.css?rev=659505&r1=659504&r2=659505&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/style/layout.css (original)
+++ incubator/couchdb/trunk/share/www/style/layout.css Fri May 23 04:28:10 2008
@@ -308,6 +308,12 @@
 }
 #documents tbody.content td.value { font-size: 10px; }
 
+#documents.reduced th.key, #documents.reduced td.key,
+#documents.reduced #paging {
+  display: none;
+}
+#documents.reduced td.value { white-space: pre; }
+
 /* Document fields table */
 
 #fields { table-layout: fixed; }



Mime
View raw message