[open-ils-commits] r16280 - in trunk/Open-ILS/xul/staff_client/chrome/content: main util (phasefx)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Apr 20 11:19:21 EDT 2010


Author: phasefx
Date: 2010-04-20 11:19:18 -0400 (Tue, 20 Apr 2010)
New Revision: 16280

Modified:
   trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js
   trunk/Open-ILS/xul/staff_client/chrome/content/util/sound.js
Log:
reduce proliferation of nsISound instances


Modified: trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js	2010-04-20 14:12:58 UTC (rev 16279)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/main/menu.js	2010-04-20 15:19:18 UTC (rev 16280)
@@ -10,6 +10,7 @@
     offlineStrings = document.getElementById('offlineStrings');
     JSAN.use('util.error'); this.error = new util.error();
     JSAN.use('util.window'); this.window = new util.window();
+    JSAN.use('util.sound'); this.sound = new util.sound();
 
     this.w = window;
     var x = document.getElementById('network_progress');
@@ -1481,6 +1482,7 @@
             if (e) { e.setAttribute('label',text); }
         };
         content_params.chrome_xulG = xulG;
+        content_params._sound = xulG._sound;
         if (params && params.tab_name) content_params.set_tab_name( params.tab_name );
         
         var frame;

Modified: trunk/Open-ILS/xul/staff_client/chrome/content/util/sound.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/util/sound.js	2010-04-20 14:12:58 UTC (rev 16279)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/util/sound.js	2010-04-20 15:19:18 UTC (rev 16280)
@@ -4,17 +4,24 @@
 util.sound = function () {
 
     try {
+
+        /* We're going to turn this guy into a singleton, at least for a given window, and look for it in xulG */
+        if (! window.xulG) { window.xulG = {}; }
+        if (window.xulG._sound) { return window.xulG._sound; }
+
         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
         var SOUNDContractID = "@mozilla.org/sound;1";
         var SOUNDIID        = Components.interfaces.nsISound;
         this.SOUND          = Components.classes[SOUNDContractID].createInstance(SOUNDIID);
         this.SOUND.init(); // not necessary, but helps avoid delays?
 
+        window.xulG._sound = this;
+        return this;
+
     } catch(E) {
-        dump('util.sound constructor: ' + E + '\n');
+        dump('error in util.sound constructor: ' + E + '\n');
+        return this;
     }
-
-    return this;
 };
 
 util.sound.prototype = {



More information about the open-ils-commits mailing list