From 4ba6c45f37e43dbd7cb54e0486f6576002291fc0 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Tue, 9 Oct 2018 10:47:11 -0300
Subject: [PATCH] Bug 15734: Use To.json to filter audio alerts

Test Plan:
1) Enable audio alerts
2) Note audio alerts don't work
3) Apply this patch
4) Note audio alerts now work

Use complex selectors to test:
  #circ_returns p.problem:contains('Not checked out.')
  #doc3 > #bd

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
---
 koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc
index 046c7d5..6c02936 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc
@@ -1,6 +1,7 @@
 [% USE raw %]
 [% USE Asset %]
 [% USE AudioAlerts %]
+[% USE To %]
 [%# Prevent XFS attacks -%]
 [% UNLESS popup %]
     <script type="text/javascript">
@@ -70,7 +71,7 @@
     <script type="text/javascript">
         //<![CDATA[
             var AUDIO_ALERT_PATH = '[% interface | html %]/[% theme | html %]/sound/';
-            var AUDIO_ALERTS = JSON.parse( '[% AudioAlerts.AudioAlerts | replace( "'", "\\'" ) | replace( '"', '\\"' ) | html %]' );
+            var AUDIO_ALERTS = JSON.parse( "[% To.json(AudioAlerts.AudioAlerts) | $raw %]" );
         //]]>
 
         $( document ).ready(function() {
-- 
2.1.4