From 3e7a05250dcee52e87cfbeea08b3de472499030e Mon Sep 17 00:00:00 2001 From: erickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4> Date: Tue, 24 Nov 2009 22:45:22 +0000 Subject: [PATCH] plugged in audio alerts for selfcheck. local config is managed by TT path overriding. at least until there's a need to make it fancier. TODO: add the org setting that turns on audio alerts for selfcheck git-svn-id: svn://svn.open-ils.org/ILS/trunk@15021 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/openils/Util.js | 1 + .../web/js/ui/default/circ/selfcheck/selfcheck.js | 44 +++++++++++++++------- .../default/circ/selfcheck/audio_config.tt2 | 13 +++++++ .../web/templates/default/circ/selfcheck/main.tt2 | 1 + 4 files changed, 46 insertions(+), 13 deletions(-) create mode 100644 Open-ILS/web/templates/default/circ/selfcheck/audio_config.tt2 diff --git a/Open-ILS/web/js/dojo/openils/Util.js b/Open-ILS/web/js/dojo/openils/Util.js index b9e4a492c5..ce89904edd 100644 --- a/Open-ILS/web/js/dojo/openils/Util.js +++ b/Open-ILS/web/js/dojo/openils/Util.js @@ -256,6 +256,7 @@ if(!dojo._hasResource["openils.Util"]) { * that support HTML 5 <audio> element. E.g. Firefox 3.5 */ openils.Util.playAudioUrl = function(urlString) { + if(!urlString) return; var audio = document.createElement('audio'); audio.setAttribute('src', urlString); audio.setAttribute('autoplay', 'true'); diff --git a/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js b/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js index cb14b4e6dc..483fc37b69 100644 --- a/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js +++ b/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js @@ -17,6 +17,7 @@ const SET_AUTO_OVERRIDE_EVENTS = 'circ.selfcheck.auto_override_checkout_events'; const SET_PATRON_PASSWORD_REQUIRED = 'circ.selfcheck.patron_password_required'; const SET_AUTO_RENEW_INTERVAL = 'circ.checkout_auto_renew_age'; const SET_WORKSTATION_REQUIRED = 'circ.selfcheck.workstation_required'; +const SET_SOUND_ON_CHECKOUT_EVENT = 'circ.selfcheck.sound_on_checkout_event'; //openils.Util.playAudioUrl('/xul/server/skin/media/audio/bonus.wav'); @@ -179,8 +180,10 @@ SelfCheckManager.prototype.loginPatron = function(barcode, passwd) { if(res == 0) { // user-not-found results in login failure - dojo.byId('oils-selfck-status-div').innerHTML = - dojo.string.substitute(localeStrings.LOGIN_FAILED, [barcode]); + this.handleAlert( + dojo.string.substitute(localeStrings.LOGIN_FAILED, [barcode]), + false, 'login-failure' + ); this.drawLoginPage(); return; } @@ -194,20 +197,35 @@ SelfCheckManager.prototype.loginPatron = function(barcode, passwd) { var evt = openils.Event.parse(this.patron); if(evt) { - - dojo.byId('oils-selfck-status-div').innerHTML = - dojo.string.substitute(localeStrings.LOGIN_FAILED, [barcode]); + this.handleAlert( + dojo.string.substitute(localeStrings.LOGIN_FAILED, [barcode]), + false, 'login-failure' + ); this.drawLoginPage(); } else { - dojo.byId('oils-selfck-status-div').innerHTML = ''; + this.handleAlert('', false, 'login-success'); dojo.byId('oils-selfck-user-banner').innerHTML = 'Welcome, ' + this.patron.usrname(); // TODO i18n this.drawCircPage(); } } +SelfCheckManager.prototype.handleAlert = function(message, shouldPopup, sound) { + + console.log("Handling alert " + message); + + dojo.byId('oils-selfck-status-div').innerHTML = message; + + if(shouldPopup && this.orgSettings[SET_ALERT_ON_CHECKOUT_EVENT]) + alert(message); + + if(sound && this.orgSettings[SET_SOUND_ON_CHECKOUT_EVENT]) + openils.Util.playAudioUrl(SelfCheckManager.audioConfig[sound]); +} + + /** * Manages the main input box * @param msg The context message to display with the box @@ -522,6 +540,8 @@ SelfCheckManager.prototype.handleXactResult = function(action, item, result) { // an alert() actually occurs, depends on org unit settings var popup = false; + var sound = ''; + // TODO handle lost/missing/etc checkin+checkout override steps var payload = result.payload || {}; @@ -552,6 +572,7 @@ SelfCheckManager.prototype.handleXactResult = function(action, item, result) { this.displayCheckout(result, 'renew'); } + sound = 'checkout-success'; this.updateScanBox(); } else if(result.textcode == 'OPEN_CIRCULATION_EXISTS' && action == 'checkout') { @@ -574,12 +595,14 @@ SelfCheckManager.prototype.handleXactResult = function(action, item, result) { } popup = true; + sound = 'checkout-failure'; displayText = dojo.string.substitute(localeStrings.ALREADY_OUT, [item]); } else { // item is checked out to some other user popup = true; + sound = 'checkout-failure'; displayText = dojo.string.substitute(localeStrings.OPEN_CIRCULATION_EXISTS, [item]); } @@ -612,6 +635,7 @@ SelfCheckManager.prototype.handleXactResult = function(action, item, result) { this.updateScanBox({select : true}); popup = true; + sound = 'checkout-failure'; if(result.length) result = result[0]; @@ -646,13 +670,7 @@ SelfCheckManager.prototype.handleXactResult = function(action, item, result) { } } - console.log("Updating status with " + displayText); - - dojo.byId('oils-selfck-status-div').innerHTML = displayText; - - if(popup && this.orgSettings[SET_ALERT_ON_CHECKOUT_EVENT]) - alert(displayText); - + this.handleAlert(displayText, popup, sound); return {}; } diff --git a/Open-ILS/web/templates/default/circ/selfcheck/audio_config.tt2 b/Open-ILS/web/templates/default/circ/selfcheck/audio_config.tt2 new file mode 100644 index 0000000000..1f8b957099 --- /dev/null +++ b/Open-ILS/web/templates/default/circ/selfcheck/audio_config.tt2 @@ -0,0 +1,13 @@ +[%# + Override the audio config values by copying this template into your local templates + directory (matching the relative path) and change the values accordingly. +#%] + +<script> + SelfCheckManager.audioConfig = { + 'login-success' : '', + 'login-failure' : '[% ctx.media_prefix %]/audio/circ/question.wav', + 'checkout-success' : '[% ctx.media_prefix %]/audio/circ/bonus.wav', + 'checkout-failure' : '[% ctx.media_prefix %]/audio/circ/question.wav', + } +</script> diff --git a/Open-ILS/web/templates/default/circ/selfcheck/main.tt2 b/Open-ILS/web/templates/default/circ/selfcheck/main.tt2 index 0a9031c67e..98751c0ee5 100644 --- a/Open-ILS/web/templates/default/circ/selfcheck/main.tt2 +++ b/Open-ILS/web/templates/default/circ/selfcheck/main.tt2 @@ -2,6 +2,7 @@ [% WRAPPER default/base.tt2 %] <script src='[% ctx.media_prefix %]/js/ui/default/circ/selfcheck/selfcheck.js'> </script> <link rel='stylesheet' type='text/css' href='[% ctx.media_prefix %]/css/skin/[% ctx.skin %]/selfcheck.css'></link> +[% INCLUDE 'default/circ/selfcheck/audio_config.tt2' %] <div id='oils-selfck-top-div'> <div id='oils-selfck-user-banner'></div> -- 2.11.0