From 824e2221bd283245d2e8d84a0b96cf14177644d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20V=C3=A9ron?= Date: Wed, 19 Nov 2014 11:40:39 +0100 Subject: [PATCH] Bug 10956 - Series of OPAC searches can cause a browser crash This patch fixes the issue for bootstrap. It was earlier fixed for the prog theme. Solution: Prevent jQuery.fn.highlight = function(pat) to be called with empty pat by skipping empty values in highlight loop. To test: Without patch, do a search as in comment #1 odr #3 Result: Endless loop (Script not responding) Appply patch: No endless loop, page displays OK --- .../opac-tmpl/bootstrap/en/modules/opac-detail.tt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index e641d76..7d1975a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -1344,13 +1344,15 @@ function highlightOn() { var x; for (x in q_array) { - q_array[x] = q_array[x].replace(/\w*:([\w])/, "$1"); - q_array[x] = q_array[x].toLowerCase(); - var myStopwords = "[% Koha.Preference('NotHighlightedWords') %]".toLowerCase().split('|'); - if( $.inArray(q_array[x], myStopwords) == -1 ) { - $(".title").highlight(q_array[x]); - $(".author").highlight(q_array[x]); - $(".results_summary").highlight(q_array[x]); + if ( q_array[x].length > 0 ) { + q_array[x] = q_array[x].replace(/\w*:([\w])/, "$1"); + q_array[x] = q_array[x].toLowerCase(); + var myStopwords = "[% Koha.Preference('NotHighlightedWords') %]".toLowerCase().split('|'); + if( $.inArray(q_array[x], myStopwords) == -1 ) { + $(".title").highlight(q_array[x]); + $(".author").highlight(q_array[x]); + $(".results_summary").highlight(q_array[x]); + } } } $(".highlight_toggle").toggle(); -- 1.7.10.4