From 90171440292d48027513f5062966f68c3abc4bbd Mon Sep 17 00:00:00 2001 From: pines Date: Thu, 14 Sep 2006 18:57:32 +0000 Subject: [PATCH] pref for disabling sound git-svn-id: svn://svn.open-ils.org/ILS/trunk@6106 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../staff_client/chrome/content/OpenILS/data.js | 14 ++++++++++ .../xul/staff_client/chrome/content/util/sound.js | 9 ++++--- .../staff_client/server/admin/font_settings.xul | 31 ++++++++++++++++++++++ Open-ILS/xul/staff_client/server/admin/index.xhtml | 2 +- 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js b/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js index ac95cf870d..258df90bf7 100644 --- a/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js +++ b/Open-ILS/xul/staff_client/chrome/content/OpenILS/data.js @@ -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'); diff --git a/Open-ILS/xul/staff_client/chrome/content/util/sound.js b/Open-ILS/xul/staff_client/chrome/content/util/sound.js index ef6f671c8e..13f169a838 100644 --- a/Open-ILS/xul/staff_client/chrome/content/util/sound.js +++ b/Open-ILS/xul/staff_client/chrome/content/util/sound.js @@ -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){ diff --git a/Open-ILS/xul/staff_client/server/admin/font_settings.xul b/Open-ILS/xul/staff_client/server/admin/font_settings.xul index 014fcf42bd..55bfcab17d 100644 --- a/Open-ILS/xul/staff_client/server/admin/font_settings.xul +++ b/Open-ILS/xul/staff_client/server/admin/font_settings.xul @@ -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); } @@ -69,9 +70,39 @@ } } + 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); } + } + } + ]]> + + + + +