Bug 25639: Add search query strings as global javascript variables

To test:
1 - Search on OPAC for "qwertyuiop"
2 - View the HTML source
3 - Find 'qwertyuiop' in the source, it is not easily accessible via JS
4 - Apply patch
5 - Repeat
6 - Note that now there are global variables with the query strings
7 - Add to OpacUserJs:
    console.log( query_desc );
    console.log( querystring );
    console.log( query_cgi );
8 - Reload page and confirm variables are warned in the JS console (Press F12)
9 - Sign off

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
(cherry picked from commit cf93255428)

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Nick Clemens 2020-07-29 10:56:37 +00:00 committed by Lucas Gass
parent b8d9d6242d
commit 4a2e76d83a
2 changed files with 6 additions and 2 deletions

View File

@ -180,6 +180,12 @@ $.widget.bridge('uitooltip', $.ui.tooltip);
var NO_OL_JACKET = _("No cover image available");
var OL_PREVIEW = _("Preview");
[% END %]
[% IF (query_desc) %]
var query_desc = "[% query_desc | html %]";
var querystring = "[% querystring | html %]";
var query_cgi = "[% query_cgi | html %]";
[% END %]
[% IF ( OPACAmazonCoverImages || SyndeticsCoverImages ) %]
$(window).load(function() {
verify_images();

View File

@ -885,8 +885,6 @@ $(document).ready(function(){
[% END %]
[% IF ( query_desc ) %]
var query_desc = "[% query_desc |replace("'", "\'") |replace('\n', '\\n') |replace('\r', '\\r') | html %]";
var querystring = "[% querystring |replace("'", "\'") |replace('\n', '\\n') |replace('\r', '\\r') | html %]";
[% IF ( OpacHighlightedWords ) %]
q_array = query_desc.split(" ");
// ensure that we don't have "" at the end of the array, which can