From 99f6116f3595f4d58307fc3249f3be98550d99a9 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 15 Aug 2016 19:58:52 +0000 Subject: [PATCH] Bug 16732 - Add audio alerts (custom sound notifications) to web based self checkout This patch adds the infrastructure needed to allow audio alerts, as configured in administration, to affect the sco module This patch allows only for the use of sounds with a full URL to be used and does not allow for the Koha standard sounds to be accessed via the SCO To test: Ensure you have the preference AudioAlerts enabled Ensure you can hear normal sounds from the staff module Define an audio alert such as: Selector: .sco_entry Sound: https://archive.org/download/Doorbell_1/doorbell.ogg Load the SCO module You should hear the doorbell noise (everytime you reload even!) Test that the default sounds are not activated for the SCO, you must sepcifically define them Signed-off-by: Owen Leonard Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall --- .../opac-tmpl/bootstrap/en/modules/sco/sco-main.tt | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt index 42d25083e9..11147ae3e6 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt @@ -1,5 +1,6 @@ [% USE Koha %] [% USE KohaDates %] +[% USE AudioAlerts %] [% INCLUDE 'doc-head-open.inc' %] [% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha [% END %] › Self checkout @@ -315,6 +316,8 @@ + + [% INCLUDE 'opac-bottom.inc' %] [% BLOCK jsinclude %] @@ -353,6 +356,26 @@ } return true; } + [% IF Koha.Preference('AudioAlerts') %] + var AUDIO_ALERTS = JSON.parse( '[% AudioAlerts.AudioAlerts | replace( "'", "\\'" ) | replace( '"', '\\"' ) %]' ); + $( document ).ready(function() { + if ( AUDIO_ALERTS ) { + for ( var k in AUDIO_ALERTS ) { + var alert = AUDIO_ALERTS[k]; + if ( $( alert.selector ).length ) { + playSound( alert.sound ); + break; + } + } + } + }); + function playSound( sound ) { + if ( ( sound.indexOf('http://') == 0 || sound.indexOf('https://') == 0 ) ) { + document.getElementById("audio-alert").innerHTML = ''; + } + } + [% END %] + $(document).ready(function() { dofocus(); -- 2.11.4.GIT