From 6718f404cbe8c73b31e53ba23f5c6a0aab1f407b Mon Sep 17 00:00:00 2001 From: phasefx Date: Mon, 6 Feb 2006 20:55:33 +0000 Subject: [PATCH] better. prevent window name/id collissions git-svn-id: svn://svn.open-ils.org/ILS/trunk@2988 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../staff_client/chrome/content/main/menu.js | 2 +- .../chrome/content/util/window.js | 28 +++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu.js b/Open-ILS/xul/staff_client/chrome/content/main/menu.js index a21dfee435..b98478bed2 100644 --- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js +++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js @@ -44,7 +44,7 @@ main.menu.prototype = { + '?session='+window.escape(session) + '&authtime='+window.escape(authtime) + '&server='+window.escape(urls.remote), - 'test' + obj.window.appshell_name_increment(), + 'main' + obj.window.window_name_increment(), 'chrome,resizable'); } ], diff --git a/Open-ILS/xul/staff_client/chrome/content/util/window.js b/Open-ILS/xul/staff_client/chrome/content/util/window.js index 1b3d4218ca..6536ae00c2 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/window.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/window.js @@ -18,17 +18,27 @@ util.window.prototype = { 'doc_list' : [], // Windows need unique names. This number helps. - 'window_name_increment' : 0, + 'window_name_increment' : function() { + JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); + if (typeof data.appshell_name_increment == 'undefined') { + data.window_name_increment = 1; + } else { + data.window_name_increment++; + } + data.stash('window_name_increment'); + return data.window_name_increment; + }, // This number gets put into the title bar for Top Level menu interface windows 'appshell_name_increment' : function() { - var windowManager = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(); - var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator); - var enumerator = windowManagerInterface.getEnumerator(null); - - var i = 0; while ( w = enumerator.getNext() ) { i++; } - - return i - 1; + JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); + if (typeof data.appshell_name_increment == 'undefined') { + data.appshell_name_increment = 1; + } else { + data.appshell_name_increment++; + } + data.stash('appshell_name_increment'); + return data.appshell_name_increment; }, // From: Bryan White on netscape.public.mozilla.xpfe, Oct 13, 2004 @@ -63,7 +73,7 @@ util.window.prototype = { 'open' : function(url,title,features) { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); - if (!title) title = 'anon' + window_name_increment++; + if (!title) title = 'anon' + window_name_increment(); if (!features) features = 'chrome'; this.error.sdump('D_WIN', 'opening ' + url + ', ' + title + ', ' + features + ' from ' + this.win + '\n'); -- 2.43.2