From 51fbc48aedac2e3db1af3126f646092ca5ce5a8b Mon Sep 17 00:00:00 2001 From: Christopher Lenz Date: Fri, 23 May 2008 11:28:10 +0000 Subject: Futon changes to correctly display reduce results. git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@659505 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/browse.js | 52 ++++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 20 deletions(-) (limited to 'share/www/script/browse.js') diff --git a/share/www/script/browse.js b/share/www/script/browse.js index 29e76d6a..1a5dcd93 100644 --- a/share/www/script/browse.js +++ b/share/www/script/browse.js @@ -363,7 +363,7 @@ function CouchDatabasePage() { 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 @@ function CouchDatabasePage() { } 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 @@ function CouchDatabasePage() { $("#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 = $(""); + var key = row.key; + $("
" + + "ID: " + row.id + "
") + .find("em").text(key !== null ? prettyPrintJSON(key, 0, "") : "null").end() + .appendTo(tr); + var value = row.value; + $("").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 = $(""); - var key = row.key; - $("
" + - "ID: " + row.id + "
") - .find("em").text(key !== null ? prettyPrintJSON(key, 0, "") : "null").end() - .appendTo(tr); - var value = row.value; + $("").appendTo(tr); $("").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; -- cgit v1.2.3