diff --git a/js/ajax.js b/js/ajax.js index ef3e2378c0..e8126a41aa 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -334,6 +334,7 @@ var AJAX = { }; AJAX.cache = { + MAX: 6, /** * An array used to prime the cache with data about the initially * loaded page. This is set in the footer, and then loaded @@ -343,8 +344,16 @@ AJAX.cache = { pages: [], current: 0, add: function (hash, scripts, menu) { + if (this.pages.length > AJAX.cache.MAX) { + // Trim the cache, to the maximum number of allowed entries + // This way we will have a cached menu for every page + for (var i=0; i this.pages.length) { - alert('The requested page was not found in the history'); + if (typeof this.pages[index] === 'undefined') { + PMA_ajaxShowMessage( + 'The requested page was not found in the history' // FIXME: l10n + ); } else { this.update(); AJAX.active = true; @@ -400,13 +410,11 @@ AJAX.cache = { }, data: {}, add: function (hash, content) { - //console.log(this.size(this.data)) - if (this.size(this.data) > 6) { + if (this.size(this.data) > AJAX.cache.MAX) { // when the cache grows, we remove the oldest entry var oldest, key, init = 0; for (var i in this.data) { if (this.data[i]) { - // console.log(this.data[i].timestamp, oldest) if (! init || this.data[i].timestamp.getTime() < oldest.getTime()) { oldest = this.data[i].timestamp; key = i;