[open-ils-commits] r15021 - in trunk/Open-ILS/web: js/dojo/openils js/ui/default/circ/selfcheck templates/default/circ/selfcheck (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Nov 24 17:45:28 EST 2009
Author: erickson
Date: 2009-11-24 17:45:22 -0500 (Tue, 24 Nov 2009)
New Revision: 15021
Added:
trunk/Open-ILS/web/templates/default/circ/selfcheck/audio_config.tt2
Modified:
trunk/Open-ILS/web/js/dojo/openils/Util.js
trunk/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js
trunk/Open-ILS/web/templates/default/circ/selfcheck/main.tt2
Log:
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
Modified: trunk/Open-ILS/web/js/dojo/openils/Util.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/Util.js 2009-11-24 17:50:27 UTC (rev 15020)
+++ trunk/Open-ILS/web/js/dojo/openils/Util.js 2009-11-24 22:45:22 UTC (rev 15021)
@@ -256,6 +256,7 @@
* 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');
Modified: trunk/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js 2009-11-24 17:50:27 UTC (rev 15020)
+++ trunk/Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js 2009-11-24 22:45:22 UTC (rev 15021)
@@ -17,6 +17,7 @@
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 @@
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 @@
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 @@
// 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 @@
this.displayCheckout(result, 'renew');
}
+ sound = 'checkout-success';
this.updateScanBox();
} else if(result.textcode == 'OPEN_CIRCULATION_EXISTS' && action == 'checkout') {
@@ -574,12 +595,14 @@
}
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 @@
this.updateScanBox({select : true});
popup = true;
+ sound = 'checkout-failure';
if(result.length)
result = result[0];
@@ -646,13 +670,7 @@
}
}
- 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 {};
}
Added: trunk/Open-ILS/web/templates/default/circ/selfcheck/audio_config.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/circ/selfcheck/audio_config.tt2 (rev 0)
+++ trunk/Open-ILS/web/templates/default/circ/selfcheck/audio_config.tt2 2009-11-24 22:45:22 UTC (rev 15021)
@@ -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>
Modified: trunk/Open-ILS/web/templates/default/circ/selfcheck/main.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/circ/selfcheck/main.tt2 2009-11-24 17:50:27 UTC (rev 15020)
+++ trunk/Open-ILS/web/templates/default/circ/selfcheck/main.tt2 2009-11-24 22:45:22 UTC (rev 15021)
@@ -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>
More information about the open-ils-commits
mailing list