diff options
author | Christopher Lenz <cmlenz@apache.org> | 2008-05-23 11:28:10 +0000 |
---|---|---|
committer | Christopher Lenz <cmlenz@apache.org> | 2008-05-23 11:28:10 +0000 |
commit | 51fbc48aedac2e3db1af3126f646092ca5ce5a8b (patch) | |
tree | 6ba2408503391e82183769868a585a8287fef4b7 /share/www | |
parent | 0de41589080a9ebbd172e96a3d2130591c671898 (diff) |
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
Diffstat (limited to 'share/www')
-rw-r--r-- | share/www/script/browse.js | 52 | ||||
-rw-r--r-- | share/www/style/layout.css | 6 |
2 files changed, 38 insertions, 20 deletions
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 = $("<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: " + 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: " + 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; diff --git a/share/www/style/layout.css b/share/www/style/layout.css index c899198d..13dfbcaf 100644 --- a/share/www/style/layout.css +++ b/share/www/style/layout.css @@ -308,6 +308,12 @@ ul.suggest-dropdown li.selected { cursor: pointer; background: Highlight; } #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; } |