summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorChristopher Lenz <cmlenz@apache.org>2009-12-11 23:27:18 +0000
committerChristopher Lenz <cmlenz@apache.org>2009-12-11 23:27:18 +0000
commit95464554aaadb9d8cac554ada84a4db9328793fa (patch)
tree9099fd6e569c7a81740f1110efa94b322a846fa8 /share
parentae46d1ed6221af19cbc060b879f80d81d227651c (diff)
Futon: Show empty lists and objects in document view as [] and {}, respectively.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@889856 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share')
-rw-r--r--share/www/script/futon.browse.js12
-rw-r--r--share/www/script/futon.format.js6
2 files changed, 16 insertions, 2 deletions
diff --git a/share/www/script/futon.browse.js b/share/www/script/futon.browse.js
index 4b033b28..172c7b62 100644
--- a/share/www/script/futon.browse.js
+++ b/share/www/script/futon.browse.js
@@ -1029,7 +1029,10 @@
row.find("td").makeEditable({acceptOnBlur: false, allowEmpty: true,
createInput: function(value) {
- if ($("dl", this).length > 0 || $("code", this).text().length > 60) {
+ var elem = $(this);
+ if (elem.find("dl").length > 0 ||
+ elem.find("code").is(".array, .object") ||
+ elem.find("code.string").text().length > 60) {
return $("<textarea rows='1' cols='40' spellcheck='false'></textarea>");
}
return $("<input type='text' spellcheck='false'>");
@@ -1082,9 +1085,14 @@
}
function _renderValue(value) {
+ function isNullOrEmpty(val) {
+ if (val == null) return true;
+ for (var i in val) return false;
+ return true;
+ }
function render(val) {
var type = typeof(val);
- if (type == "object" && val !== null) {
+ if (type == "object" && !isNullOrEmpty(val)) {
var list = $("<dl></dl>");
for (var i in val) {
$("<dt></dt>").text(i).appendTo(list);
diff --git a/share/www/script/futon.format.js b/share/www/script/futon.format.js
index 674f5f8f..601a91d3 100644
--- a/share/www/script/futon.format.js
+++ b/share/www/script/futon.format.js
@@ -72,6 +72,9 @@
}
if (index >= 0) buf.push(options.linesep, tab.substr(options.indent));
buf.push("]");
+ if (options.html) {
+ return "<code class='array'>" + buf.join("") + "</code>";
+ }
} else {
buf.push("{");
@@ -94,6 +97,9 @@
}
if (index >= 0) buf.push(options.linesep, tab.substr(options.indent));
buf.push("}");
+ if (options.html) {
+ return "<code class='object'>" + buf.join("") + "</code>";
+ }
}
return buf.join("");