couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cml...@apache.org
Subject svn commit: r700767 - in /incubator/couchdb/trunk/share/www: browse/database.html index.html script/browse.js script/jquery.cookies.js style/layout.css
Date Wed, 01 Oct 2008 13:52:59 GMT
Author: cmlenz
Date: Wed Oct  1 06:52:59 2008
New Revision: 700767

URL: http://svn.apache.org/viewvc?rev=700767&view=rev
Log:
Make the database list in the sidebar in Futon a list of the 10 most recently used databases,
to avoid excessive script/render time with instances containing very many databases.

Modified:
    incubator/couchdb/trunk/share/www/browse/database.html
    incubator/couchdb/trunk/share/www/index.html
    incubator/couchdb/trunk/share/www/script/browse.js
    incubator/couchdb/trunk/share/www/script/jquery.cookies.js
    incubator/couchdb/trunk/share/www/style/layout.css

Modified: incubator/couchdb/trunk/share/www/browse/database.html
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/browse/database.html?rev=700767&r1=700766&r2=700767&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/browse/database.html [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/browse/database.html [utf-8] Wed Oct  1 06:52:59 2008
@@ -32,6 +32,13 @@
       if (window != parent) {
         parent.updateNavigation(location.pathname,
           encodeURIComponent(location.search.split("/", 2)[0]));
+        var recentDbs = $.cookies.get("recent", "").split(",");
+        if ($.inArray(page.db.name, recentDbs) == -1) {
+          recentDbs.unshift(page.db.name);
+          if (recentDbs.length > 10) recentDbs.length = 10;
+          $.cookies.set("recent", recentDbs.join(","), parent.location.pathname);
+          parent.updateRecentDatabasesList();
+        }
       }
 
       $(document).ready(function() {

Modified: incubator/couchdb/trunk/share/www/index.html
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/index.html?rev=700767&r1=700766&r2=700767&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/index.html [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/index.html [utf-8] Wed Oct  1 06:52:59 2008
@@ -28,19 +28,17 @@
     </style>
     <script src="script/json2.js"></script>
     <script src="script/jquery.js?1.2.6"></script>
+    <script src="script/jquery.cookies.js?0.8.0"></script>
     <script src="script/jquery.couch.js?0.8.0"></script>
     <script>
-      function updateDatabaseList() {
-        var list = $("#dbs").empty();
-        var dbs = $.couch.allDbs({
-          success: function(dbs, status) {
-            for (var i = 0; i < dbs.length; i++) {
-              var dbName = dbs[i];
-              list.append("<li><a href='browse/database.html?" +
-                encodeURIComponent(dbName) + "' target='content'>" + dbName +
-                "</a></li>");
-            }
-          }
+      function updateRecentDatabasesList() {
+        $("#dbs").empty();
+        var recentDbs = $.cookies.get("recent", "").split(",");
+        recentDbs.sort();
+        $.each(recentDbs, function(idx, name) {
+          $("#dbs").append("<li><a href='browse/database.html?" +
+            encodeURIComponent(name) + "' target='content'>" + name +
+            "</a></li>");
         });
       }
       function updateNavigation(path, queryString) {
@@ -76,7 +74,7 @@
             $("#version").text(info.version);
           }
         });
-        updateDatabaseList();
+        updateRecentDatabasesList();
       });
     </script>
   </head>
@@ -91,7 +89,7 @@
         <li><a href="config.html" target="content">Configuration</a></li>
         <li><a href="couch_tests.html" target="content">Test Suite</a></li>
       </ul></li>
-      <li><span>Databases</span>
+      <li><span>Recent Databases</span>
         <ul id="dbs"></ul>
       </li>
     </ul>

Modified: incubator/couchdb/trunk/share/www/script/browse.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/script/browse.js?rev=700767&r1=700766&r2=700767&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/script/browse.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/script/browse.js [utf-8] Wed Oct  1 06:52:59 2008
@@ -26,7 +26,6 @@
         $.couch.db(data.name).create({
           error: function(status, id, reason) { callback({name: reason}) },
           success: function(resp) {
-            if (window !== parent) parent.setTimeout("updateDatabaseList()", 500);
             location.href = "database.html?" + encodeURIComponent(data.name);
             callback();
           }

Modified: incubator/couchdb/trunk/share/www/script/jquery.cookies.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/script/jquery.cookies.js?rev=700767&r1=700766&r2=700767&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/script/jquery.cookies.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/script/jquery.cookies.js [utf-8] Wed Oct  1 06:52:59
2008
@@ -15,7 +15,7 @@
   $.fn.extend($.cookies, {
 
     /* Return the value of a cookie. */
-    get: function(name) {
+    get: function(name, defaultValue) {
       var nameEq = name + "=";
       var parts = document.cookie.split(';');
       for (var i = 0; i < parts.length; i++) {
@@ -24,23 +24,26 @@
           return unescape(part.substring(nameEq.length, part.length));
         }
       }
-      return null;
+      return defaultValue !== undefined ? defaultValue : null;
     },
 
     /* Create or update a cookie. */
-    set: function(name, value, days) {
-      var expires = "";
+    set: function(name, value, path, days) {
+      var params = [];
+      if (path) {
+        params.push("; path=" + path);
+      }
       if (days) {
         var date = new Date();
         date.setTime(date.getTime() + (days * 24*60*60*1000));
-        expires = "; expires=" + date.toGMTString();
+        params.push("; expires=" + date.toGMTString());
       }
-      document.cookie = name + "=" + escape(value) + expires;
+      document.cookie = name + "=" + escape(value) + params.join();
     },
 
     /* Remove a cookie. */
-    remove: function(name) {
-      $.cookies.set(name, "", -1);
+    remove: function(name, path) {
+      $.cookies.set(name, "", path, -1);
     }
 
   });

Modified: incubator/couchdb/trunk/share/www/style/layout.css
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/style/layout.css?rev=700767&r1=700766&r2=700767&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/style/layout.css (original)
+++ incubator/couchdb/trunk/share/www/style/layout.css Wed Oct  1 06:52:59 2008
@@ -16,7 +16,7 @@
 /* General styles */
 
 html, body { background: transparent; color: #000;
-  font: normal 90% Arial,Helvetica,sans-serif; margin: 0;
+  font: normal 90% Arial,Helvetica,sans-serif; margin: 0; padding: 0;
 }
 :link, :visited { color: #ba1e16; text-decoration: none; }
 :link img, :visited img { border: none; }



Mime
View raw message