Bug 9419: The highlight feature can cause a browser freeze
authorJonathan Druart <jonathan.druart@biblibre.com>
Thu, 17 Jan 2013 15:52:18 +0000 (16:52 +0100)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Sat, 30 Mar 2013 12:03:07 +0000 (08:03 -0400)
Test plan:
- switch on the OpacHighlightedWords syspref
- search at the opac and intranet a string with a space (e.g.
  au,wrdl:"Shakespeare,  William" note the double space after the comma)
- without the patch your browser will be frozen during a few seconds,
  after applying it, the highlight works better.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt
koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt

index b5035c9..1b20b07 100644 (file)
@@ -134,7 +134,9 @@ $('#sort_by').change(function() {
 function highlightOn() {
     var x;
     for (x in q_array) {
-        toHighlight.highlight(q_array[x]);
+        if ( q_array[x].length > 0 ) {
+            toHighlight.highlight(q_array[x]);
+        }
     }
     $(".highlight_toggle").toggle();
 }[% END %]
index 0986616..9f0b044 100644 (file)
@@ -95,9 +95,11 @@ function highlightOff() {
 function highlightOn() {
     var x;
     for (x in q_array) {
-        $(".title").highlight(q_array[x]);
-        $(".author").highlight(q_array[x]);
-        $(".results_summary").highlight(q_array[x]);
+        if ( q_array[x].length > 0 ) {
+            $(".title").highlight(q_array[x]);
+            $(".author").highlight(q_array[x]);
+            $(".results_summary").highlight(q_array[x]);
+        }
     }
     $(".highlight_toggle").toggle();
 }