pref for disabling sound
authorpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 14 Sep 2006 18:57:32 +0000 (18:57 +0000)
committerpines <pines@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 14 Sep 2006 18:57:32 +0000 (18:57 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@6106 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js
Open-ILS/xul/staff_client/chrome/content/util/sound.js
Open-ILS/xul/staff_client/server/admin/font_settings.xul
Open-ILS/xul/staff_client/server/admin/index.xhtml

index ac95cf8..258df90 100644 (file)
@@ -261,6 +261,20 @@ OpenILS.data.prototype = {
                }
                file.close();
 
+               JSAN.use('util.file'); var file = new util.file('no_sound');
+               if (file._file.exists()) {
+                       try {
+                               var x = file.get_content();
+                               if (x) {
+                                       obj.no_sound = x;
+                                       obj.stash('no_sound');
+                               }
+                       } catch(E) {
+                               alert(E);
+                       }
+               }
+               file.close();
+
                JSAN.use('util.functional');
                JSAN.use('util.fm_utils');
 
index ef6f671..13f169a 100644 (file)
@@ -35,17 +35,20 @@ util.sound.prototype = {
 
        'play_url' : function(url) {
 
+               var obj = this;
                try {
                        netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-                       var obj = this;
                        JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'});
                        var url2 = obj.xp_url_init( data.server + url );
                        dump('url = ' + url2 + '\n');
-                       obj.SOUND.play( url2 );
+                       if (typeof data.no_sound == 'undefined' || data.no_sound == false || data.no_sound == 'false') obj.SOUND.play( url2 );
                } catch(E) {
-                       obj.SOUND.beep();
+                       try { if (data.no_sound == 'undefined' || data.no_sound == false || data.no_sound == 'false') obj.SOUND.beep(); } catch(F) { 
+                               dump('beep(): ' + F + '\n');
+                       }
                        dump('play_url(): ' + E + '\n');
                }
+
        },
 
        'good' : function(e){
index 014fcf4..55bfcab 100644 (file)
@@ -42,6 +42,7 @@
                                g.error.sdump('D_TRACE','my_init() for font_settings.xul');
 
                                JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.stash_retrieve();
+                               document.getElementById('sound').checked = typeof g.data.no_sound == 'undefined' || g.data.no_sound == 'false' || g.data.no_sound == false ? false : true;
 
                        } catch(E) {
                                try { g.error.standard_unexpected_error_alert('admin/font_settings.xul',E); } catch(F) { alert(E); }
                        }
                }
 
+               function toggle_sound() {
+                       try {
+                               var bool = document.getElementById('sound').checked;
+                               g.data.no_sound = bool; g.data.stash('no_sound');
+                               alert('Sound is now ' + (bool ? ' disabled.' : ' enabled.') ); 
+                       } catch(E) {
+                               try { g.error.standard_unexpected_error_alert('setting sound in admin/font_settings.xul',E); } catch(F) { alert(E); }
+                       }
+               }
+
+               function save_sound() {
+                       try {
+                               netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+                               JSAN.use('util.file'); var file = new util.file('no_sound');
+                               file.write_content( 'truncate', String( document.getElementById('sound').checked ) );
+                               file.close();
+                               alert('Sound preference saved to file system.');
+                       } catch(E) {
+                               try { g.error.standard_unexpected_error_alert('saving in admin/font_settings.xul',E); } catch(F) { alert(E); }
+                       }
+               }
+
        ]]>
        </script>
 
+       <groupbox orient="vertical">
+               <caption label="Adjust Sound"/>
+               <hbox>
+                       <checkbox id="sound" label="Disable sound?" oncommand="toggle_sound();"/>
+                       <button label='Save to Disk' oncommand="save_sound();"/>
+               </hbox>
+       </groupbox>
+
        <groupbox>
                <caption label="Adjust Global Font"/>
                <hbox>
index 681d884..b789fdf 100644 (file)
@@ -31,7 +31,7 @@
                                        <tr valign="top">
                                                <td>
                                                        <div style='padding: 8px;'>
-                                                               <a href='javascript:_l("font_settings.xul");'>Global Font Settings</a>
+                                                               <a href='javascript:_l("font_settings.xul");'>Global Font and Sound Settings</a>
                                                        </div>
                                                        <div style='padding: 8px;'>
                                                                <a href='javascript:_l("printer_settings.html");'>Printer Settings Editor</a>