Bug 42292: Tidy all script tags - OPAC (auto tidy)

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Jan Kissig <bibliothek@th-wildau.de>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Jonathan Druart 2026-04-03 11:46:10 +02:00 committed by Pedro Amorim
parent 5e822ff613
commit e53b7346c9
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
8 changed files with 337 additions and 310 deletions

View File

@ -9,44 +9,45 @@
TimeFormat: "[% Koha.Preference('TimeFormat') | html %]",
});
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">
var flatpickr_weekdays = {
shorthand: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
longhand: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]
shorthand: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
longhand: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
};
var flatpickr_months = {
shorthand: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
longhand: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
shorthand: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
longhand: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
};
var sentmsg = 0;
if (debug > 1) {alert("dateformat: " + dateformat_pref + "\ndebug is on (level " + debug + ")");}
if (debug > 1) {
alert("dateformat: " + dateformat_pref + "\ndebug is on (level " + debug + ")");
}
var calendarFirstDayOfWeek = Koha.prefs.CalendarFirstDayOfWeek;
var flatpickr_timeformat_string = Koha.prefs.TimeFormat == '12hr' ? "G:i K" : "H:i";
var flatpickr_timeformat = Koha.prefs.TimeFormat == '12hr' ? false : true;
var flatpickr_timeformat_string = Koha.prefs.TimeFormat == "12hr" ? "G:i K" : "H:i";
var flatpickr_timeformat = Koha.prefs.TimeFormat == "12hr" ? false : true;
var flatpickr_dateformat_string = "";
var delimiter = "";
var altinput_dateformat = "";
switch ( dateformat_pref ){
switch (dateformat_pref) {
case "us":
flatpickr_dateformat_string = "m/d/Y";
altinput_dateformat = 'mm/dd/yyyy';
altinput_dateformat = "mm/dd/yyyy";
delimiter = "/";
break;
case "metric":
flatpickr_dateformat_string = "d/m/Y";
altinput_dateformat = 'dd/mm/yyyy';
delimiter = "/";
altinput_dateformat = "dd/mm/yyyy";
delimiter = "/";
break;
case "dmydot":
flatpickr_dateformat_string = "d.m.Y";
altinput_dateformat = 'dd/mm/yyyy';
altinput_dateformat = "dd/mm/yyyy";
delimiter = ".";
break;
default:
flatpickr_dateformat_string = "Y-m-d";
altinput_dateformat = 'yyyy/mm/dd';
altinput_dateformat = "yyyy/mm/dd";
delimiter = "-";
}
</script>

View File

@ -18,22 +18,22 @@
</script>
<!-- js-date-format.inc -->
<script nonce="[% Koha.CSPNonce | $raw %]">
(function() {
(function () {
var def_date_format = Koha.prefs.dateformat;
var def_time_format = Koha.prefs.TimeFormat;
var def_tz = tz;
var get_date_pattern = function(format) {
var date_pattern = 'YYYY-MM-DD';
if(format == 'us') date_pattern = 'MM/DD/YYYY';
if(format == 'metric') date_pattern = 'DD/MM/YYYY';
if(format == 'dmydot') date_pattern = 'DD.MM.YYYY';
var get_date_pattern = function (format) {
var date_pattern = "YYYY-MM-DD";
if (format == "us") date_pattern = "MM/DD/YYYY";
if (format == "metric") date_pattern = "DD/MM/YYYY";
if (format == "dmydot") date_pattern = "DD.MM.YYYY";
return date_pattern;
};
var get_time_pattern = function(format) {
var time_pattern = 'HH:mm';
if(format == '12hr') time_pattern = 'hh:mm a';
var get_time_pattern = function (format) {
var time_pattern = "HH:mm";
if (format == "12hr") time_pattern = "hh:mm a";
return time_pattern;
};
@ -43,44 +43,43 @@
* Optionally accepts a dateformat parameter to allow override of the configured output format
* as well as a 'withtime' boolean denoting whether to include time or not in the output string.
*/
window.$date = function(value, options) {
if(!value) return '';
var tz = (options&&options.tz)||def_tz;
window.$date = function (value, options) {
if (!value) return "";
var tz = (options && options.tz) || def_tz;
var m = dayjs(value);
if ( ! value.match(/^\d{4}-\d{2}-\d{2}$/ ) ) {
if (!value.match(/^\d{4}-\d{2}-\d{2}$/)) {
m = m.tz(tz);
}
var dateformat = (options&&options.dateformat)||def_date_format;
var withtime = (options&&options.withtime)||false;
var dateformat = (options && options.dateformat) || def_date_format;
var withtime = (options && options.withtime) || false;
if(dateformat=='rfc3339' && withtime) return m.format();
if (dateformat == "rfc3339" && withtime) return m.format();
var timeformat = (options&&options.timeformat)||def_time_format;
var timeformat = (options && options.timeformat) || def_time_format;
var date_pattern = get_date_pattern(dateformat);
var time_pattern = !withtime?'':' '+get_time_pattern(timeformat);
var time_pattern = !withtime ? "" : " " + get_time_pattern(timeformat);
return m.format(date_pattern+time_pattern);
}
return m.format(date_pattern + time_pattern);
};
window.$datetime = function(value, options) {
options = options||{};
window.$datetime = function (value, options) {
options = options || {};
options.withtime = true;
return $date(value, options);
};
window.$time = function(value, options) {
if(!value) return '';
var tz = (options&&options.tz)||def_tz;
window.$time = function (value, options) {
if (!value) return "";
var tz = (options && options.tz) || def_tz;
var m = dayjs(value);
if(tz) m = m.tz(tz);
if (tz) m = m.tz(tz);
var dateformat = (options&&options.dateformat);
var timeformat = (dateformat=='rfc3339'&&'24hr')||(options&&options.timeformat)||def_time_format;
return m.format(get_time_pattern(timeformat)+(dateformat=='rfc3339'?':ss'+(!m.isUTC()?'Z':''):''))+(dateformat=='rfc3339' && m.isUTC()?'Z':'');
}
var dateformat = options && options.dateformat;
var timeformat = (dateformat == "rfc3339" && "24hr") || (options && options.timeformat) || def_time_format;
return m.format(get_time_pattern(timeformat) + (dateformat == "rfc3339" ? ":ss" + (!m.isUTC() ? "Z" : "") : "")) + (dateformat == "rfc3339" && m.isUTC() ? "Z" : "");
};
})();
</script>
<!-- / js-date-format.inc -->

View File

@ -1682,7 +1682,6 @@
var normalized_isbn = "[% normalized_isbn | html %]";
var normalized_upc = "[% normalized_upc | html %]";
[% END %]
</script>
[% IF ( Koha.Preference('OPACShowMusicalInscripts') ) %]
[% Asset.js("js/verovio.js") | $raw %]
@ -2269,17 +2268,18 @@
</script>
[% IF ( NovelistSelectProfile && ( normalized_isbn || normalized_upc ) ) %]
<script nonce="[% Koha.CSPNonce | $raw %]">
$(document).ready(function() {
$(document).ready(function () {
novSelect.loadContentForQuery(
{
ClientIdentifier : normalized_isbn || normalized_upc,
ISBN : normalized_isbn || normalized_upc,
version : '2.1'
ClientIdentifier: normalized_isbn || normalized_upc,
ISBN: normalized_isbn || normalized_upc,
version: "2.1",
},
NovelistSelectProfile,
NovelistSelectPassword,
function(d){
if ( d.length > 0 ){ //If no content
function (d) {
if (d.length > 0) {
//If no content
$(".NovelistSelect").show();
}
}

View File

@ -508,8 +508,8 @@
[% Asset.js("js/results-list.js") | $raw %]
[% Asset.js("js/cover_images.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
if (Koha.prefs.OpacHighlightedWords){
var q_array = new Array(); // holds search terms if available
if (Koha.prefs.OpacHighlightedWords) {
var q_array = new Array(); // holds search terms if available
function highlightOff() {
$("td").removeHighlight();
@ -520,8 +520,8 @@
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.prefs.NotHighlightedWords.toLowerCase().split('|');
if ( (q_array[x].length > 0) && ($.inArray(q_array[x], myStopwords) == -1) ) {
var myStopwords = Koha.prefs.NotHighlightedWords.toLowerCase().split("|");
if (q_array[x].length > 0 && $.inArray(q_array[x], myStopwords) == -1) {
$(".title").highlight(q_array[x]);
$(".author").highlight(q_array[x]);
$(".results_summary").highlight(q_array[x]);
@ -531,145 +531,157 @@
}
}
let counter_wait = 0;
function wait_for_images(cb){
function wait_for_images(cb) {
var loaded = 1;
counter_wait++;
if (Koha.prefs.GoogleJackets){
if ( loaded ) {
if (Koha.prefs.GoogleJackets) {
if (loaded) {
loaded = KOHA.Google.done;
}
}
if (Koha.prefs.OpenLibraryCovers){
if ( loaded ) {
if (Koha.prefs.OpenLibraryCovers) {
if (loaded) {
loaded = KOHA.OpenLibrary.done;
}
}
if (Koha.prefs.OpacCoce && Koha.prefs.CoceProviders){
if ( loaded ) {
if (Koha.prefs.OpacCoce && Koha.prefs.CoceProviders) {
if (loaded) {
loaded = KOHA.coce.done;
}
}
if (!loaded && counter_wait < 50) {// Do not wait more than 5 seconds
window.setTimeout(function(){wait_for_images(cb);}, 100);
if (!loaded && counter_wait < 50) {
// Do not wait more than 5 seconds
window.setTimeout(function () {
wait_for_images(cb);
}, 100);
} else {
if (counter_wait >= 50 ) {
if (counter_wait >= 50) {
}
cb();
}
}
$(window).load(function() {
$(window).load(function () {
wait_for_images(verify_cover_images);
});
$(document).ready(function(){
$(".moretoggle").click(function(e){
$(document).ready(function () {
$(".moretoggle").click(function (e) {
e.preventDefault();
$(this).siblings(".collapsible-facet").toggle();
$(this).siblings(".moretoggle").toggle();
$(this).toggle();
});
if (Koha.prefs.OpacHighlightedWords){
$('a.title').each(function() {
if (Koha.prefs.OpacHighlightedWords) {
$("a.title").each(function () {
$(this).attr("href", $(this).attr("href") + "&query_desc=" + query_desc_uri);
});
}
$(".br-readonly a").on("click", function(e){
$(".br-readonly a").on("click", function (e) {
e.preventDefault();
});
$('.resort').change(function() {
$('#bookbag_form').submit();
$(".resort").change(function () {
$("#bookbag_form").submit();
});
$('#results_per_page').change(function() {
$('#bookbag_form').submit();
$("#results_per_page").change(function () {
$("#bookbag_form").submit();
});
if ( query_desc ){
if (Koha.prefs.OpacHighlightedWords){
if (query_desc) {
if (Koha.prefs.OpacHighlightedWords) {
q_array = query_desc.split(" ");
// ensure that we don't have "" at the end of the array, which can
// break the highlighter
while (q_array.length > 0 && q_array[q_array.length-1] == "") {
q_array = q_array.splice(0,-1);
while (q_array.length > 0 && q_array[q_array.length - 1] == "") {
q_array = q_array.splice(0, -1);
}
highlightOn();
$("#highlight_toggle_on" ).hide().click(function(e) {
e.preventDefault();
highlightOn();
});
$("#highlight_toggle_off").show().click(function(e) {
e.preventDefault();
highlightOff();
});
$("#highlight_toggle_on")
.hide()
.click(function (e) {
e.preventDefault();
highlightOn();
});
$("#highlight_toggle_off")
.show()
.click(function (e) {
e.preventDefault();
highlightOff();
});
}
if (OverDriveEnabled && firstPage){
var $overdrive_results = $( '<div id="overdrive-results">' + _("Searching %s...").format('OverDrive') + ' <img class="throbber" src=`${interface}/${theme}/images/spinner-small.gif` /></div>' );
$( '#numresults' ) .after( $overdrive_results );
if (OverDriveEnabled && firstPage) {
var $overdrive_results = $('<div id="overdrive-results">' + _("Searching %s...").format("OverDrive") + ' <img class="throbber" src=`${interface}/${theme}/images/spinner-small.gif` /></div>');
$("#numresults").after($overdrive_results);
//Clean querystring, first we remove CCL entities, then decode HTML entities, then swap double quotes for single quotes
//as the overdrive API treats double quotes as a search term and returns extra results
od_querystring = querystring.replace(/(?:^|\W)([\w-]+)(,[\w-]+)*([:=])/g,' ');
od_querystring = new DOMParser().parseFromString( od_querystring, 'text/html').body.innerText;
od_querystring = od_querystring.replace(/\"/g,"'");
KOHA.OverDrive.Search( Koha.prefs.OverDriveLibraryID, od_querystring, 1, 0, function( data ) {
if ( data.error ) {
$overdrive_results.html( _("Error searching %s collection").format('OverDrive') );
od_querystring = querystring.replace(/(?:^|\W)([\w-]+)(,[\w-]+)*([:=])/g, " ");
od_querystring = new DOMParser().parseFromString(od_querystring, "text/html").body.innerText;
od_querystring = od_querystring.replace(/\"/g, "'");
KOHA.OverDrive.Search(Koha.prefs.OverDriveLibraryID, od_querystring, 1, 0, function (data) {
if (data.error) {
$overdrive_results.html(_("Error searching %s collection").format("OverDrive"));
return;
}
if ( data.totalItems ) {
$overdrive_results.html( '<a href="/cgi-bin/koha/opac-overdrive-search.pl?q=' + encodeURIComponent( od_querystring ) + '">' + _("Found %s results in the library's %s collection").format(data.totalItems, 'OverDrive') + '</a>' );
if (data.totalItems) {
$overdrive_results.html(
'<a href="/cgi-bin/koha/opac-overdrive-search.pl?q=' + encodeURIComponent(od_querystring) + '">' + _("Found %s results in the library's %s collection").format(data.totalItems, "OverDrive") + "</a>"
);
} else {
$overdrive_results.remove();
}
} );
});
}
if ( OpenLibrarySearch ) {
var $openlibrary_results = $( '<div id="openlibrary-results">' + _("Searching %s...").format('OpenLibrary' ) + ' <img class="throbber" src=`${interface}/${theme}/images/spinner-small.gif` /></div>' );
$( '#numresults' ) .after( $openlibrary_results );
KOHA.OpenLibrary.search( querystring, null, function( data ) {
if ( data.error ) {
$openlibrary_results.html( _("Error searching %s collection").format('OpenLibrary') );
if (OpenLibrarySearch) {
var $openlibrary_results = $('<div id="openlibrary-results">' + _("Searching %s...").format("OpenLibrary") + ' <img class="throbber" src=`${interface}/${theme}/images/spinner-small.gif` /></div>');
$("#numresults").after($openlibrary_results);
KOHA.OpenLibrary.search(querystring, null, function (data) {
if (data.error) {
$openlibrary_results.html(_("Error searching %s collection").format("OpenLibrary"));
return;
}
if ( data.numFound > 0 ) {
$openlibrary_results.html( '<a href="' + KOHA.OpenLibrary.searchUrl(querystring) + '" target="openlibrary">' + _("Found %s results in the library's %s collection").format(data.numFound, 'OpenLibrary') + '</a>' );
if (data.numFound > 0) {
$openlibrary_results.html('<a href="' + KOHA.OpenLibrary.searchUrl(querystring) + '" target="openlibrary">' + _("Found %s results in the library's %s collection").format(data.numFound, "OpenLibrary") + "</a>");
} else {
$openlibrary_results.remove();
}
} );
});
}
}
if (Koha.prefs.OpenLibraryCovers){KOHA.OpenLibrary.GetCoverFromIsbn();}
if (Koha.prefs.OPACLocalCoverImages){KOHA.LocalCover.GetCoverFromBibnumber(false);}
if (Koha.prefs.GoogleJackets){KOHA.Google.GetCoverFromIsbn();}
if (Koha.prefs.OpacCoce && Koha.prefs.CoceProviders){
if (Koha.prefs.OpenLibraryCovers) {
KOHA.OpenLibrary.GetCoverFromIsbn();
}
if (Koha.prefs.OPACLocalCoverImages) {
KOHA.LocalCover.GetCoverFromBibnumber(false);
}
if (Koha.prefs.GoogleJackets) {
KOHA.Google.GetCoverFromIsbn();
}
if (Koha.prefs.OpacCoce && Koha.prefs.CoceProviders) {
KOHA.coce.getURL(Koha.prefs.CoceHost, Koha.prefs.CoceProviders);
}
if (DidYouMean){
$("#didyoumean").load("/cgi-bin/koha/svc/suggestion?render=stub&q=" + querystring_uri,
function() {
$(this).addClass("dym-loaded");
});
if (DidYouMean) {
$("#didyoumean").load("/cgi-bin/koha/svc/suggestion?render=stub&q=" + querystring_uri, function () {
$(this).addClass("dym-loaded");
});
}
$("input.newtag").on('keydown', function(e){
if (e.keyCode == 13) { e.preventDefault(); }
$("input.newtag").on("keydown", function (e) {
if (e.keyCode == 13) {
e.preventDefault();
}
});
});
</script>

View File

@ -857,50 +857,50 @@
const can_remove_biblios = [% can_remove_biblios ? 1 : 0 | html %];
var print = [% print ? 1 : 0 | html %];
const has_items = [% itemsloop ? 1 : 0 | html %]
</script>
[% Asset.js("js/results-list.js") | $raw %]
[% Asset.js("js/cover_images.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
let counter_wait = 0;
function wait_for_images(cb){
function wait_for_images(cb) {
var loaded = 1;
counter_wait++;
if (Koha.prefs.GoogleJackets){
if ( loaded ) {
if (Koha.prefs.GoogleJackets) {
if (loaded) {
loaded = KOHA.Google.done;
}
}
if (Koha.prefs.OpenLibraryCovers){
if ( loaded ) {
if (Koha.prefs.OpenLibraryCovers) {
if (loaded) {
loaded = KOHA.OpenLibrary.done;
}
}
if ( Koha.prefs.OpacCoce && Koha.prefs.CoceProviders ) {
if ( loaded ) {
if (Koha.prefs.OpacCoce && Koha.prefs.CoceProviders) {
if (loaded) {
loaded = KOHA.coce.done;
}
}
if (!loaded && counter_wait < 50) {// Do not wait more than 5 seconds
window.setTimeout(function(){wait_for_images(cb);}, 100);
if (!loaded && counter_wait < 50) {
// Do not wait more than 5 seconds
window.setTimeout(function () {
wait_for_images(cb);
}, 100);
} else {
if (counter_wait >= 50 ) {
if (counter_wait >= 50) {
}
cb();
}
}
$(window).load(function() {
$(window).load(function () {
wait_for_images(verify_cover_images);
});
if (TagsInputEnabled && loggedinusername){
if (TagsInputEnabled && loggedinusername) {
function tagSelected() {
var checkedBoxes = $("input:checkbox:checked");
if ($(checkedBoxes).size()) {
@ -908,7 +908,7 @@
$(".tag_hides").hide();
$("#tagsel_form").show();
} else {
alert( _("No item was selected") );
alert(_("No item was selected"));
}
}
@ -923,13 +923,13 @@
function tagAdded() {
var checkedBoxes = $("input:checkbox:checked");
if (!$(checkedBoxes).size()) {
alert( _("No item was selected") );
alert(_("No item was selected"));
return false;
}
var tag = $("#tagsel_new").val();
if (!tag || (tag == "")) {
alert( _("No tag was specified.") );
if (!tag || tag == "") {
alert(_("No tag was specified."));
return false;
}
@ -944,57 +944,61 @@
}
}
$(function() {
$(function () {
$("a.print").show();
if ( TagsInputEnabled && loggedinusername ) {
if (TagsInputEnabled && loggedinusername) {
var tagAdd = $(".tag_add");
tagAdd.removeClass("hidden");
$("#tagsel_tag").click(function(){
$("#tagsel_tag").click(function () {
tagSelected();
return false;
});
$("#tagsel_cancel").click(function(){
$("#tagsel_cancel").click(function () {
tagCanceled();
return false;
});
$("#tagsel_button").click(function(){
$("#tagsel_button").click(function () {
tagAdded();
return false;
});
tagAdd.click(function(){
tagAdd.click(function () {
var thisid = $(this).attr("id");
thisid = thisid.replace("tag_add","");
thisid = thisid.replace("tag_add", "");
$(this).hide();
$("#tagform"+thisid).show();
$("#newtag"+thisid).focus();
$("#newtag"+thisid+"_status").empty().hide();
$("#tagform" + thisid).show();
$("#newtag" + thisid).focus();
$("#newtag" + thisid + "_status")
.empty()
.hide();
return false;
});
$(".cancel_tag_add").click(function(){
$(".cancel_tag_add").click(function () {
var thisid = $(this).attr("id");
thisid = thisid.replace("cancel","");
$("#tagform"+thisid).hide();
$("#tag_add"+thisid).show();
$("#newtag"+thisid).val("");
$("#newtag"+thisid+"_status").empty().hide();
thisid = thisid.replace("cancel", "");
$("#tagform" + thisid).hide();
$("#tag_add" + thisid).show();
$("#newtag" + thisid).val("");
$("#newtag" + thisid + "_status")
.empty()
.hide();
return false;
});
$(".tagbutton").click(function(){
var thisid = $(this).attr("title");
var tag = $("#newtag"+thisid).val();
if (!tag || (tag == "")) {
alert( _("No tag was specified.") );
return false;
}
KOHA.Tags.add_tag_button(thisid, tag);
return false;
$(".tagbutton").click(function () {
var thisid = $(this).attr("title");
var tag = $("#newtag" + thisid).val();
if (!tag || tag == "") {
alert(_("No tag was specified."));
return false;
}
KOHA.Tags.add_tag_button(thisid, tag);
return false;
});
}
if (loggedinusername && can_remove_biblios){
$("body").on("click", ".removeitems", function(e){
if (loggedinusername && can_remove_biblios) {
$("body").on("click", ".removeitems", function (e) {
e.preventDefault();
var title;
var yes_label;
@ -1002,36 +1006,36 @@
var message = "";
var biblionumber;
/* Single "Remove from list" link has a biblionumber data-attribute */
if( $(this).data("biblionumber") ){
if ($(this).data("biblionumber")) {
/* Use the checkbox with that value to preview the title in the confirmation */
var selected_titles = $(".cb[value='" + $(this).data("biblionumber") + "'");
biblionumber = $(this).data("biblionumber");
} else {
var selected_titles = $(".cb:checked");
}
if ( selected_titles.size() < 1 ) {
alert( _("No item was selected") );
if (selected_titles.size() < 1) {
alert(_("No item was selected"));
} else {
if( selected_titles.size() > 1 ){
if (selected_titles.size() > 1) {
message = $("<ul></ul>");
title = _("Are you sure you want to remove these items from the list?");
yes_label = _("Yes, remove from list");
no_label = _("No, do not remove from list");
selected_titles.each(function(){
message.append( "<li>" + $(this).data("title") + "</li>" );
selected_titles.each(function () {
message.append("<li>" + $(this).data("title") + "</li>");
});
} else {
title = _("Are you sure you want to remove this item from the list?");
yes_label = _("Yes, remove from list");
no_label = _("No, do not remove from list");
selected_titles.each(function(){
selected_titles.each(function () {
message += $(this).data("title");
});
}
confirmModal( message, title, yes_label, no_label, function( result ){
if( result ){
if( biblionumber ){
$("#shelf_delete_biblionumber").val( biblionumber );
confirmModal(message, title, yes_label, no_label, function (result) {
if (result) {
if (biblionumber) {
$("#shelf_delete_biblionumber").val(biblionumber);
$("#shelf_delete_title").submit();
} else {
$("#myform").submit();
@ -1042,130 +1046,140 @@
});
}
if (Koha.prefs.OpenLibraryCovers){KOHA.OpenLibrary.GetCoverFromIsbn();}
if (Koha.prefs.OPACLocalCoverImages){KOHA.LocalCover.GetCoverFromBibnumber(false);}
if (Koha.prefs.GoogleJackets){KOHA.Google.GetCoverFromIsbn();}
if (Koha.prefs.OpacCoce && Koha.prefs.CoceProviders){
if (Koha.prefs.OpenLibraryCovers) {
KOHA.OpenLibrary.GetCoverFromIsbn();
}
if (Koha.prefs.OPACLocalCoverImages) {
KOHA.LocalCover.GetCoverFromBibnumber(false);
}
if (Koha.prefs.GoogleJackets) {
KOHA.Google.GetCoverFromIsbn();
}
if (Koha.prefs.OpacCoce && Koha.prefs.CoceProviders) {
KOHA.coce.getURL(Koha.prefs.CoceHost, Koha.prefs.CoceProviders);
}
if (print){
if (print) {
window.print();
window.onafterprint = function () {
window.close();
}
setTimeout('window.close()', 1000); // Hack for Chrome < 63
};
setTimeout("window.close()", 1000); // Hack for Chrome < 63
}
AdjustRemark();
if (has_items){
sortMenu( $("#sorting-form") );
if (has_items) {
sortMenu($("#sorting-form"));
$("#sortfield").on("change", function(){
$('#sorting-form').submit();
$("#sortfield").on("change", function () {
$("#sorting-form").submit();
});
}
$(".deleteshelf").on("click", function(e){
$(".deleteshelf").on("click", function (e) {
e.preventDefault();
var shelf_name = $(this).data("shelfname");
var shelf_number = $(this).data("shelfnumber");
var is_shared = $(this).data("shared");
var count = $(this).data("count");
var message = "<p><em>" + escape_str(shelf_name) + "</em></p>";
if( count ){
if (count) {
message += "<p>" + _("Items on this list:") + " <strong>" + escape_str(count) + "</strong></p>";
}
if( is_shared ){
if (is_shared) {
message += "<p>" + _("This list is shared. Other users will lose access to it.") + "</p>";
}
confirmModal( message, _("Are you sure you want to delete this list?"), _("Yes, delete"), _("No, do not delete"), function( result ){
if( result ){
$("#deleteshelf" + shelf_number ).submit();
}
confirmModal(message, _("Are you sure you want to delete this list?"), _("Yes, delete"), _("No, do not delete"), function (result) {
if (result) {
$("#deleteshelf" + shelf_number).submit();
}
);
});
});
$(".remove_share").on("click", function(e){
$(".remove_share").on("click", function (e) {
e.preventDefault();
var shelf_name = $(this).data("shelfname");
var shelf_number = $(this).data("shelfnumber");
confirmModal( escape_str(shelf_name), _("Are you sure you want to remove sharing? You will no longer have access to the list."), _("Yes, remove sharing"), _("No, do not remove sharing"), function( result ){
if( result ){
$("#unshare" + shelf_number ).submit();
}
confirmModal(escape_str(shelf_name), _("Are you sure you want to remove sharing? You will no longer have access to the list."), _("Yes, remove sharing"), _("No, do not remove sharing"), function (result) {
if (result) {
$("#unshare" + shelf_number).submit();
}
);
});
});
$(".download-list").on("click", function(e){
$(".download-list").on("click", function (e) {
e.preventDefault();
var format = $(this).data("format");
$("#download_format").val( format );
$("#download_format").val(format);
$("#download_list").submit();
});
$("#allow_changes_from, #public").on("change", function(){
$("#allow_changes_from, #public").on("change", function () {
AdjustRemark();
});
$(".send").on("click", function(e){
$(".send").on("click", function (e) {
e.preventDefault();
let link = this.href;
Dopop( link );
Dopop(link);
});
}); // document.ready
function sortMenu( sorting_form ){
function sortMenu(sorting_form) {
var shelfnumber = sorting_form.find("input[name='shelfnumber']").val();
var sort_link = "/cgi-bin/koha/opac-shelves.pl?op=view&amp;shelfnumber=" + shelfnumber + "&sortfield=";
var menu = "<div class=\"btn-group dropdown\"><button type=\"button\" class=\"btn btn-link dropdown-toggle\" data-bs-toggle=\"dropdown\" id=\"sortmenu\" aria-haspopup=\"true\" aria-expanded=\"false\"><i class=\"fa fa-sort\" aria-hidden=\"true\"></i> " + _("Sort") + "</span></button><div class=\"dropdown-menu dropdown-menu-end\" aria-labelledby=\"sortmenu\">";
$("#sortfield").children().each(function(){
if( $(this)[0].tagName.toUpperCase() == "OPTION" ){
menu += "<a class=\"dropdown-item\" href=\"" + sort_link + $(this).val() + "\">" + $(this).text() + "</a>";
} else if( $(this)[0].tagName.toUpperCase() == "OPTGROUP" ){
menu += "<span class=\"dropdown-header\">" + $(this).attr("label") + "</span>";
$(this).children().each(function(){
if( $(this)[0].tagName.toUpperCase() == "OPTION" ){
menu += "<a class=\"dropdown-item\" href=\"" + sort_link + $(this).val() + "&direction=" + $(this).data('direction') + "\">" + $(this).text() + "</a>";
}
});
}
});
var menu =
'<div class="btn-group dropdown"><button type="button" class="btn btn-link dropdown-toggle" data-bs-toggle="dropdown" id="sortmenu" aria-haspopup="true" aria-expanded="false"><i class="fa fa-sort" aria-hidden="true"></i> ' +
_("Sort") +
'</span></button><div class="dropdown-menu dropdown-menu-end" aria-labelledby="sortmenu">';
$("#sortfield")
.children()
.each(function () {
if ($(this)[0].tagName.toUpperCase() == "OPTION") {
menu += '<a class="dropdown-item" href="' + sort_link + $(this).val() + '">' + $(this).text() + "</a>";
} else if ($(this)[0].tagName.toUpperCase() == "OPTGROUP") {
menu += '<span class="dropdown-header">' + $(this).attr("label") + "</span>";
$(this)
.children()
.each(function () {
if ($(this)[0].tagName.toUpperCase() == "OPTION") {
menu += '<a class="dropdown-item" href="' + sort_link + $(this).val() + "&direction=" + $(this).data("direction") + '">' + $(this).text() + "</a>";
}
});
}
});
menu += "</div>";
$(".list-actions").append( menu );
$(".list-actions").append(menu);
sorting_form.remove();
}
function AdjustRemark() {
var public;
if( $("#public").length > 0 ) {
if ($("#public").length > 0) {
public = $("#public").val();
} else {
public = default_public;
}
var perms = $("#allow_changes_from").val();
if( perms < 2 ) {
if (perms < 2) {
$("#anyone_remark").hide();
$("#staff_remark").hide();
$("#permitted_staff_remark").hide();
} else if( public==0 ) {
} else if (public == 0) {
// If we move to Private (without shares), show Anyone remark
// Note: the number of shares is not tested real-time
if (!is_shelf_shared){
if ( perms==2 ) {
if (!is_shelf_shared) {
if (perms == 2) {
$("#anyone_remark").show();
$("#staff_remark").hide();
$("#permitted_staff_remark").hide();
} else if ( perms==3 ) {
} else if (perms == 3) {
$("#anyone_remark").hide();
$("#staff_remark").show();
$("#permitted_staff_remark").hide();
} else if ( perms==4 ) {
} else if (perms == 4) {
$("#anyone_remark").hide();
$("#staff_remark").hide();
$("#permitted_staff_remark").show();
@ -1175,7 +1189,8 @@
$("#staff_remark").hide();
$("#permitted_staff_remark").hide();
}
} else { // public==1
} else {
// public==1
$("#anyone_remark").hide();
$("#staff_remark").hide();
$("#permitted_staff_remark").hide();

View File

@ -1471,18 +1471,18 @@
[% IF OverDriveCirculation %]
[% Asset.js("js/overdrive.js") | $raw %]
<script nonce="[% Koha.CSPNonce | $raw %]">
$(document).ready(function() {
if ( overdrive_error ){
$(document).ready(function () {
if (overdrive_error) {
KOHA.OverDriveCirculation.display_error("#opac-user-overdrive_panel", overdrive_error);
}
if ( overdrive_tab ){
if (overdrive_tab) {
$("#opac-user-views a[href='#opac-user-overdrive_panel']").tab("show");
}
$("#opac-user-overdrive_panel").each( function() {
$("#opac-user-overdrive_panel").each(function () {
KOHA.OverDriveCirculation.display_account_details(this);
} );
});
});
</script>
[% END %]

View File

@ -235,68 +235,70 @@
<script nonce="[% Koha.CSPNonce | $raw %]" data-tt-allowed="true">
const refresh_timeout = "[% refresh_timeout | html %]";
</script>
<script nonce="[% Koha.CSPNonce | $raw %]">
function mungeHistory() {
// prevent back button from allowing form resubmission
if (history && history.pushState) {
history.replaceState(null, document.title, window.location.href);
}
}
// prevent back button from allowing form resubmission
if (history && history.pushState) {
history.replaceState(null, document.title, window.location.href);
}
}
function dofocus() {
$(".focus:last").select();
}
function dofocus() {
$(".focus:last").select();
}
var barcodes = [];
var barcodes = [];
$( window ).on( "load", function() {
dofocus();
});
$(window).on("load", function () {
dofocus();
});
$( window ).on( "unload", function() {
mungeHistory();
});
$(window).on("unload", function () {
mungeHistory();
});
$(document).ready(function() {
$(document).ready(function () {
// Barcodes scanning table initially hidden
$("#sci_barcodes_table").hide();
// Control the 'append' button behaviour
$("#sci_append_button").on('click', function(e) {
$("#sci_append_button").on("click", function (e) {
// Make sure the form is not submitted by the button
e.preventDefault();
var barcode = $('#barcode_input').val().trim(); // Trim whitespace from input
var barcode = $("#barcode_input").val().trim(); // Trim whitespace from input
if (barcode !== "") {
// Properly escape the barcode value by using .text() for display
var barcodeHtml = $('<tr style="font-size: initial;"><td></td></tr>');
barcodeHtml.find('td').text(barcode).append(
$('<input>').attr({
type: 'hidden',
name: 'barcode',
value: barcode
})
);
barcodeHtml
.find("td")
.text(barcode)
.append(
$("<input>").attr({
type: "hidden",
name: "barcode",
value: barcode,
})
);
$('#sci_barcodes_table tbody').append(barcodeHtml);
$("#sci_barcodes_table tbody").append(barcodeHtml);
// Make sure the table is now displayed
$("#sci_barcodes_table").show();
$('#sci_checkin_button').show();
$('#sci_refresh_button').show();
$("#sci_checkin_button").show();
$("#sci_refresh_button").show();
// Add barcode to the array
barcodes.push(barcode);
}
// Clear the input and reset the focus
$('#barcode_input').val('');
$("#barcode_input").val("");
dofocus();
});
$(".helpModal-trigger").on("click", function(e) {
$(".helpModal-trigger").on("click", function (e) {
e.preventDefault();
$("#helpModal").modal("show");
});
@ -305,48 +307,46 @@
dofocus();
});
var idleTime = 0;
$(document).ready(function () {
//Increment the idle time counter every second
var idleInterval = setInterval(timerIncrement, 1000);
var idleTime = 0;
$(document).ready(function () {
//Increment the idle time counter every second
var idleInterval = setInterval(timerIncrement, 1000);
//Zero the idle timer on mouse movement.
$(this).mousemove(function (e) {
idleTime = 0;
});
$(this).keypress(function (e) {
idleTime = 0;
});
});
//Zero the idle timer on mouse movement.
$(this).mousemove(function (e) {
idleTime = 0;
});
$(this).keypress(function (e) {
idleTime = 0;
});
});
function timerIncrement() {
if ( $("#sci_finish_button").is(":visible") || $("#sci_refresh_button").is(":visible") ) {
idleTime = idleTime + 1;
idleTimeout = refresh_timeout;
if (idleTime >= idleTimeout ) {
location.href = '/cgi-bin/koha/sci/sci-main.pl';
}
}
function timerIncrement() {
if ($("#sci_finish_button").is(":visible") || $("#sci_refresh_button").is(":visible")) {
idleTime = idleTime + 1;
idleTimeout = refresh_timeout;
if (idleTime >= idleTimeout) {
location.href = "/cgi-bin/koha/sci/sci-main.pl";
}
}
}
function checkBarcodeInput() {
var inputField = document.getElementById("barcode_input");
var button = document.getElementById("sci_append_button");
function checkBarcodeInput() {
var inputField = document.getElementById("barcode_input");
var button = document.getElementById("sci_append_button");
if (inputField.value.trim() === "") {
button.disabled = true;
} else {
button.disabled = false;
}
}
if (inputField.value.trim() === "") {
button.disabled = true;
} else {
button.disabled = false;
}
}
checkBarcodeInput();
document.getElementById("barcode_input").addEventListener("input", checkBarcodeInput);
document.getElementById("sci_append_button").addEventListener("click", function() {
document.getElementById("sci_append_button").addEventListener("click", function () {
setTimeout(checkBarcodeInput, 10);
});
</script>

View File

@ -425,20 +425,20 @@
</script>
[% IF Koha.Preference('AudioAlerts') %]
<script nonce="[% Koha.CSPNonce | $raw %]">
$( document ).ready(function() {
if ( AUDIO_ALERTS ) {
for ( var k in AUDIO_ALERTS ) {
$(document).ready(function () {
if (AUDIO_ALERTS) {
for (var k in AUDIO_ALERTS) {
var alert = AUDIO_ALERTS[k];
if ( $( alert.selector ).length ) {
playSound( alert.sound );
if ($(alert.selector).length) {
playSound(alert.sound);
break;
}
}
}
});
function playSound( sound ) {
function playSound(sound) {
if (!(sound.indexOf("http://") === 0 || sound.indexOf("https://") === 0)) {
sound = interface + '/bootstrap/sound/' + sound;
sound = interface + "/bootstrap/sound/" + sound;
}
document.getElementById("audio-alert").innerHTML = '<audio src="' + sound + '" autoplay="autoplay" autobuffer="autobuffer"></audio>';
}