better, because we're not storing the hostname in constants.js
[Evergreen.git] / Open-ILS / xul / staff_client / chrome / content / util / sound.js
1 dump('entering util/sound.js\n');
2
3 if (typeof util == 'undefined') util = {};
4 util.sound = function () {
5
6         try {
7                 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
8                 var SOUNDContractID = "@mozilla.org/sound;1";
9                 var SOUNDIID        = Components.interfaces.nsISound;
10                 this.SOUND          = Components.classes[SOUNDContractID].createInstance(SOUNDIID);
11
12         } catch(E) {
13                 dump('util.sound constructor: ' + E + '\n');
14         }
15
16         return this;
17 };
18
19 util.sound.prototype = {
20
21         'xp_url_init' : function (aURL) {
22                 try {
23                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
24                         var URLContractID   = "@mozilla.org/network/standard-url;1";
25                         var URLIID          = Components.classes[URLContractID].createInstance( );
26                         var URL             = URLIID.QueryInterface(Components.interfaces.nsIURL);
27                         if (aURL) {
28                                 URL.spec = aURL;
29                         }
30                         return URL;
31                 } catch(E) {
32                         alert('xp_url_init(): ' + E);
33                 }
34         },
35
36         'play_url' : function(url) {
37
38                 try {
39                         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
40                         var obj = this;
41                         JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
42                         var url2 = obj.xp_url_init( data.server + url );
43                         dump('url = ' + url2 + '\n');
44                         obj.SOUND.play( url2 );
45                 } catch(E) {
46                         alert('play_url(): ' + E);
47                 }
48         },
49
50         'good' : function(e){
51                 this.play_url( urls.AUDIO_GOOD_SOUND );
52         },
53
54         'bad' : function(e){
55                 this.play_url( urls.AUDIO_BAD_SOUND );
56         },
57
58         'horrible' : function(e){
59                 this.play_url( urls.AUDIO_HORRIBLE_SOUND );
60         },
61
62         'circ_good' : function(e){
63                 this.play_url( urls.AUDIO_CIRC_GOOD_SOUND );
64         },
65
66         'circ_bad' : function(e){
67                 this.play_url( urls.AUDIO_CIRC_BAD_SOUND );
68         },
69 }
70
71 dump('exiting util/sound.js\n');