summaryrefslogtreecommitdiff
path: root/share/www/script
diff options
context:
space:
mode:
authorChristopher Lenz <cmlenz@apache.org>2009-07-22 21:35:05 +0000
committerChristopher Lenz <cmlenz@apache.org>2009-07-22 21:35:05 +0000
commita7a6c6a7370cf6723011ebd174406df231cf4517 (patch)
treeac0f199f94920a218a47786c1e09683c1344b263 /share/www/script
parent26555564ad89db5407f278dc7e3943c0b0ba9bbc (diff)
Apply patch by Jason Davies that improves how the view menu is populated: only one HTTP request (thanks to `include_docs`), and design docs and view names are sorted alphabetically. Closes COUCHDB-426.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@796885 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/www/script')
-rw-r--r--share/www/script/futon.browse.js31
1 files changed, 17 insertions, 14 deletions
diff --git a/share/www/script/futon.browse.js b/share/www/script/futon.browse.js
index 85e9a0ec..4cb3eb6a 100644
--- a/share/www/script/futon.browse.js
+++ b/share/www/script/futon.browse.js
@@ -236,24 +236,27 @@
this.populateViewsMenu = function() {
var select = $("#switch select");
db.allDocs({startkey: "_design/", endkey: "_design0",
+ include_docs: true,
success: function(resp) {
select[0].options.length = 3;
for (var i = 0; i < resp.rows.length; i++) {
- db.openDoc(resp.rows[i].id, {
- success: function(doc) {
- var optGroup = $(document.createElement("optgroup"))
- .attr("label", doc._id.substr(8)).appendTo(select);
- for (var name in doc.views) {
- var path = $.couch.encodeDocId(doc._id) + "/_view/" +
- encodeURIComponent(name);
- var option = $(document.createElement("option"))
- .attr("value", path).text(name).appendTo(optGroup);
- if (path == viewName) {
- option[0].selected = true;
- }
- }
+ var doc = resp.rows[i].doc;
+ var optGroup = $(document.createElement("optgroup"))
+ .attr("label", doc._id.substr(8)).appendTo(select);
+ var viewNames = [];
+ for (var name in doc.views) {
+ viewNames.push(name);
+ }
+ viewNames.sort();
+ for (var j = 0; j < viewNames.length; j++) {
+ var path = $.couch.encodeDocId(doc._id) + "/_view/" +
+ encodeURIComponent(viewNames[j]);
+ var option = $(document.createElement("option"))
+ .attr("value", path).text(viewNames[j]).appendTo(optGroup);
+ if (path == viewName) {
+ option[0].selected = true;
}
- });
+ }
}
}
});