Bug 42292: (QA follow-up) Fix evaluation of OpacHighlightedWords to be numeric in opac-results

OpacHighlightedWords was set in quotation marks and resulted in either "1" or "0".
As "0" and "1" always evaluates to true in JS the following error was thrown when OpacHighlightedWords was set to Don't highlight: Uncaught TypeError: $(...).highlight is not a function

To test:
a) Set system preference OpacHighlightedWords to Don't highlight
b) search a title in the opac with open dev console and check that no error (like above) is thrown.

Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Jan Kissig 2026-06-24 09:14:42 +00:00 committed by Pedro Amorim
parent 71b121bb6f
commit 87d4eac98e
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
1 changed files with 1 additions and 1 deletions

View File

@ -488,7 +488,7 @@
var theme = "[% theme | html %]";
const firstPage = [% firstPage ? 1 : 0 | html %];
Koha.addPrefs({
OpacHighlightedWords: "[% Koha.Preference('OpacHighlightedWords') | html %]",
OpacHighlightedWords: [% Koha.Preference('OpacHighlightedWords') ? 1 : 0 | html %],
NotHighlightedWords: "[% Koha.Preference("NotHighlightedWords") | html %]",
GoogleJackets: [% Koha.Preference("GoogleJackets") ? 1 : 0 | html %],
OpenLibraryCovers: [% Koha.Preference("OpenLibraryCovers") ? 1 : 0 | html %],