Koha/koha-tmpl/intranet-tmpl/prog/js/cart.js
Michał Kula da9f74e56a
Bug 35072: Fix invalid usage of "&" in JavaScript intranet-tmpl script redirects
These escapes were invalid in these places, as HTML entity escapes
are meant to be used only inside of HTML elements/attributes, not
inside of JavaScript code.

These URLs would be sent out by the browser as-is, and that'd usually
work on the default install only coincidentally. Unfortunately, on some
setups (such as when using reverse proxies), this would break, and the
URL after "&" would have been truncated.

This small patch adjusts the URLs in templates to not use wrong escapes,
and makes them consistent with how URLs are formatted for JavaScript
redirects in most of the templates already.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
2023-10-24 10:05:27 -03:00

149 lines
3.8 KiB
JavaScript

/* global __ dataTablesDefaults showMore showLess delSelRecords addSelToShelf sendBasket printBasket delBasket openBiblio selRecord */
function placeHold () {
var checkedItems = $("input:checkbox:checked");
if ($(checkedItems).size() === 0) {
alert( __("No item was selected") );
return false;
}
var bib_params = [];
$(checkedItems).each(function() {
var bib = $(this).val();
bib_params.push("biblionumber=" + bib);
});
if (bib_params.length > 1) {
bib_params.push('multi_hold=1');
}
window.opener.location = "/cgi-bin/koha/reserve/request.pl?" + bib_params.join('&');
window.close();
}
function batchDelete(){
var checkedItems = $("input:checkbox:checked");
if ($(checkedItems).size() === 0) {
alert( __("No item was selected") );
return false;
}
var newloc;
var bibs = "";
checkedItems.each(function() {
var bib = $(this).val();
bibs += bib + "/";
});
newloc = "/cgi-bin/koha/tools/batch_delete_records.pl?op=list&type=biblio&bib_list=" + bibs;
window.opener.location = newloc;
window.close();
}
function batchModify(){
var checkedItems = $("input:checkbox:checked");
if ($(checkedItems).size() === 0) {
alert( __("No item was selected") );
return false;
}
var newloc;
var bibs = "";
$(checkedItems).each(function() {
var bib = $(this).val();
bibs += bib + "/";
});
newloc = "/cgi-bin/koha/tools/batch_record_modification.pl?op=list&bib_list=" + bibs + "&type=biblio";
window.opener.location = newloc;
window.close();
}
$(document).ready(function(){
$("#items-popover").popover();
$("#CheckAll").click(function (e) {
e.preventDefault();
$(".select_record").each(function () {
$(this).prop("checked", true).change();
});
});
$("#CheckNone").click(function (e) {
e.preventDefault();
$(".select_record").each(function () {
$(this).prop("checked", false).change();
});
});
$(".holdsep").text("| ");
$(".hold").text( __("Place hold") );
$("#downloadcartc").empty();
$("#itemst").dataTable($.extend(true, {}, dataTablesDefaults, {
"sDom": 't',
"aoColumnDefs": [
{ "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
{ "sType": "anti-the", "aTargets" : [ "anti-the" ] },
{ "sType": "callnumbers", "aTargets" : [ "callnumbers"] }
],
"aaSorting": [[ 1, "asc" ]],
"bPaginate": false
}));
$(".showdetails").on("click",function(e){
e.preventDefault();
if( $(this).hasClass("showmore") ){
showMore();
} else {
showLess();
}
});
$("#batch_modify").on("click",function(e){
e.preventDefault();
batchModify();
});
$("#batch_delete").on("click",function(e){
e.preventDefault();
batchDelete();
});
$("#remove_from_cart").on("click",function(e){
e.preventDefault();
delSelRecords();
});
$("#add_to_list").on("click",function(e){
e.preventDefault();
addSelToShelf();
});
$("#place_hold").on("click",function(e){
e.preventDefault();
placeHold();
});
$("#send_cart").on("click",function(e){
e.preventDefault();
sendBasket();
});
$("#print_cart").on("click",function(e){
e.preventDefault();
printBasket();
});
$("#empty_cart").on("click",function(e){
e.preventDefault();
delBasket('popup');
});
$(".title").on("click",function(e){
e.preventDefault();
openBiblio( this.href );
});
$(".select_record").on("change",function(){
selRecord( this.value, this.checked );
});
});