re-introducing sound effects. Need to put them everywhere :)
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 14 Mar 2006 05:06:36 +0000 (05:06 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 14 Mar 2006 05:06:36 +0000 (05:06 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@3352 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/chrome/content/util/error.js
Open-ILS/xul/staff_client/chrome/content/util/sound.js [new file with mode: 0644]

index 5720499..3ab929b 100644 (file)
@@ -66,10 +66,20 @@ var api = {
 }
 
 var urls = {
+
+       'remote' : 'http://dev.gapines.org/',
+
        'opac' : '/opac/en-US/skin/default/xml/advanced.xml',
        'opac_rdetail' : '/opac/en-US/skin/default/xml/rdetail.xml',
        'browser' : '/opac/en-US/skin/default/xml/advanced.xml',
        'fieldmapper' : '/opac/common/js/fmall.js',
+
+       'AUDIO_GOOD_SOUND' : '/xul/server/skin/media/audio/bonus.wav',
+       'AUDIO_BAD_SOUND' : '/xul/server/skin/media/audio/question.wav',
+       'AUDIO_HORRIBLE_SOUND' : '/xul/server/skin/media/audio/redalert.wav',
+       'AUDIO_CIRC_GOOD_SOUND' : '/xul/server/skin/media/audio/toggled.wav',
+       'AUDIO_CIRC_BAD_SOUND' : '/xul/server/skin/media/audio/question.wav',
+
        'XUL_ADV_USER_BARCODE_ENTRY' : '/xul/server/patron/adv_barcode_entry.xul',
        'XUL_BIB_BRIEF' : '/xul/server/cat/bib_brief.xul',
        'XUL_BROWSER' : 'chrome://open_ils_staff_client/content/util/browser.xul',
index cb2ff16..fccfaac 100644 (file)
@@ -16,6 +16,8 @@ util.error = function () {
 
        this.OpenILS = {};
 
+       JSAN.use('util.sound'); this.sound = new util.sound();
+
        return this;
 };
 
@@ -215,6 +217,8 @@ util.error.prototype = {
 
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
+               this.sound.bad();
+
                // get a reference to the prompt service component.
                var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
                        .getService(Components.interfaces.nsIPromptService);
diff --git a/Open-ILS/xul/staff_client/chrome/content/util/sound.js b/Open-ILS/xul/staff_client/chrome/content/util/sound.js
new file mode 100644 (file)
index 0000000..4d22199
--- /dev/null
@@ -0,0 +1,70 @@
+dump('entering util/sound.js\n');
+
+if (typeof util == 'undefined') util = {};
+util.sound = function () {
+
+       try {
+               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+               var SOUNDContractID = "@mozilla.org/sound;1";
+               var SOUNDIID        = Components.interfaces.nsISound;
+               this.SOUND          = Components.classes[SOUNDContractID].createInstance(SOUNDIID);
+
+       } catch(E) {
+               dump('util.sound constructor: ' + E + '\n');
+       }
+
+       return this;
+};
+
+util.sound.prototype = {
+
+       'xp_url_init' : function (aURL) {
+               try {
+                       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+                       var URLContractID   = "@mozilla.org/network/standard-url;1";
+                       var URLIID          = Components.classes[URLContractID].createInstance( );
+                       var URL             = URLIID.QueryInterface(Components.interfaces.nsIURL);
+                       if (aURL) {
+                               URL.spec = aURL;
+                       }
+                       return URL;
+               } catch(E) {
+                       alert('xp_url_init(): ' + E);
+               }
+       },
+
+       'play_url' : function(url) {
+
+               try {
+                       netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
+                       var obj = this;
+                       var url2 = obj.xp_url_init( urls.remote + url );
+                       dump('url = ' + url2 + '\n');
+                       obj.SOUND.play( url2 );
+               } catch(E) {
+                       alert('play_url(): ' + E);
+               }
+       },
+
+       'good' : function(e){
+               this.play_url( urls.AUDIO_GOOD_SOUND );
+       },
+
+       'bad' : function(e){
+               this.play_url( urls.AUDIO_BAD_SOUND );
+       },
+
+       'horrible' : function(e){
+               this.play_url( urls.AUDIO_HORRIBLE_SOUND );
+       },
+
+       'circ_good' : function(e){
+               this.play_url( urls.AUDIO_CIRC_GOOD_SOUND );
+       },
+
+       'circ_bad' : function(e){
+               this.play_url( urls.AUDIO_CIRC_BAD_SOUND );
+       },
+}
+
+dump('exiting util/sound.js\n');