From 57f2e6a118dc57af6dbd6c377b60bae7fdcd3d22 Mon Sep 17 00:00:00 2001 From: Christopher Lenz Date: Wed, 1 Oct 2008 13:52:59 +0000 Subject: 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. git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@700767 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/browse/database.html | 7 +++++++ share/www/index.html | 24 +++++++++++------------- share/www/script/browse.js | 1 - share/www/script/jquery.cookies.js | 19 +++++++++++-------- share/www/style/layout.css | 2 +- 5 files changed, 30 insertions(+), 23 deletions(-) diff --git a/share/www/browse/database.html b/share/www/browse/database.html index 0dd086db..fe17a47b 100644 --- a/share/www/browse/database.html +++ b/share/www/browse/database.html @@ -32,6 +32,13 @@ specific language governing permissions and limitations under the License. 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() { diff --git a/share/www/index.html b/share/www/index.html index 54cc9e15..b6919b93 100644 --- a/share/www/index.html +++ b/share/www/index.html @@ -28,19 +28,17 @@ specific language governing permissions and limitations under the License. + @@ -91,7 +89,7 @@ specific language governing permissions and limitations under the License.
  • Configuration
  • Test Suite
  • -
  • Databases +
  • Recent Databases
  • diff --git a/share/www/script/browse.js b/share/www/script/browse.js index 82f9eeff..6abcb073 100644 --- a/share/www/script/browse.js +++ b/share/www/script/browse.js @@ -26,7 +26,6 @@ function CouchIndexPage() { $.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(); } diff --git a/share/www/script/jquery.cookies.js b/share/www/script/jquery.cookies.js index a2817461..77c5e0a9 100644 --- a/share/www/script/jquery.cookies.js +++ b/share/www/script/jquery.cookies.js @@ -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); } }); diff --git a/share/www/style/layout.css b/share/www/style/layout.css index 7b0aeb04..db86acc3 100644 --- a/share/www/style/layout.css +++ b/share/www/style/layout.css @@ -16,7 +16,7 @@ specific language governing permissions and limitations under the License. /* 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; } -- cgit v1.2.3