couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cml...@apache.org
Subject svn commit: r889856 - in /couchdb/trunk/share/www/script: futon.browse.js futon.format.js
Date Fri, 11 Dec 2009 23:27:18 GMT
Author: cmlenz
Date: Fri Dec 11 23:27:18 2009
New Revision: 889856

URL: http://svn.apache.org/viewvc?rev=889856&view=rev
Log:
Futon: Show empty lists and objects in document view as [] and {}, respectively.

Modified:
    couchdb/trunk/share/www/script/futon.browse.js
    couchdb/trunk/share/www/script/futon.format.js

Modified: couchdb/trunk/share/www/script/futon.browse.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/futon.browse.js?rev=889856&r1=889855&r2=889856&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/futon.browse.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/futon.browse.js [utf-8] Fri Dec 11 23:27:18 2009
@@ -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);

Modified: couchdb/trunk/share/www/script/futon.format.js
URL: http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/futon.format.js?rev=889856&r1=889855&r2=889856&view=diff
==============================================================================
--- couchdb/trunk/share/www/script/futon.format.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/futon.format.js [utf-8] Fri Dec 11 23:27:18 2009
@@ -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("");



Mime
View raw message