var errorMessage = "Si è verificato un errore.Stato della chiamata: ";
var dataWebinar = "Data Webinar";
var tCliccare = "cliccare";
var tQui = "qui";
var tPerAccessoWebinar = "per accesso al webinar";
var tLingua = "ita";
var tSuccesso = "Operazione svolta con successo";
var tIdAnagrafica = "";
var tConfermare = "confermare";
var tChiudi = "Chiudi";
var tErrore = "ERRORE";
var tScegli = "Scegli dalla lista";
var tTutti = "Tutti";
var trad = "";
var altezzasito = 0;
var altfooter = 0;
var larghezzasito = 0;
var totaltezza = 0;
var alttop = 0;
var menu = $("#menusxgest");
var posizione = menu.position();
function ricercapfe(idpercorsoformativo_eventi, idpercorsoformativo, lingua) {
var myElement = document.getElementById("ricercapfe").value;
Richiesta(idpercorsoformativo_eventi + '||' + idpercorsoformativo + '||||' + myElement + '||||||' + lingua + '||', '/php/admin/iscrittipfe.php', 'iscrittipfe', 'si')
}
function update_ndomande_num(n) {
var nd = Math.floor($('#ndomande').val() * n / 100);
$('#nd_shownum').html(nd);
$('#ndomande_num').val(nd);
$('#select2-ndomande_num-container').html(nd);
$('#ndomande_abs').val(nd);
}
function update_ndomande(n) {
if (n > 0) {
var nn = $('#ndomande_num').val();
var np = Math.round(nn * 100 / n);
var nd = Math.floor(np * n / 100);
if (nd > nn) {
np -= 1
} else if (nd < nn) {
np += 1
}
$('#ndomande').val(np);
$('#nd_shownum').html(nn);
$('#select2-ndomande-container').html(np);
$('#ndomande_abs').val(n);
}
}
function show_ndomande() {
var input = $('#ndomande_input').val();
if (input == 0) {
$('#ndperc').show();
$('#ndnum').hide();
} else {
$('#ndperc').hide();
$('#ndnum').show();
}
}
function initGaugeS(targetId, valore) {
var opts = {
angle: 0, // The h4 of the gauge arc
lineWidth: 0.3, // The line thickness
radiusScale: 0.6, // Relative radius
pointer: {
length: 0.6, // // Relative to gauge radius
strokeWidth: 0.035, // The thickness
color: '#000000' // Fill color
},
limitMax: false, // If false, max value increases automatically if value > maxValue
limitMin: false, // If true, the min value of the gauge will be fixed
colorStart: '#6FADCF', // Colors
colorStop: '#8FC0DA', // just experiment with them
strokeColor: '#E0E0E0', // to see which ones work best for you
generateGradient: true,
highDpiSupport: true, // High resolution support
staticLabels: {
font: "12px helvetica", // Specifies font
labels: [0, 70, 80, 100], // Print labels at these values
color: "#000000", // Optional: Label text color
fractionDigits: 0 // Optional: Numerical precision. 0=round off.
},
staticZones: [{
strokeStyle: "#F03E3E",
min: 0,
max: 70
}, // Red from 100 to 130
{
strokeStyle: "#FFDD00",
min: 70,
max: 80
}, // Yellow
{
strokeStyle: "#30B32D",
min: 80,
max: 100
}, // Green
],
}
var target = document.getElementById(targetId); // your canvas element
var gauge = new Gauge(target).setOptions(opts); // create sexy gauge!
gauge.maxValue = 100; // set max gauge value
gauge.setMinValue(0); // Prefer setter over gauge.minValue = 0
gauge.animationSpeed = 32; // set animation speed (32 is default value)
gauge.set(valore); // set actual value
}
function mettifiltro(url, display) {
$("#imgresult").attr("src", url);
if (display == "none") {
$(".pal").hide()
$(".stotag").hide()
} else {
$(".pal").show()
$(".stotag").show()
}
}
function calendariocorsiajax(querystring) {
$('#calendario_corsi').html('
");
var valore = variabili;
$.ajax({
type: "POST", //Tipo di richiesta
url: pagina, //Url web service
data: "variabile=" + valore + '&ricerca=' + ricerca, //Parametri (da concatenare con &)
//dataType: "json", //Tipo di risposta
error: function (msg,stato,errori) {$("#" + div).html("
"+stato+"").fadeIn("slow");},
success: function (msg) { //Callback risposta
$("#" + div).html(msg).fadeIn("slow");
//sistemamenu();
$(".data").datepicker();
$("table").addClass('tablesorter')
$('tr:odd').addClass('grigio');
$('tr:even').addClass('bianco');
$('div.clear:odd').addClass('grigio');
$('div.clear:even').addClass('bianco');
$("select").select2();
$(".select2-container").css("max-width", "350px");
$(".select2-container").css("min-width", "120px");
$("#linguas").select2('destroy');
$(".cosas").select2('destroy');
$('a[rel="#overlay"]').click(function () {
var href = $(this).attr('href');
usaoverlay(href)
});
//Setta i valori dei campi e fa un fadeIn
}
});
coloraFiltri();
nooscura() ;
}
document.cookie = "ScreenSize=" + screen.width + "-" + screen.height;
function popupfull(mylink, windowname) {
popupwindow = window.open(mylink, windowname, "height=" + (window.screen.height - 60) + ", width=" + (window.screen.width - 10) + ", top=0, left=0,scrollbars=yes");
}
function ColoraRighe(tabella) {
var tabelle = document.getElementsByTagName("table");
for (i = 0; i < tabelle.length; i++) {
if (tabelle[i].className.indexOf(tabella) >= 0) {
trs = tabelle[i].tBodies[0].rows;
for (s = 1; s < trs.length; s += 1)
trs[s].className = "bianco";
for (j = 1; j < trs.length; j += 2)
trs[j].className = "grigio";
}
}
}
function Aggiorna() {
Richiesta('zzxy', '/admin/controlla_msg.asp', 'posta', 'no');
}
function AggiornaAllegati() {
Richiesta('zzxy', '/u/lista_materiale.asp', 'lista_materiale', '');
}
function change() {
intervalID = setInterval(Aggiorna, 2500);
}
function chiudiMsg(dove, cosa, classe)
{
document.getElementById(dove).style.visibility = "hidden";
document.getElementById(cosa).className = classe;
}
function upmessaggio(dove, cosa, classe) {
if (document.message.messaggio.value == "") {
alert("Inserire il messaggio");
document.message.messaggio.focus();
return false;
}
chiudiMsg(dove, cosa, classe);
document.message.submit();
}
function chiudiAggiorna(dove, variabile, doves, pagina)
{
document.getElementById(dove).style.visibility = "hidden";
Richiesta(variabile, pagina, doves);
}
function provatr(valore, variabile) {
$.ajax({
type: "GET",
url: "/admin/riga.asp",
data: "variabile=" + variabile,
success: function (response) {
$("#" + valore).each(function (i) {
$(this).attr('id', valore);
$(this).html(response)
});
}
});
}
function uptotale(valore, elemento)
{
//alert(elemento)
if (document.getElementById(elemento).checked) {
totale = parseInt(document.formecommerce.price.value) + parseInt(valore);
//alert(valore)
}
if (document.getElementById(elemento).checked == false) {
totale = parseInt(document.formecommerce.price.value) - parseInt(valore);
//alert(valore)
}
document.formecommerce.totale.value = totale
//alert(totale);
}
function deletepartecipante(variabile, pagina) {
$("#evento_corso").hide();
$.ajax({
type: "GET",
url: pagina,
data: variabile,
success: function (response) {
$("#evento_corso").html(response).slideDown();
$("#stato_iscrizioni").slideDown();
$("select").select2();
$(".select2-container").css("max-width", "350px");
$(".select2-container").css("min-width", "120px");
}
});
}
function aprimenu() {
$("#sx").show();
$('#dx').css('margin', '0px');
if (larghezzasito < 768)
{
$('#dx').hide()
} else {
$('#dx').css('width', larghezzasito - 270 + 'px');
}
$('#cmenu').css('display', 'block');
$('#amenu').css('display', 'none');
document.cookie = 'menu' + '=' + '';
}
function apri_div(div, maxdiv) {
var i = 1;
for (i = 1; i <= maxdiv; i++) {
//alert ('D'+i)
document.getElementById('D' + i).className = "chiuso_div"
}
document.getElementById(div).className = "vedi_div"
}
function prova(anchorname, variabile, dove, pagina) {
$(".bottone").removeClass("alert");
var str = anchorname;
var res = str.replace("anchor", "");
if (dove != "") {
$("#" + anchorname).addClass("alert");
document.getElementById(dove).style.visibility = "visible";
document.getElementById(dove).style.display = "block";
Richiesta(variabile, pagina, dove);
}
}
function chiudi(dove, divk, idev)
{
document.getElementById(dove).style.visibility = "hidden";
Richiesta(idev + '_' + divk, 'avvisi', divk);
}
function chiudiDiv(dove)
{
document.getElementById(dove).style.visibility = "hidden";
document.getElementById(dove).style.display = "none";
}
function controlDelete(div)
{
$('#' + div).remove();
}
function yummy(yommo) {
var kafka = "67"
recs = ""
stringa = yommo;
var arr_testo = stringa.split("");
var i = 0;
while (i < arr_testo.length) {
var rec = arr_testo[i]
recs = recs + (rec.charCodeAt(0) + kafka) + ","
i++;
}
return recs;
}
function upavviso() {
if (document.advice.avviso.value == "") {
alert("Inserire l'avviso");
document.advice.avviso.focus();
return false;
}
doves = document.advice.k.value
document.getElementById(doves).innerHTML = document.advice.avviso.value.slice(0, 60);
document.advice.submit();
}
//-->
function conferma() {
if (document.gloss.definizione.value == "") {
alert("Inserire la definizione");
document.gloss.definizione.focus();
return false;
}
if (document.gloss.testo.value == "") {
alert("Inserire il testo");
document.gloss.testo.focus();
return false;
}
Richiesta(document.gloss.definizione.value + '_' + document.gloss.testo.value + '_' + document.gloss.idcorso.value, 'insert_glossario.asp', 'glossario');
}
//-->
function modifica() {
if (document.gloss.definizione.value == "") {
alert("Inserire la definizione");
document.gloss.definizione.focus();
return false;
}
if (document.gloss.testo.value == "") {
alert("Inserire il testo");
document.gloss.testo.focus();
return false;
}
Richiesta(document.gloss.definizione.value + '_' + document.gloss.testo.value + '_' + document.gloss.idcorso.value + '_' + document.gloss.idglossario.value + '_' + document.gloss.idlezione.value, 'update_glossario.asp', 'punti');
}
//-->
function showtr(t, cosa, s1, comp1, s2, comp2) {
document.getElementById(s1).style.display = comp1;
document.getElementById(s2).style.display = comp2;
var colore = document.getElementById(t);
var IE = (window.navigator.userAgent.indexOf('MSIE') > -1) ? 1 : 0;
if (t == 'tab') {
colore.style.display = (IE) ? 'block' : 'table-row';
} else {
colore.style.display = cosa;
}
}
function insavviso(dove, t, cosa, s1, comp1, s2, comp2) {
if (document.advice.avviso.value == "") {
alert("Inserire l'avviso");
document.advice.avviso.focus();
return false;
}
document.advice.submit();
}
function DropDownMenu(entered) {
// ********** DROP DOWN MENU (c) Henrik Petersen / NetKontoret - All rights reserved ****************
// The script is explained along with other useful scripts at: http://www.echoecho.com/javascript.htm
// You may freely use this script as long as you do not remove this line and the 2 lines above.
with (entered) {
ref = options[selectedIndex].value;
splitcharacter = ref.lastIndexOf("$");
if (splitcharacter != -1) {
loc = ref.substring(0, splitcharacter);
target = ref.substring(splitcharacter + 1, 1000).toLowerCase();
} else {
loc = ref;
target = "_self";
}
lowloc = loc.toLowerCase();
if (lowloc == "false")
return;
if (target == "_self") {
document.location = loc;
} else {
if (target == "_top")
top.location = loc;
else {
if (target == "_blank")
window.open(loc);
else {
if (target == "_parent")
parent.location = loc;
else
parent.frames[target].location = loc;
}
}
}
}
}
function cercaaziendaAtt() {
oscura()
$.ajax({
url: "/admin/lista_attestati.asp",
data: $("#inviaazienda").serialize(),
success: function (result) {
$("#spaziomsgAtt").html(result);
$(".data").datepicker();
$("table").addClass('tablesorter')
$('tr:odd').addClass('grigio');
$('tr:even').addClass('bianco');
$('div.clear:odd').addClass('grigio');
$('div.clear:even').addClass('bianco');
$("select").select2();
$(".select2-container").css("max-width", "350px");
$(".select2-container").css("min-width", "120px");
$("#linguas").select2('destroy');
$(".cosas").select2('destroy');
nooscura();
$(".idr").change(function () {
if ($('.idr').prop('checked')) {
id = $(this).val()
creaattestatoAll(id, 0, '')
} else {
//alert('no')
}
});
}
});
}
function removeid(id) {
$("#" + id).remove();
}
function creafile(url, div, file) {
$("#" + div).html('');
$.get(url, function (data, status) {
$.get('/admin/reportonline.asp?urlcompleto=' + url + '&filecompleto=' + file + '&div=' + div, function (data, status) {
$("#" + div).html('ok');
});
});
}
function senddatimail(email, id) {
if (email == '')
{
//$("#result").html(JSON.stringify(data))
allarme('email' + id, 'Inserire il numero di telefono ')
} else {
$.ajax({
url: "/ideastudio/sendutente.asp?idregistrazione_corso=" + id + "&email=" + email,
success: function (result) {
allarme('email' + id, result)
}
});
}
}
function checknuovasub() {
valore = $('#questasub').val()
if (valore == "nuovanuova")
{
$("#questasub").hide();
$("#nuovasub").show();
} else
{
$("#questasub").show();
$("#nuovasub").hide();
}
}
function trovasub(idazienda, idsegnalato, id) {
$("#sublocation" + id).html('');
idagenzia = $('#idagenzia' + id).val()
$.ajax({
url: "/u/trovasub.asp?idazienda=" + idazienda + "&idsegnalato=" + idsegnalato + "&idagenzia=" + idagenzia,
success: function (result) {
$("#sublocation" + id).html(result);
}
});
}
function senddatiwa(telefono, id, prefisso) {
if (telefono == '')
{
//$("#result").html(JSON.stringify(data))
allarme('telefono' + id, 'Inserire il numero di telefono ')
} else {
// Invia i dati di accesso al corso per WhatsApp (send.js), da /php/wa/send_wa.php (sostituisce /ideastudio/sendwa.asp, Maytapi eliminato)
$.ajax({
type: "post",
url: "/php/wa/send_wa.php",
contentType: "application/json",
dataType: "json",
data: JSON.stringify({ idregistrazione_corso: id, telefono: prefisso + telefono }),
success: function (result) {
if (result && result.success) {
allarme('telefono' + id, 'OK')
} else {
allarme('telefono' + id, 'KO ' + $('
').text((result && result.message) || '').html())
}
},
error: function (xhr) {
var m = '';
try { m = JSON.parse(xhr.responseText).message; } catch (e) { }
allarme('telefono' + id, 'KO ' + $('
').text(m || '').html())
}
});
}
}
function sendWA(id, cosa, tel, messaggio) {
var customer;
console.log(tel + ' ' + messaggio)
if (cosa == "sendFile") {
var allegapdf = $("#" + id + " #allegapdf").val();
if (allegapdf == "si") {
phone = $("#" + id + " #numero").val(),
testo = $("#" + id + " #link").val(),
filename = $("#" + id + " #file").val()
// send.js invia solo testo: il link al file viaggia nel messaggio (filename non piu usato)
waInvia(phone, testo,
function () { $("#result").html("OK") },
function (m) { $("#result").html("KO" + (m ? ": " + m : "")) });
}
}
phone = $("#" + id + " #numero").val(),
testo = $("#" + id + " #messaggio").val()
waInvia(phone, testo,
function () { $("#result").html("ok") },
function (m) { $("#result").html("ko" + (m ? ": " + m : "")) });
}
function addeventopercorso() {
idpercorsoformativo_eventi = $("#idpercorsoformativo_eventi").val()
if (idpercorsoformativo_eventi == "999999999") {
$('#eventocorso').show();
}
}
function cercaaziendaRep() {
$.ajax({
url: "/admin/lista_rep.asp",
data: $("#inviaazienda").serialize(),
success: function (result) {
$("#spaziomsgAtt").html(result);
$(".data").datepicker();
$("table").addClass('tablesorter')
$('tr:odd').addClass('grigio');
$('tr:even').addClass('bianco');
$('div.clear:odd').addClass('grigio');
$('div.clear:even').addClass('bianco');
$("select").select2();
$(".select2-container").css("max-width", "350px");
$(".select2-container").css("min-width", "120px");
$("#linguas").select2('destroy');
$(".cosas").select2('destroy');
$(".idr").change(function () {
if ($('.idr').prop('checked')) {
id = $(this).val()
creaattestatoAll(id, 0, '')
} else {
//alert('no')
}
});
}
});
}
function sendmailattivazione(idanagrafica) {
// Recupera la lingua dalla pagina (dovrai definire come ottenerla)
$.ajax({
url: '/u/sendMailAttivazione.asp',
type: 'GET',
data: {
lingua: 'ita',
idanagrafica: idanagrafica
},
success: function(response) {
console.log('Email di attivazione inviata con successo', response);
// Puoi aggiungere qui ulteriori azioni dopo il successo
},
error: function(xhr, status, error) {
console.error('Errore nell\'invio dell\'email di attivazione', error);
// Gestione degli errori
}
});
}
function ciao() {
for (var key in SCHEDULED_REQUEST) {
postRequest(SCHEDULED_REQUEST); /* post and empty SCHEDULED_REQUEST object */
for (var i = 0; i < 1000; i++) {
/* do something unnoticable but time consuming like writing a lot to console */
console.log('buying some time to finish saving data');
console.log('ciao');
$.ajax({
url: "/admin/log-out.asp?idanagrafica=" + tIdAnagrafica,
type: "GET",
success: function (result) {},
error: function (richiesta, stato, errori) {}
});
}
break;
}
}
$(document).ready(function () {
$(".allarga").mouseover(function () {
//$(this).css("background-color", "yellow");
var newWidth = parseInt($(this).width()) * 2;
$(this).width(newWidth);
//console.log($(this).width());
});
$(".allarga").mouseout(function () {
//$(this).css("background-color", "white");
$(this).width($(this).width() / 2);
});
});
function coloraFiltri() {
$(".select2-selection__rendered").each(function () {
var text = $(this).text();
if (text.indexOf(tScegli) < 0 && text.indexOf(tTutti) < 0 && text.indexOf('--') < 0) {
$(this).css("background-color", "LightBlue");
//$(this).css("color", "white");
}
});
}
document.addEventListener('DOMContentLoaded', function () {
const fileInput = document.getElementById('fileInput');
const fileSizeInfo = document.getElementById('fileSizeInfo');
const errorMessage = document.getElementById('errorMessage');
const submitButton = document.getElementById('submitButton');
const maxSizeInMB = 100; // Set maximum file size to 100 MB
if (!fileInput || !fileSizeInfo || !errorMessage || !submitButton) {
console.log("Required elements are missing from the DOM.");
return;
}
fileInput.addEventListener('change', function (event) {
// Get the selected file
const file = event.target.files[0];
if (file) {
// Get the file size in bytes
const fileSize = file.size;
// Convert the file size to megabytes (MB)
const fileSizeInMB = (fileSize / (1024 * 1024)).toFixed(2);
// Show the file size to the user
fileSizeInfo.textContent = `File size: ${fileSizeInMB} MB`;
// Check if the file size exceeds the maximum limit
if (fileSize > maxSizeInMB * 1024 * 1024) {
errorMessage.textContent = `The selected file is too large. The maximum allowed size is ${maxSizeInMB} MB.`;
// Reset the file input
event.target.value = '';
submitButton.disabled = true; // Disable the submit button
} else {
errorMessage.textContent = ''; // Clear any previous error messages
submitButton.disabled = false; // Enable the submit button
}
} else {
fileSizeInfo.textContent = '';
submitButton.disabled = true; // Disable the submit button
}
});
document.getElementById('uploadForm').addEventListener('submit', function (event) {
const file = fileInput.files[0];
if (file) {
// Verify the file size again before submitting the form
if (file.size > maxSizeInMB * 1024 * 1024) {
errorMessage.textContent = `The selected file is too large. The maximum allowed size is ${maxSizeInMB} MB.`;
event.preventDefault(); // Prevent the form from submitting
}
} else {
errorMessage.textContent = 'Please select a file before submitting the form.';
nooscura()
event.preventDefault(); // Prevent the form from submitting
}
});
});
function decodeHtmlEntities(text) {
// Definisci una regex per trovare i caratteri del tipo ';' e ';'
const regex = /(?:x([a-fA-F\d]+)|(\d+));/g;
return text.replace(regex, (match, hex, decimal) => {
// Converti il codice esadecimale o decimale in un carattere
if (hex) {
return String.fromCharCode(parseInt(hex, 16));
} else {
return String.fromCharCode(parseInt(decimal, 10));
}
});
}
function getCookie(name) {
const cookieValue = document.cookie
.split('; ')
.find(row => row.startsWith(name + '='))
?.split('=')[1];
if (!cookieValue) return null;
try {
return decodeURIComponent(cookieValue);
} catch (e) {
console.error('Failed to decode cookie:', e);
return null; // Return null or a default value
}
}
$(document).ready(function() {
var arabicPattern = /[\u0600-\u06FF\u0750-\u077F]/;
$('button,input,textarea,option,a,label,p, span, div, li, td, th, h1, h2, h3, h4, h5, h6').each(function() {
var $this = $(this);
var text = $this.text().trim();
if (text.length > 0 && arabicPattern.test(text) && !$this.attr('dir')) {
// CONTROLLO IMPORTANTE: contiene altri elementi figli?
if ($this.children().length > 0) {
// CASO 1: Div con elementi figli (icone, bottoni, etc.)
// Applica RTL solo al testo, non agli elementi figli
// Cerca nodi di testo diretti e avvolgili
$this.contents().filter(function() {
return this.nodeType === 3 && // Tipo testo
arabicPattern.test(this.textContent) &&
this.textContent.trim().length > 0;
}).wrap('');
// Ai span creati applica gli attributi
$this.find('.rtl-text-only')
.attr('lang', 'ar')
.attr('dir', 'rtl');
} else {
// CASO 2: Elemento semplice (solo testo)
$this
.addClass('rtl-text')
.attr('lang', 'ar')
.attr('dir', 'rtl');
}
}
});
});
function equalizeTableColumns(filtro) {
var $tables = $(filtro);
var colWidths = [];
var totalWidth = 0;
// Legge le larghezze dalla prima tabella
$tables.first().find("tr:first th, tr:first td").each(function() {
var w = $(this).outerWidth();
colWidths.push(w);
totalWidth += w;
});
// Converte in percentuali
var colPercents = colWidths.map(function(w) {
return (w / totalWidth * 100).toFixed(2) + "%";
});
// Applica a tutte le tabelle come percentuali
$tables.css("table-layout", "fixed");
$tables.each(function() {
$(this).find("tr").each(function() {
$(this).find("th, td").each(function(i) {
if (colPercents[i]) {
$(this).css("width", colPercents[i]);
}
});
});
});
}
function ModalMessage(message, mType, okLabel, cancelLabel) {
// se jQuery non esiste nel TOP, qui si rompe tutto
if (!window.jQuery) {
console.error('[ModalMessage] jQuery is missing');
return Promise.resolve(false);
}
var $ = window.jQuery;
return new Promise(function (resolve) {
/*
console.log('[ModalMessage] called:', {
message,
mType
});
*/
var msgCancel='Annulla';
var msgContinue='Continua';
var msgYes='SI';
var msgNo='NO';
var msgClose='Chiudi';
var modalDiv = `
`;
var $modal = $('#modalDiv');
if (!$modal.length) {
$('body').append(modalDiv);
$modal = $('#modalDiv');
}
var $text = $modal.find('#modalText');
var $ok = $modal.find('#modalOK');
var $cancel = $modal.find('#modalCancel');
/*
console.log('[ModalMessage] found:', {
ok: $ok.length,
cancel: $cancel.length,
text: $text.length
});
*/
if (!$ok.length || !$cancel.length || !$text.length) {
console.error('[ModalMessage] some elements are missing in the modal window');
resolve(false);
return;
}
if (mType === 'YesNo') {
$cancel.show().html(cancelLabel || msgNo);
$ok.html(okLabel || msgYes);
} else if (mType === 'alert') {
$cancel.hide();
$ok.html(okLabel || msgClose);
} else {
$cancel.show().html(cancelLabel || msgCancel);
$ok.html(okLabel || msgContinue);
}
// accetta anche numeri/undefined (come faceva alert) e i vecchi "\n" diventano a capo
message = (message === null || message === undefined) ? '' : String(message);
if (!/<[a-z][\s\S]*>/i.test(message)) message = message.replace(/\r?\n/g, ' ');
$text.html(message);
// una sola finestra riusata: se ne era rimasta una aperta, la chiude (false) cosi' la sua promise non resta appesa
if (window._modalPrevSettle) window._modalPrevSettle(false);
// pulizia binding
$(document).off('keydown.modalDiv');
$ok.off('click');
$cancel.off('click');
var settled = false;
function settle(val) {
if (settled)
return;
settled = true;
$modal.hide();
$(document).off('keydown.modalDiv');
//console.log('[ModalMessage] resolved:', val);
resolve(val);
}
window._modalPrevSettle = settle;
$ok.on('click', function () {
settle(true);
});
$cancel.on('click', function () {
settle(false);
});
$(document).on('keydown.modalDiv', function (e) {
if (e.key === 'Escape')
settle(false);
});
$modal.show();
$ok.trigger('focus'); // Invio chiude l'avviso, come con alert()
});
}
async function alertModal(message, okLabel) {
return await ModalMessage(message, 'alert', okLabel);
}
async function confirmModal(message, okLabel, cancelLabel) {
return await ModalMessage(message, 'confirm', okLabel, cancelLabel);
}
async function yesNoModal(message, okLabel, cancelLabel) {
return await ModalMessage(message, 'YesNo', okLabel, cancelLabel);
}
window.alertModal = alertModal;
window.confirmModal = confirmModal;
window.yesNoModal = yesNoModal;
function sostituisciIscrizioneTIRT(url, idanagrafica, btn, onSuccess) {
var $btn = $(btn);
$btn.prop('disabled', true);
$.ajax({
url: url,
success: function (result) {
var $result = $('
').html(result);
if ($result.find('#enrolmentStatus.KO').length) {
if ($('#modalText').length) {
$('#modalText').html(result);
}
} else {
$('#idanagrafica' + idanagrafica).prop('checked', true).prop('disabled', true);
var hasModal = $('#modalDiv').length > 0;
if (hasModal) {
$('#modalDiv').hide();
}
if (typeof onSuccess === 'function') {
onSuccess();
return;
}
var $cell = $btn.closest('td');
if ($cell.length) {
$cell.html('CONFERMATO');
} else if (!hasModal) {
location.reload();
}
}
},
error: function (xhr) {
if ($('#modalText').length) {
$('#modalText').html(xhr.responseText);
}
},
complete: function () {
$btn.prop('disabled', false);
}
});
}
window.sostituisciIscrizioneTIRT = sostituisciIscrizioneTIRT;
function gestisciBox() {
$('.anteprimacorso .box').each(function () {
var $box = $(this);
var $buttons = $box.find('button.btn');
if (!$buttons.length) return;
var rightOffset = 0;
// Posiziona da destra a sinistra
$($buttons.get().reverse()).each(function () {
$(this).css('right', rightOffset);
rightOffset += $(this).outerWidth(true) + 4;
});
});
$('.anteprimacorso').on('mouseenter', function () {
var $el = $(this);
if ($el.data('clone'))
return;
// Tick
var tick = new Audio('/public/Button-Click-basso.mp3');
tick.volume = 0.5;
tick.play();
var offset = $el.offset();
var scrollTop = $(window).scrollTop();
var w = $el.outerWidth();
var h = $el.outerHeight();
var eventW = $el.find('.event').outerWidth();
var eventH = $el.find('.event').outerHeight() || h;
// scrollHeight dà l'altezza reale del contenuto senza toccare il DOM
var altezzaPiena = Math.max(h, $el.find('.box')[0].scrollHeight);
var $clone = $el.clone(false)
.removeClass('anteprimacorso')
.addClass('anteprima-clone')
.css({
position: 'fixed',
top: offset.top - scrollTop,
left: offset.left,
width: w,
height: h+4,
margin: 0,
padding: 2, // ? questo era il problema
zIndex: 99999,
overflow: 'hidden',
background:'#fff',
boxShadow: '0 0 0 2px #c0cdd5, 0 0 18px rgba(0,0,0,0.5)'
})
.appendTo('body');
// Flexbox per le colonne
$clone.find('.panel-widget').css({
display: 'flex',
alignItems: 'flex-start'
});
$clone.find('.event').css({
float: 'none',
width: eventW,
minHeight: eventH,
flexShrink: 0
});
$clone.find('.col-sm-7').css({
float: 'none',
flex: '1 1 auto'
});
// p.box rimane position:absolute - zero problemi di padding
// Clone e p.box animano insieme verso la stessa altezza
$el.data('clone', $clone);
$el.css('visibility', 'hidden');
$clone.animate({
height: altezzaPiena+4
}, {
duration: 350,
queue: false
});
$clone.find('.box').animate({
height: altezzaPiena
}, {
duration: 350,
queue: false,
complete: function () {
$(this).css('overflow', 'visible');
$clone.css('overflow', 'visible');
}
});
$clone.on('mouseleave', function () {
$clone.find('.box').stop(true)
.css('overflow', 'hidden')
.animate({
height: '120px'
}, {
duration: 250,
queue: false
});
$clone.stop(true).animate({
height: h+4
}, {
duration: 250,
queue: false,
complete: function () {
$(this).remove();
$el.css('visibility', '');
$el.removeData('clone');
}
});
});
});
$(window).on('scroll', function () {
$('.anteprimacorso').each(function () {
var $el = $(this);
var $clone = $el.data('clone');
if ($clone) {
$clone.stop(true).remove();
$el.css('visibility', '');
$el.removeData('clone');
}
});
});
}
window.gestisciBox = gestisciBox;