summaryrefslogtreecommitdiff
path: root/share/www/script/browse.js
diff options
context:
space:
mode:
Diffstat (limited to 'share/www/script/browse.js')
-rw-r--r--share/www/script/browse.js62
1 files changed, 34 insertions, 28 deletions
diff --git a/share/www/script/browse.js b/share/www/script/browse.js
index ec514f09..d7e3fcee 100644
--- a/share/www/script/browse.js
+++ b/share/www/script/browse.js
@@ -348,6 +348,9 @@ function CouchDatabasePage() {
if (options.count === undefined) {
options.count = parseInt($("#perpage").val(), 10);
}
+ if (options.group === undefined) {
+ options.group = true;
+ }
if ($("#documents thead th.key").is(".desc")) {
options.descending = true;
$.cookies.set(dbName + ".desc", "1");
@@ -363,7 +366,7 @@ function CouchDatabasePage() {
if (resp.offset === undefined) {
resp.offset = 0;
}
- if (resp.total_rows !== null && resp.offset > 0) {
+ if (resp.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 +380,7 @@ function CouchDatabasePage() {
} else {
$("#paging a.prev").removeAttr("href");
}
- if (resp.total_rows !== null && resp.total_rows - resp.offset > options.count) {
+ if (resp.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,39 +395,42 @@ function CouchDatabasePage() {
$("#paging a.next").removeAttr("href");
}
- 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;
+ for (var i = 0; i < resp.rows.length; i++) {
+ var row = resp.rows[i];
+ var tr = $("<tr></tr>");
+ var key = row.key;
+ if (row.id) {
$("<td class='key'><a href='document.html?" + encodeURIComponent(db.name) +
- "/" + encodeURIComponent(row.id) + "'><em></em><br>" +
+ "/" + encodeURIComponent(row.id) + "'><strong></strong><br>" +
"<span class='docid'>ID:&nbsp;" + row.id + "</span></a></td>")
- .find("em").text(key !== null ? prettyPrintJSON(key, 0, "") : "null").end()
+ .find("strong").text(key !== null ? prettyPrintJSON(key, 0, "") : "null").end()
+ .appendTo(tr);
+ } else {
+ $("<td class='key'><strong></strong></td>")
+ .find("strong").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>");
- $("<td class='key'></td>").appendTo(tr);
+ var value = row.value;
$("<td class='value'></td>").text(
- resp.result !== null ? prettyPrintJSON(resp.result) : "null"
- ).appendTo(tr);
+ 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 reduce result");
- $("#documents").addClass("reduced");
}
+ var firstNum = 1;
+ var lastNum = totalNum = resp.rows.length;
+ if (resp.total_rows != null) {
+ firstNum = Math.min(resp.total_rows, resp.offset + 1);
+ lastNum = firstNum + resp.rows.length - 1;
+ totalNum = resp.total_rows;
+ $("#paging").show();
+ } else {
+ $("#paging").hide();
+ }
+ $("#documents tbody.footer td span").text(
+ "Showing " + firstNum + "-" + lastNum + " of " + totalNum +
+ " row" + (firstNum != lastNum ? "s" : ""));
$("#documents tbody tr:odd").addClass("odd");
$(document.body).removeClass("loading");
}