From a493da6b44285ab18e9625a9e1717aafc2ddf511 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Tue, 13 Sep 2016 17:21:51 -0400 Subject: [PATCH] make egAudio respect eg.audio.disable This patch also removes some console.debug noise. Signed-off-by: Galen Charlton Signed-off-by: Kathy Lussier --- Open-ILS/web/js/ui/default/staff/services/audio.js | 54 ++++++++++++---------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/Open-ILS/web/js/ui/default/staff/services/audio.js b/Open-ILS/web/js/ui/default/staff/services/audio.js index 1b88978e12..8cab8723f8 100644 --- a/Open-ILS/web/js/ui/default/staff/services/audio.js +++ b/Open-ILS/web/js/ui/default/staff/services/audio.js @@ -40,37 +40,41 @@ angular.module('egCoreMod') service.play_url = function(path, orig_path) { - var url = service.url_cache[path] || - service.base_url + path.replace(/\./g, '/') + '.wav'; + egHatch.getItem('eg.audio.disable').then(function(audio_disabled) { + if (!audio_disabled) { + + var url = service.url_cache[path] || + service.base_url + path.replace(/\./g, '/') + '.wav'; - var player = new Audio(url); + var player = new Audio(url); - player.onloadeddata = function() { - console.debug('Playing audio URL: ' + url); - service.url_cache[orig_path] = url; - player.play(); - }; + player.onloadeddata = function() { + service.url_cache[orig_path] = url; + player.play(); + }; - if (service.url_cache[path]) { - // when serving from the cache, avoid secondary URL lookups. - return; - } + if (service.url_cache[path]) { + // when serving from the cache, avoid secondary URL lookups. + return; + } - player.onerror = function() { - // Unable to play path at the requested URL. + player.onerror = function() { + // Unable to play path at the requested URL. - if (!path.match(/\./)) { - // all fall-through options have been exhausted. - // No path to play. - console.warn( - "No suitable URL found for path '" + orig_path + "'"); - return; - } + if (!path.match(/\./)) { + // all fall-through options have been exhausted. + // No path to play. + console.warn( + "No suitable URL found for path '" + orig_path + "'"); + return; + } - // Fall through to the next (more generic) option - path = path.replace(/\.[^\.]+$/, ''); - service.play_url(path, orig_path); - } + // Fall through to the next (more generic) option + path = path.replace(/\.[^\.]+$/, ''); + service.play_url(path, orig_path); + } + } + }); } return service; -- 2.11.0