Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
2414 righe
78 KiB
2414 righe
78 KiB
window.CKEDITOR = []; |
|
|
|
window.htmlentities = { |
|
/** |
|
* Converts a string to its html characters completely. |
|
* |
|
* @param {String} str String with unescaped HTML characters |
|
**/ |
|
encode : function(str) { |
|
var buf = []; |
|
|
|
for (var i=str.length-1;i>=0;i--) { |
|
buf.unshift(['&#', str[i].charCodeAt(), ';'].join('')); |
|
} |
|
|
|
return buf.join(''); |
|
}, |
|
/** |
|
* Converts an html characterSet into its original character. |
|
* |
|
* @param {String} str htmlSet entities |
|
**/ |
|
decode : function(str) { |
|
return str.replace(/&#(\d+);/g, function(match, dec) { |
|
return String.fromCharCode(dec); |
|
}); |
|
} |
|
}; |
|
|
|
var goToFilter = function () { |
|
var collapsible = $('.collapse'); |
|
if(collapsible.length > 0) { |
|
$('.collapse').on('shown.bs.collapse', function () { |
|
$(this).scrollIntoView(); |
|
// $('body, main').animate({ |
|
// scrollTop: $('.collapse').offset().top - $('.collapse').outerHeight() |
|
// }, 2000); |
|
}) |
|
} |
|
} |
|
|
|
$.fn.scrollBottom = function() { |
|
return $(document).height() - this.scrollTop() - this.height(); |
|
}; |
|
|
|
var affixTop = function() { |
|
var commands = $('#commands'); |
|
var passed = false; |
|
var state = null; |
|
if(commands.length > 0) { |
|
$('main').scroll(function() { |
|
passed = commands.offset().top < 62 ? true : false; |
|
if(passed !== state) { |
|
if(passed) { |
|
$('#commands').addClass('bg-secondary py-2 shadow-sm').css('margin-left','-1rem').css('margin-right','-1rem'); |
|
} else { |
|
$('#commands').removeClass('bg-secondary py-2 shadow-sm').css('margin-left','0').css('margin-right','0'); |
|
} |
|
} |
|
}); |
|
} |
|
} |
|
|
|
var drawertoogle = function () { |
|
$('[data-toogle="drawer"]').on('click', function (e) { |
|
e.preventDefault(); |
|
if($('body').hasClass('drawer-out')) { |
|
$('body').toggleClass('drawer-out'); |
|
} else { |
|
if($('body').hasClass('drawer-in') || $('aside').css('left') == '-140px') { |
|
$('body').toggleClass('drawer-in'); |
|
} else { |
|
$('body').toggleClass('drawer-out'); |
|
} |
|
} |
|
}); |
|
} |
|
|
|
var __movedModal = []; |
|
|
|
var fixModal = function fixModal() { |
|
var modal = $('.modal').not('.not-moving-modal'); |
|
|
|
if (modal.length > 0) { |
|
for (var i = modal.length - 1; i >= 0; i--) { |
|
if (__movedModal.indexOf($(modal[i]).attr('id')) === -1) { |
|
$('body').append($(modal[i])); |
|
__movedModal.push($(modal[i]).attr('id')); |
|
} |
|
} |
|
} |
|
}; |
|
|
|
|
|
setPreferito = function(codice) { |
|
$.ajax({ |
|
url: "/backend/utenti/setPreferito.php", |
|
data: { |
|
"codice": codice |
|
}, |
|
method: "post", |
|
dataType: "script", |
|
async: true, |
|
success: function(script) { |
|
script |
|
} |
|
}); |
|
} |
|
|
|
String.prototype.padRight = function(l, c) { |
|
return this + Array(l - this.length + 1).join(c || " "); |
|
}; |
|
|
|
Array.prototype.clean = function(deleteValue) { |
|
for (var i = 0; i < this.length; i++) { |
|
if (this[i] == deleteValue) { |
|
this.splice(i, 1); |
|
i--; |
|
} |
|
} |
|
return this; |
|
}; |
|
|
|
|
|
CPVloadTree = function(codice,id,data,custom) { |
|
url = "loadCustomTree.php"; |
|
prefix = "custom"; |
|
if (typeof custom !== "boolean") { |
|
url = "loadTree.php"; |
|
prefix = "cpv"; |
|
} |
|
list_id = "#" + id + "-"+prefix+"-list-"+codice; |
|
var selezionate = []; |
|
$(".selected-"+prefix,"#"+id+"-"+prefix+"-list").each(function(){ selezionate.push($(this).val());}); |
|
$(".selected-"+prefix,"#"+id+"-"+prefix+"-list-external").each(function(){ selezionate.push($(this).val());}); |
|
selezionate = btoa(selezionate.join(";")); |
|
data = data + "&selezionate=" + selezionate; |
|
if ($(list_id).html().trim() !== "") { |
|
$(list_id).slideToggle('fast'); |
|
if ($(list_id+"-caret").hasClass('fa-rotate-90')) { |
|
$(list_id+"-caret").removeClass('fa-rotate-90'); |
|
} else { |
|
$(list_id+"-caret").addClass('fa-rotate-90'); |
|
} |
|
} else { |
|
$(list_id).load("/inc/cpv/"+url+"?"+data,function() { |
|
$(list_id).slideDown('fast'); |
|
$(list_id+"-caret").addClass('fa-rotate-90'); |
|
}); |
|
} |
|
} |
|
|
|
addCPV = function(codice,id,data,custom) { |
|
url = "addCustom.php"; |
|
prefix = "custom"; |
|
if (typeof custom !== "boolean") { |
|
url = "addCPV.php"; |
|
prefix = "cpv"; |
|
} |
|
list_id = "#" + id + "-"+prefix+"-list"; |
|
$.ajax({ |
|
url: "/inc/cpv/"+url+"?"+data, |
|
dataType: "html", |
|
async: false, |
|
success: function(script) { |
|
if ($("#" + id + "-"+prefix+"-in-"+codice).length == 0) { |
|
if (prefix == "cpv") { |
|
$(".selected-cpv",list_id).each(function(){ |
|
if ($(this).val().indexOf(codice) === 0) $(this).parent().find('button').trigger("click"); |
|
}); |
|
} else { |
|
$(".selected-custom",list_id).each(function(){ |
|
element = $(this); |
|
$.ajax({ |
|
url: "/inc/cpv/derivation.php?codice="+element.val(), |
|
dataType: 'json', |
|
async: false, |
|
success: function(data) { |
|
if (data.indexOf(codice) != -1) element.parent().find('button').trigger("click"); |
|
} |
|
}); |
|
}); |
|
} |
|
$(list_id).parent().slideDown(); |
|
$(list_id).append(script); |
|
$("#" + id + "-"+prefix+"-"+codice).slideUp('fast'); |
|
$("#" + id + "-"+prefix+"-filter").typeahead('val', ''); |
|
} |
|
} |
|
}); |
|
} |
|
|
|
showCompany = function(codice) { |
|
showModalWithURL("/backend/operatori_economici/details.php?codice="+codice); |
|
} |
|
|
|
showMSG = function(codice) { |
|
showModalWithURL("/comunicazioni/details.php?codice="+codice); |
|
} |
|
|
|
refreshModalHelper = function() { |
|
if (modalURL.length > 0) { |
|
url = modalURL[modalURL.length-1]; |
|
modalURL.splice(-1,1); |
|
showModalWithURL(url); |
|
} |
|
} |
|
|
|
backModalHelper = function() { |
|
if (modalURL.length > 0) { |
|
modalURL.splice(-1,1); |
|
url = modalURL[modalURL.length-1]; |
|
if (typeof url != "undefined") { |
|
showModalWithURL(url); |
|
} else { |
|
$("#modal-helper").modal('hide'); |
|
} |
|
} |
|
} |
|
|
|
var modalURL = []; |
|
var googleMaps = []; |
|
|
|
showModalWithURL = function(url) { |
|
if ($.inArray(url, modalURL)==-1) modalURL.push(url); |
|
$("#wait_div").show(); |
|
$.ajax({ |
|
url: url, |
|
dataType: "html", |
|
success: function(result) { |
|
$("#wait_div").hide(); |
|
$(".modal-body","#modal-helper").html(result); |
|
$("#modal-helper").modal(); |
|
$("#modal-helper").on("hidden.bs.modal", function () { |
|
modalURL = []; |
|
}); |
|
f_ready(); |
|
$("#modal-helper").on('shown.bs.modal',function() { |
|
if (googleMaps.length > 0) { |
|
for(i=0;i<=googleMaps.length;i++) { |
|
currentMap = googleMaps[i]; |
|
google.maps.event.trigger(currentMap, "resize"); |
|
} |
|
} |
|
}); |
|
if (modalURL.length > 1) { |
|
$("#modal-helper-back-button").show(); |
|
} else { |
|
$("#modal-helper-back-button").hide(); |
|
} |
|
}, |
|
error: function() { |
|
$("#wait_div").hide(); |
|
modalURL.splice(-1,1); |
|
swal(js_dict["error-retry"]); |
|
} |
|
}); |
|
} |
|
|
|
sendICRequest = function(codice) { |
|
if (typeof codice === 'undefined') codice = 0; |
|
var url = "/backend/infocamere/find.php"; |
|
if (codice > 0) { |
|
url = "/backend/infocamere/select.php?oe="+codice; |
|
} |
|
showModalWithURL(url); |
|
} |
|
|
|
atokaSearchModal = function() { |
|
showModalWithURL('/backend/atoka/find.php'); |
|
} |
|
|
|
sevendataSearchModal = function() { |
|
showModalWithURL('/backend/sevendata/find.php'); |
|
} |
|
|
|
sendCribisRequest = function(codice) { |
|
if (typeof codice === 'undefined') codice = 0; |
|
var url = "/backend/cribis/find.php"; |
|
if (codice > 0) { |
|
url = "/backend/cribis/select.php?azienda="+codice; |
|
} |
|
showModalWithURL(url); |
|
} |
|
|
|
sendComunicazione = function(sezione,elemento,destinatario,sub_elemento,codice_pec) { |
|
if (typeof sub_elemento == "undefined") sub_elemento = 0; |
|
if (typeof codice_pec == "undefined") codice_pec = 0; |
|
showModalWithURL('/backend/comunicazioni/form.php?codice_pec='+codice_pec+'&sezione='+sezione+'&sub_elemento='+sub_elemento+'&codice_elemento='+elemento+'&destinatari='+destinatario); |
|
} |
|
|
|
openChat = function(sezione,elemento,ente,sub_elemento) { |
|
if (typeof sub_elemento == "undefined") { |
|
sub_elemento = 0; |
|
} |
|
if (typeof ente == "undefined") { |
|
ente = 0; |
|
} |
|
showModalWithURL('/backend/comunicazioni/chat.php?ente='+ente+'&sezione='+sezione+'&sub_elemento='+sub_elemento+'&codice_elemento='+elemento); |
|
} |
|
|
|
managePermessi = function(sezione,elemento,ente) { |
|
showModalWithURL('/backend/utenti/permessi/specific/list.php?sezione='+sezione+'&codice_elemento='+elemento+'&ente='+ente); |
|
} |
|
|
|
filtra = function(soggetto,contesto,elemento) { |
|
if (typeof soggetto !== 'undefined' && typeof contesto !== 'undefined' && typeof elemento !== 'undefined') { |
|
if ($(contesto).length > 0) { |
|
if (soggetto.length > 0) { |
|
$(elemento,contesto).hide(); |
|
$(elemento+":contains('"+soggetto+"')",contesto).show(); |
|
} else if (soggetto.length === 0) { |
|
$(elemento,contesto).show(); |
|
} |
|
} |
|
} |
|
} |
|
|
|
addCommas = function(nStr) { |
|
nStr += ''; |
|
x = nStr.split('.'); |
|
x1 = x[0]; |
|
x2 = x.length > 1 ? ',' + x[1] : ',00'; |
|
var rgx = /(\d+)(\d{3})/; |
|
while (rgx.test(x1)) { |
|
x1 = x1.replace(rgx, '$1' + '.' + '$2'); |
|
} |
|
x2 = x2.padRight(3, "0"); |
|
return x1 + x2; |
|
} |
|
var id_inserimento = 0; |
|
aggiungi = function(url, target, param) { |
|
id_inserimento++; |
|
param = typeof param !== 'undefined' ? param : {}; |
|
data = {id:"i_"+ id_inserimento, target: target, param: param}; |
|
$.ajax({ |
|
type: "POST", |
|
url: url, |
|
dataType: "html", |
|
data: data, |
|
async: false, |
|
success: function(script) { |
|
$(target).append(script); |
|
} |
|
}); |
|
f_ready(); |
|
etichette_testo(); |
|
} |
|
|
|
sanitize_string = function(string) { |
|
string = string.replace(/[^a-zA-Z0-9\.\/_|+ -]/g,''); |
|
string = string.toLowerCase(); |
|
string = string.replace(/[\/_|+ -]+/g,'-'); |
|
string = string.replace('..','.'); |
|
return string; |
|
} |
|
|
|
number_format = function(number, decimals, dec_point, thousands_sep) { |
|
number = (number + '').replace(/[^0-9+\-Ee.]/g, ''); |
|
var n = !isFinite(+number) ? 0 : +number, |
|
prec = !isFinite(+decimals) ? 0 : Math.abs(decimals), |
|
sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep, |
|
dec = (typeof dec_point === 'undefined') ? '.' : dec_point, |
|
s = '', |
|
toFixedFix = function(n, prec) { |
|
var k = Math.pow(10, prec); |
|
return '' + (Math.round(n * k) / k).toFixed(prec); |
|
}; |
|
// Fix for IE parseFloat(0.55).toFixed(0) = 0; |
|
s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.'); |
|
if (s[0].length > 3) { |
|
s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep); |
|
} |
|
if ((s[1] || '').length < prec) { |
|
s[1] = s[1] || ''; |
|
s[1] += new Array(prec - s[1].length + 1).join('0'); |
|
} |
|
return s.join(dec); |
|
} |
|
|
|
etichette_testo = function() { |
|
// Inserisce il titolo dei tag input nel placeholder |
|
$("* :input").each(function() { |
|
$(this).attr("placeholder", $(this).attr("title")); |
|
}); |
|
} |
|
|
|
eliminaP = function(codice, modulo, other) { |
|
Swal({ |
|
title: js_dict["sei-sicuro"], |
|
text: js_dict["msg-conferma"], |
|
type: "error", |
|
showCancelButton: true, |
|
confirmButtonColor: 'var(--success)', |
|
cancelButtonColor: 'var(--danger)', |
|
confirmButtonText: js_dict.conferma, |
|
cancelButtonText: js_dict.annulla, |
|
closeOnConfirm: true |
|
}).then((result) => { |
|
if (result.value) { |
|
data = "codice=" + codice + "&modulo=" + modulo; |
|
if (typeof other !== 'undefined') data += "&" + other; |
|
$.ajax({ |
|
type: "POST", |
|
url: "/" + modulo + "/delete.php", |
|
data: data, |
|
dataType: "script", |
|
success: function(result) { |
|
result; |
|
}, |
|
error: function() { |
|
swal(js_dict["error-retry"]); |
|
} |
|
}); |
|
} |
|
}); |
|
return false; |
|
} |
|
elimina = function(codice, modulo, other, callback) { |
|
Swal({ |
|
title: js_dict["sei-sicuro"], |
|
text: js_dict["msg-conferma"], |
|
type: "error", |
|
showCancelButton: true, |
|
confirmButtonColor: 'var(--success)', |
|
cancelButtonColor: 'var(--danger)', |
|
confirmButtonText: js_dict.conferma, |
|
cancelButtonText: js_dict.annulla, |
|
closeOnConfirm: true |
|
}).then((result) => { |
|
if (result.value) { |
|
data = "codice=" + codice + "&modulo=" + modulo; |
|
if (typeof other !== 'undefined') data += "&" + other; |
|
$.ajax({ |
|
type: "POST", |
|
url: "/backend/" + modulo + "/delete.php", |
|
data: data, |
|
dataType: "script", |
|
success: function(result) { |
|
result; |
|
if(typeof callback !== 'undefined') { |
|
callback(); |
|
} |
|
}, |
|
error: function() { |
|
swal(js_dict["error-retry"]); |
|
} |
|
}); |
|
} |
|
}); |
|
return false; |
|
} |
|
|
|
confirmBeforeSubmit = function(codice, path, other) { |
|
Swal({ |
|
title: js_dict["sei-sicuro"], |
|
text: js_dict["msg-conferma"], |
|
type: "warning", |
|
showCancelButton: true, |
|
confirmButtonColor: 'var(--success)', |
|
cancelButtonColor: 'var(--danger)', |
|
confirmButtonText: js_dict.conferma, |
|
cancelButtonText: js_dict.annulla, |
|
closeOnConfirm: true |
|
}).then((result) => { |
|
if (result.value) { |
|
data = "codice=" + codice; |
|
if (typeof other !== 'undefined') data += "&" + other; |
|
$.ajax({ |
|
type: "POST", |
|
url: path, |
|
data: data, |
|
dataType: "script", |
|
success: function(result) { |
|
result; |
|
}, |
|
error: function() { |
|
swal(js_dict["error-retry"]); |
|
} |
|
}); |
|
} |
|
}); |
|
return false; |
|
} |
|
|
|
confirmBeforeSubmitForm = function(msg,form) { |
|
Swal({ |
|
title: js_dict["sei-sicuro"], |
|
text: msg, |
|
type: "warning", |
|
showCancelButton: true, |
|
confirmButtonColor: 'var(--success)', |
|
cancelButtonColor: 'var(--danger)', |
|
confirmButtonText: js_dict.conferma, |
|
cancelButtonText: js_dict.annulla, |
|
closeOnConfirm: true |
|
}).then((result) => { |
|
if (result.value) { |
|
$("#"+form).submit() |
|
} |
|
}); |
|
} |
|
|
|
disabilitaP = function(codice, modulo, other) { |
|
Swal({ |
|
title: js_dict["sei-sicuro"], |
|
text: js_dict["msg-conferma"], |
|
type: "warning", |
|
showCancelButton: true, |
|
confirmButtonColor: 'var(--success)', |
|
cancelButtonColor: 'var(--danger)', |
|
confirmButtonText: js_dict.conferma, |
|
cancelButtonText: js_dict.annulla, |
|
closeOnConfirm: true |
|
}).then((result) => { |
|
if (result.value) { |
|
data = "codice=" + codice + "&modulo=" + modulo; |
|
if (typeof other !== 'undefined') data += "&" + other; |
|
$.ajax({ |
|
type: "POST", |
|
url: "/" + modulo + "/disable.php", |
|
data: data, |
|
dataType: "script", |
|
success: function(result) { |
|
result; |
|
}, |
|
error: function() { |
|
swal(js_dict["error-retry"]); |
|
} |
|
}); |
|
} |
|
}); |
|
return false; |
|
} |
|
|
|
|
|
disabilita = function(codice, modulo, other) { |
|
Swal({ |
|
title: js_dict["sei-sicuro"], |
|
text: js_dict["msg-conferma"], |
|
type: "warning", |
|
showCancelButton: true, |
|
confirmButtonColor: 'var(--success)', |
|
cancelButtonColor: 'var(--danger)', |
|
confirmButtonText: js_dict.conferma, |
|
cancelButtonText: js_dict.annulla, |
|
closeOnConfirm: true |
|
}).then((result) => { |
|
if (result.value) { |
|
data = "codice=" + codice + "&modulo=" + modulo; |
|
if (typeof other !== 'undefined') data += "&" + other; |
|
$.ajax({ |
|
type: "POST", |
|
url: "/backend/" + modulo + "/disable.php", |
|
data: data, |
|
dataType: "script", |
|
success: function(result) { |
|
result; |
|
}, |
|
error: function() { |
|
swal(js_dict["error-retry"]); |
|
} |
|
}); |
|
} |
|
}); |
|
return false; |
|
} |
|
|
|
isNumeric = function(n) { |
|
return !isNaN(parseFloat(n)) && isFinite(n); |
|
} |
|
|
|
fill_relazioni = function(input, ambito) { |
|
var relazioni = $(input).val(); |
|
if (relazioni !== undefined) { |
|
relazioni = relazioni.split(";"); |
|
} |
|
$(ambito).find(".bt_relazione").each(function() { |
|
$(this).attr("checked", false); |
|
codice = $(this).attr("name"); |
|
if ($.inArray(codice, relazioni) != -1) { |
|
if ($(this).is("button")) { |
|
$(this).addClass("attivo"); |
|
} else { |
|
$(this).attr("checked", true); |
|
} |
|
} |
|
}); |
|
} |
|
|
|
check_error_tabs = function() { |
|
$('.card-header, .card').removeClass("bg-danger text-white"); |
|
$(".card").each(function(index, element) { |
|
if ($(this).find(".invalid-feedback").length > 0) { |
|
$(this).children('.card-header').addClass('bg-danger text-white'); |
|
} |
|
}); |
|
} |
|
|
|
toTimestamp = function(string) { |
|
array_string = string.split(" "); |
|
if (array_string.length == 1) array_string[1] = "00:00"; |
|
time_array = array_string[1].split(":"); |
|
date_array = array_string[0].split("/"); |
|
var datum = new Date(Date.UTC(date_array[2], date_array[1] - 1, date_array[0], time_array[0], time_array[1], 0)); |
|
return datum.getTime() / 1000; |
|
} |
|
|
|
completeVat = function(vat, country, destinazione) { |
|
data = "countryCode=" + country + "&vatNumber=" + vat; |
|
$.ajax({ |
|
type: "POST", |
|
url: "/complete_vat.php", |
|
data: data, |
|
async: false, |
|
dataType: "html", |
|
success: function(script) { |
|
if (script !== "") { |
|
$("#" + destinazione).val(script); |
|
} |
|
} |
|
}); |
|
} |
|
|
|
const RandExp = require('randexp'); |
|
const feelin = require('feelin'); |
|
window.feelin = feelin; |
|
|
|
valida = function(input) { |
|
|
|
var msg = []; |
|
input.parents(".form-group").first().removeClass("text-danger"); |
|
input.removeClass('is-invalid'); |
|
input.parents(".form-group").first().find(".invalid-feedback").remove(); |
|
var label_id = input.attr("id"); |
|
|
|
if ((typeof label_id === "undefined" || label_id.length < 1) && typeof input.attr("name") !== "undefined") { |
|
label_id = input.attr("name").replace(/\]/g, '_').replace(/\[/g, '_').replace(/\:/g, '_').replace(/\$/g, '_').replace(/\'/g, '_'); |
|
} |
|
|
|
$("#alert_" + label_id).remove(); |
|
//$("#note_" + label_id).remove(); |
|
|
|
var errore = false; |
|
var controlla = true; |
|
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,20})?$/; // espressione regolare per il controllo del formato della mail |
|
|
|
var dataReg = /^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/; // espressione regolare per il controllo del formato della data |
|
|
|
var timeReg = /^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/; // espressione regolare per il controllo del formato della data |
|
|
|
var dateTimeReg = /^[0-9]{2}\/[0-9]{2}\/[0-9]{4}\s\d([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$/; |
|
var imgReg = /\.(gif|jpg|jpeg|png)$/; // espressione regolare per il controllo dei file immagine |
|
|
|
var allReg = /\.(jpg|jpeg|png|gif|doc|xls|pdf|rtf|zip|rar|ods|odt|JPG|JPEG|PNG|GIF|DOC|XLS|PDF|ZIP|RAR|ODS|ODT)$/; // espressione regolare per il controllo dei file allegati |
|
|
|
var allPReg = /\.(p7m|pdf|zip|P7M|PDF|ZIP)$/; // espressione regolare per il controllo dei file allegati |
|
|
|
var SignReg = /\.(p7m|P7M)$/; // espressione regolare per il controllo dei file allegati |
|
|
|
var csvReg = /\.(csv)$/; // espressione regolare per il controllo dei file allegati |
|
|
|
var videoReg = /^(?:https?:\/\/)?(?:www\.)?youtube\.com\/watch\?(?=.*v=((\w|-){11}))(?:\S+)?$/; // espressione regolare per il controllo dei video Youtube |
|
|
|
var urlReg = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/; // espressione regolare per il controllo dei link |
|
|
|
var cfReg = /^([a-zA-Z]{6}[0-9]{2}[a-zA-Z][0-9]{2}[a-zA-Z][0-9a-zA-Z]{3}[a-zA-Z]|[0-9]{9,13}|[0-9]{8}[a-zA-Z]{1}|[a-zA-Z]{1}[0-9]{7}[a-zA-Z]{1}|[0-9]{7}[a-zA-Z]{1,2})$/; |
|
var ibanReg = /^[a-zA-Z]{2}[0-9]{2}[a-zA-Z0-9]{4}[0-9]{7}([a-zA-Z0-9]?){0,16}$/; // var pivaReg = /^[0-9]{11}$/; |
|
|
|
var pivaReg = /^((AT)?U[0-9]{8}|(BE)?0[0-9]{9}|(BG)?[0-9]{9,10}|(HR)?[0-9]{11}|(CY)?[0-9]{8}L|(CZ)?[0-9]{8,10}|(DE)?[0-9]{9}|(DK)?[0-9]{8}|(EE)?[0-9]{9}|(EL|GR)?[0-9]{9}|(ES)?[0-9A-Z][0-9]{7}[0-9A-Z]|(FI)?[0-9]{8}|(FR)?[0-9A-Z]{2}[0-9]{9}|(GB)?([0-9]{9}([0-9]{3})?|[A-Z]{2}[0-9]{3})|(HU)?[0-9]{8}|(IE)?[0-9]S[0-9]{5}L|(IE)?[0-9]{7}S|(IT)?[0-9]{11}|(LT)?([0-9]{9}|[0-9]{12})|(LU)?[0-9]{8}|(LV)?[0-9]{11}|(MT)?[0-9]{8}|(NL)?[0-9]{9}B[0-9]{2}|(PL)?[0-9]{10}|(PT)?[0-9]{9}|(RO)?[0-9]{2,10}|(SE)?[0-9]{12}|(SI)?[0-9]{8}|(SK)?[0-9]{1})$/; // acquisizione dei controlli da effettuare sul campo specificati nella proprietà rel del singolo input |
|
// se tale proprietà non è stata inserita il controllo sul campo non sarà effettuato. |
|
|
|
var explodeCommaReg = /^[0-9,]*$/ |
|
var explodeCommaReg2 = /^([0-9,]{0,3})(,\s*[0-9,]{0,3})*$/; |
|
|
|
var controlli_str = input.attr("rel"); |
|
|
|
|
|
|
|
if (input.is(':disabled') || input.attr('disabled') || input.prop('disabled')) { controlli_str = undefined; } |
|
|
|
|
|
if (typeof controlli_str !== "undefined") { |
|
if (input.val() === null) input.val(""); |
|
var replacedBSP = input.val(); |
|
if (typeof replacedBSP === "string") { |
|
replacedBSP = replacedBSP.replaceAll(" ", " "); |
|
input.val(replacedBSP); |
|
} |
|
if (!$.isArray(input.val())) input.val($.trim(input.val())); |
|
|
|
if (input.val() === null) { |
|
msg.push("<strong>" + input.attr("title") + " " + js_dict.obbligatorio + "</strong>"); |
|
errore = true; |
|
} else { |
|
var controlli = controlli_str.split(";"); |
|
|
|
if (controlli.length >= 4) { |
|
var obbligatorio = controlli[0]; |
|
var lunghezza_minima = controlli[1]; |
|
var lunghezza_massima = controlli[2]; |
|
var tipo = controlli[3]; |
|
|
|
if (typeof controlli[4] !== 'undefined' && controlli[4] !== '') { |
|
if (controlli[4].slice(-3) == "php") { |
|
data = "valore=" + input.val(); |
|
if (typeof input.data('codice') !== "undefined") data += "&codice=" + input.data('codice'); |
|
input.after("<span class='fa fa-spinner fa-spin' id='load_" + label_id + "'></span>"); |
|
$.ajax({ |
|
type: "POST", |
|
url: controlli[4], |
|
data: data, |
|
dataType: "html", |
|
async: false, |
|
success: function success(script) { |
|
if (script !== "") { |
|
msg.push(script); |
|
errore = true; |
|
} |
|
}, |
|
error: function error() { |
|
msg.push(js_dict["errore-validazione"]); |
|
errore = true; |
|
} |
|
}); |
|
$("#load_" + label_id).remove(); |
|
} else { |
|
var valore = input.val(); |
|
var riferimento = controlli[4]; |
|
var operatore = "="; |
|
var input_riferimento = ""; |
|
|
|
if (riferimento.indexOf(" ") === -1) { |
|
if ($("#" + controlli[4]).length > 0) { |
|
input_riferimento = $("#" + controlli[4]); |
|
riferimento = input_riferimento.val(); |
|
} |
|
} |
|
riferimento_echo = riferimento; |
|
if ((tipo == "D" || tipo == "T" || tipo == "DT") && typeof riferimento != 'undefined') { |
|
riferimento = toTimestamp(riferimento); |
|
valore = toTimestamp(valore); |
|
} else if (tipo == "checked" && riferimento == "group_validate" && typeof riferimento != 'undefined') { |
|
controlla = false; |
|
if (obbligatorio == 'S') { |
|
if (input.find("input:checked").length === 0) { |
|
msg.push("<strong>" + input.attr("title") + " " + js_dict.obbligatorio + "</strong>"); |
|
errore = true; |
|
} |
|
} |
|
$("#load_" + label_id).remove(); |
|
} else if (tipo == "checked" && riferimento == "group_one" && typeof riferimento != 'undefined') { |
|
controlla = false; |
|
let radios = input.find("input:checked"); |
|
let radio_groups = {}; |
|
$(radios).each(function(){ |
|
if (! ($(this).attr("name") in radio_groups)) { |
|
radio_groups[$(this).attr("name")] = []; |
|
} |
|
radio_groups[$(this).attr("name")].push($(this)); |
|
}) |
|
if (jQuery.isEmptyObject(radio_groups)) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["nessun-elemento-selezionato"]); |
|
errore = true; |
|
} |
|
Object.entries(radio_groups).forEach(entry => { |
|
const [key, inputs] = entry; |
|
if (obbligatorio == "S" && inputs.length != 1) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["errore-compilazione"]); |
|
errore = true; |
|
} else if (inputs.length > 1) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["errore-compilazione"]); |
|
errore = true; |
|
} |
|
}); |
|
} else if (tipo == "required_if_empty" && $("#" + controlli[4]).length > 0) { |
|
controlla = false; |
|
if ($("#" + controlli[4]).val() === "" && valore === "") { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict.obbligatorio_se_vuoto.replace('#field', '<b>' + $("#" + controlli[4]).attr('title') + '</b>')); |
|
errore = true; |
|
} |
|
} else if (tipo == "N") { |
|
valore = parseFloat(valore); |
|
riferimento = parseFloat(riferimento); |
|
} else if (tipo == "P") { |
|
if (typeof input_riferimento.attr('title') !== 'undefined') { |
|
riferimento_echo = input_riferimento.attr('title'); |
|
} |
|
} |
|
if (typeof controlli[5] !== 'undefined' && controlli[5] !== '') { |
|
operatore = controlli[5]; |
|
if (controlla) { |
|
switch (operatore) { |
|
case "=": |
|
if (valore != riferimento) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["must-equal"] + riferimento_echo); |
|
errore = true; |
|
} |
|
break; |
|
case ">": |
|
if (valore <= riferimento) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["must-greater"] + riferimento_echo); |
|
errore = true; |
|
} |
|
break; |
|
case ">=": |
|
if (valore < riferimento) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["must-greater-equal"] + riferimento_echo); |
|
errore = true; |
|
} |
|
break; |
|
case "<": |
|
if (valore >= riferimento) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["must-lesser"] + riferimento_echo); |
|
errore = true; |
|
} |
|
break; |
|
case "<=": |
|
if (valore > riferimento) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["must-lesser-equal"] + riferimento_echo); |
|
errore = true; |
|
} |
|
break; |
|
case "!=": |
|
if (valore == riferimento) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict.diverso + riferimento_echo); |
|
errore = true; |
|
} |
|
|
|
break; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
if (controlla) { |
|
if (input.val() === "" && obbligatorio == "S") { |
|
// Controllo sul valore del campo |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict.obbligatorio); |
|
errore = true; |
|
} |
|
|
|
// data-regex |
|
const regex = input.data("regex"); |
|
if(typeof regex != 'undefined' && input.val() !== "") { |
|
if (!input.val().match(regex)) { |
|
errore = true; |
|
msg.push( |
|
` |
|
<div class="validation-regex-examples"> |
|
<strong>${input.attr("title")}</strong> ${js_dict["regex-not-matched"]} <br> |
|
<ul> |
|
<li>${new RandExp(regex).gen()}</li> |
|
<li>${new RandExp(regex).gen()}</li> |
|
<li>${new RandExp(regex).gen()}</li> |
|
<li>${new RandExp(regex).gen()}</li> |
|
<li>${new RandExp(regex).gen()}</li> |
|
</ul> |
|
<button class="btn btn-danger btn-sm" type="button" onclick='valida($(\`[name="${input.attr('name')}"]\`))';'>${js_dict['show-more-examples']}</button> |
|
</div> |
|
`); |
|
} |
|
} |
|
|
|
if (input.val() !== "") { |
|
if (tipo != "RT") { |
|
if (input.val().length < lunghezza_minima) { |
|
// Controlla il numero di caratteri del campo |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["at-least"] + " " + lunghezza_minima + " " + js_dict.caratteri); |
|
errore = true; |
|
} |
|
|
|
if (lunghezza_massima > 0 && input.val().length > lunghezza_massima) { |
|
// Controlla il numero di caratteri del campo |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["max-char"] + " " + lunghezza_massima + " " + js_dict.caratteri); |
|
errore = true; |
|
} |
|
} |
|
|
|
switch (tipo) { |
|
case "ARRAY": |
|
if (!$.isArray(input.val()) || input.val().length <= 0) { |
|
errore = true; |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["scelta-multipla"]); |
|
} |
|
|
|
break; |
|
|
|
case "ALFA": //ALFABETICO |
|
if (! /^[A-Za-z\sàèéìòù]*$/.test(input.val())) { |
|
errore = true; |
|
msg.push(`<strong>${input.attr("title")}</strong> ${js_dict["must-alfabetic"]}`); |
|
} |
|
break; |
|
|
|
case "N": |
|
input.val(input.val().replace(",", ".")); |
|
|
|
if (!isNumeric(input.val())) { |
|
errore = true; |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["must-number"]); |
|
} |
|
|
|
break; |
|
|
|
case "NUMBER": |
|
input.val(input.val().replace(",", ".")); |
|
if (!isNumeric(input.val())) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["must-number"]); |
|
} |
|
if (lunghezza_massima != "NONE") { |
|
if (isNumeric(input.val()) && parseFloat(input.val()) > lunghezza_massima) { |
|
msg.push(`<strong>${input.attr("title")}</strong> ${js_dict["must-lesser-equal"]} ${lunghezza_massima}`); |
|
} |
|
} |
|
if (lunghezza_minima != "NONE") { |
|
if (isNumeric(input.val()) && parseFloat(input.val()) < lunghezza_minima) { |
|
msg.push(`<strong>${input.attr("title")}</strong> ${js_dict["must-greater-equal"]} ${lunghezza_minima}`); |
|
} |
|
} |
|
break; |
|
case "E": |
|
if (!emailReg.test(input.val())) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["must-email"]); |
|
errore = true; |
|
} |
|
|
|
break; |
|
|
|
case "D": |
|
if (!dataReg.test(input.val())) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["must-date"]); |
|
errore = true; |
|
} |
|
|
|
break; |
|
|
|
case "T": |
|
if (!timeReg.test(input.val())) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["must-hour"]); |
|
errore = true; |
|
} |
|
|
|
break; |
|
|
|
case "DT": |
|
if (!dateTimeReg.test(input.val())) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["must-datehour"]); |
|
errore = true; |
|
} |
|
|
|
break; |
|
|
|
case "I": |
|
if (!imgReg.test(input.val())) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["can-be-type"] + " JPG | GIF | PNG"); |
|
errore = true; |
|
} |
|
|
|
break; |
|
|
|
case "F": |
|
if (!allReg.test(input.val())) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["can-be-type"] + " JPG | GIF | PNG | DOC | XLS | PDF | ZIP | RAR"); |
|
errore = true; |
|
} |
|
|
|
break; |
|
|
|
case "FP": |
|
if (!allPReg.test(input.val())) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["can-be-type"] + " P7M | PDF | ZIP "); |
|
errore = true; |
|
} |
|
|
|
break; |
|
|
|
case "FS": |
|
if (!SignReg.test(input.val())) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["can-be-type"] + ": P7M "); |
|
errore = true; |
|
} |
|
|
|
break; |
|
|
|
case "CSV": |
|
if (!csvReg.test(input.val())) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["can-be-type"] + " CSV"); |
|
errore = true; |
|
} |
|
|
|
break; |
|
|
|
case "YV": |
|
if (!videoReg.test(input.val())) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["ln-youtube"]); |
|
errore = true; |
|
} |
|
|
|
break; |
|
|
|
case "CF": |
|
if (!cfReg.test(input.val())) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["valid-cf"]); |
|
errore = true; |
|
} |
|
|
|
break; |
|
|
|
case "IB": |
|
if (!ibanReg.test(input.val())) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["valid-iban"]); |
|
errore = true; |
|
} |
|
|
|
break; |
|
|
|
case "L": |
|
if (!urlReg.test(input.val())) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["valid-link"]); |
|
errore = true; |
|
} |
|
|
|
break; |
|
|
|
case "Checked": |
|
var checked = input.prop("checked"); |
|
|
|
if (!checked && obbligatorio == "S") { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict.obbligatorio); |
|
errore = true; |
|
} |
|
|
|
break; |
|
|
|
case "0D": |
|
var number = input.val(); |
|
number = number.replace(',', '.'); |
|
|
|
if (!isNumeric(number)) { |
|
errore = true; |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["must-number"]); |
|
} else { |
|
number = parseFloat(number); |
|
input.val(number.toFixed(0)); |
|
} |
|
|
|
break; |
|
|
|
case "5D": |
|
var number = input.val(); |
|
number = number.replace(',', '.'); |
|
|
|
if (!isNumeric(number)) { |
|
errore = true; |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["must-number"]); |
|
} else { |
|
number = parseFloat(number); |
|
input.val(number.toFixed(5)); |
|
} |
|
|
|
break; |
|
|
|
case "2D": |
|
input.val(input.val().replace(",", ".")); |
|
|
|
if (!isNumeric(input.val())) { |
|
errore = true; |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["must-number"]); |
|
} else { |
|
var integer_part = Math.floor(input.val()); |
|
|
|
if (input.val() == integer_part) { |
|
input.val(integer_part + '.00'); |
|
} else { |
|
var splitted_number = input.val().split('.'); |
|
|
|
if (splitted_number[1].length <= 1) { |
|
input.val(input.val() + '0'); |
|
} else if (splitted_number[1].length > 2) { |
|
input.val(integer_part + '.' + splitted_number[1].substring(0, 2)); |
|
} |
|
} |
|
} |
|
|
|
break; |
|
case "RT": |
|
var realInput = htmlToPlain(input.val()); |
|
if (realInput.length < lunghezza_minima) { // Controlla il numero di caratteri del campo |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["at-least"] + " " + lunghezza_minima + " " + js_dict.caratteri); |
|
errore = true; |
|
} |
|
if (lunghezza_massima > 0 && realInput.length > lunghezza_massima) { // Controlla il numero di caratteri del campo |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["max-char"] + " " + lunghezza_massima + " " + js_dict.caratteri); |
|
errore = true; |
|
} |
|
break; |
|
case "P": |
|
var hasUpperCase = /[A-Z]/.test(input.val()); |
|
var hasLowerCase = /[a-z]/.test(input.val()); |
|
var hasNumbers = /\d/.test(input.val()); |
|
var hasNonalphas = /\W/.test(input.val()); |
|
if (hasUpperCase + hasLowerCase + hasNumbers + hasNonalphas < 4) msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["strong-pwd"]); |
|
break; |
|
|
|
case "PI": |
|
if (!pivaReg.test(input.val())) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["valid-vat"]); |
|
errore = true; |
|
} |
|
|
|
break; |
|
|
|
case "PICF": |
|
errore_cf = false; |
|
errore_piva = false; |
|
|
|
if (!cfReg.test(input.val())) { |
|
errore_cf = true; |
|
} |
|
|
|
if (errore_cf) { |
|
errore_cf = false; |
|
|
|
if (!pivaReg.test(input.val())) { |
|
errore_piva = true; |
|
errore = true; |
|
} |
|
} |
|
|
|
if (errore_cf || errore_piva) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["valid-cfvat"]); |
|
errore = true; |
|
} |
|
|
|
break; |
|
|
|
case "ECOMMA": |
|
|
|
if (!explodeCommaReg.test(input.val())) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["valid-caratteri"]); |
|
break; |
|
} |
|
|
|
if (!explodeCommaReg2.test(input.val())) { |
|
msg.push("<strong>" + input.attr("title") + "</strong> " + js_dict["valid-group"]); |
|
break; |
|
} |
|
|
|
break; |
|
|
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
if (msg.length > 0) { |
|
msg_text = ""; |
|
|
|
for (i = 0; i < msg.length; i++) { |
|
msg_text += msg[i] + "<br>"; |
|
} |
|
|
|
input.addClass('is-invalid'); |
|
input.parents(".form-group").first().addClass("text-danger"); |
|
input.parents(".form-group").first().append("<div class=\"invalid-feedback\" id=\"note_" + label_id + "\">" + msg_text + "</div>"); |
|
} |
|
|
|
check_error_tabs(); |
|
} |
|
|
|
return msg; |
|
}; |
|
|
|
if (typeof escapeHtmlEntities == 'undefined') { |
|
escapeHtmlEntities = function(text) { |
|
return text.replace(/[\u00A0-\u2666<>\&]/g, function(c) { |
|
return '&' + (escapeHtmlEntities.entityTable[c.charCodeAt(0)] || '#' + c.charCodeAt(0)) + ';'; |
|
}); |
|
}; |
|
// all HTML4 entities as defined here: http://www.w3.org/TR/html4/sgml/entities.html |
|
// added: amp, lt, gt, quot and apos |
|
escapeHtmlEntities.entityTable = { |
|
34: 'quot', |
|
38: 'amp', |
|
39: 'apos', |
|
60: 'lt', |
|
62: 'gt', |
|
160: 'nbsp', |
|
161: 'iexcl', |
|
162: 'cent', |
|
163: 'pound', |
|
164: 'curren', |
|
165: 'yen', |
|
166: 'brvbar', |
|
167: 'sect', |
|
168: 'uml', |
|
169: 'copy', |
|
170: 'ordf', |
|
171: 'laquo', |
|
172: 'not', |
|
173: 'shy', |
|
174: 'reg', |
|
175: 'macr', |
|
176: 'deg', |
|
177: 'plusmn', |
|
178: 'sup2', |
|
179: 'sup3', |
|
180: 'acute', |
|
181: 'micro', |
|
182: 'para', |
|
183: 'middot', |
|
184: 'cedil', |
|
185: 'sup1', |
|
186: 'ordm', |
|
187: 'raquo', |
|
188: 'frac14', |
|
189: 'frac12', |
|
190: 'frac34', |
|
191: 'iquest', |
|
192: 'Agrave', |
|
193: 'Aacute', |
|
194: 'Acirc', |
|
195: 'Atilde', |
|
196: 'Auml', |
|
197: 'Aring', |
|
198: 'AElig', |
|
199: 'Ccedil', |
|
200: 'Egrave', |
|
201: 'Eacute', |
|
202: 'Ecirc', |
|
203: 'Euml', |
|
204: 'Igrave', |
|
205: 'Iacute', |
|
206: 'Icirc', |
|
207: 'Iuml', |
|
208: 'ETH', |
|
209: 'Ntilde', |
|
210: 'Ograve', |
|
211: 'Oacute', |
|
212: 'Ocirc', |
|
213: 'Otilde', |
|
214: 'Ouml', |
|
215: 'times', |
|
216: 'Oslash', |
|
217: 'Ugrave', |
|
218: 'Uacute', |
|
219: 'Ucirc', |
|
220: 'Uuml', |
|
221: 'Yacute', |
|
222: 'THORN', |
|
223: 'szlig', |
|
224: 'agrave', |
|
225: 'aacute', |
|
226: 'acirc', |
|
227: 'atilde', |
|
228: 'auml', |
|
229: 'aring', |
|
230: 'aelig', |
|
231: 'ccedil', |
|
232: 'egrave', |
|
233: 'eacute', |
|
234: 'ecirc', |
|
235: 'euml', |
|
236: 'igrave', |
|
237: 'iacute', |
|
238: 'icirc', |
|
239: 'iuml', |
|
240: 'eth', |
|
241: 'ntilde', |
|
242: 'ograve', |
|
243: 'oacute', |
|
244: 'ocirc', |
|
245: 'otilde', |
|
246: 'ouml', |
|
247: 'divide', |
|
248: 'oslash', |
|
249: 'ugrave', |
|
250: 'uacute', |
|
251: 'ucirc', |
|
252: 'uuml', |
|
253: 'yacute', |
|
254: 'thorn', |
|
255: 'yuml', |
|
402: 'fnof', |
|
913: 'Alpha', |
|
914: 'Beta', |
|
915: 'Gamma', |
|
916: 'Delta', |
|
917: 'Epsilon', |
|
918: 'Zeta', |
|
919: 'Eta', |
|
920: 'Theta', |
|
921: 'Iota', |
|
922: 'Kappa', |
|
923: 'Lambda', |
|
924: 'Mu', |
|
925: 'Nu', |
|
926: 'Xi', |
|
927: 'Omicron', |
|
928: 'Pi', |
|
929: 'Rho', |
|
931: 'Sigma', |
|
932: 'Tau', |
|
933: 'Upsilon', |
|
934: 'Phi', |
|
935: 'Chi', |
|
936: 'Psi', |
|
937: 'Omega', |
|
945: 'alpha', |
|
946: 'beta', |
|
947: 'gamma', |
|
948: 'delta', |
|
949: 'epsilon', |
|
950: 'zeta', |
|
951: 'eta', |
|
952: 'theta', |
|
953: 'iota', |
|
954: 'kappa', |
|
955: 'lambda', |
|
956: 'mu', |
|
957: 'nu', |
|
958: 'xi', |
|
959: 'omicron', |
|
960: 'pi', |
|
961: 'rho', |
|
962: 'sigmaf', |
|
963: 'sigma', |
|
964: 'tau', |
|
965: 'upsilon', |
|
966: 'phi', |
|
967: 'chi', |
|
968: 'psi', |
|
969: 'omega', |
|
977: 'thetasym', |
|
978: 'upsih', |
|
982: 'piv', |
|
8226: 'bull', |
|
8230: 'hellip', |
|
8242: 'prime', |
|
8243: 'Prime', |
|
8254: 'oline', |
|
8260: 'frasl', |
|
8472: 'weierp', |
|
8465: 'image', |
|
8476: 'real', |
|
8482: 'trade', |
|
8501: 'alefsym', |
|
8592: 'larr', |
|
8593: 'uarr', |
|
8594: 'rarr', |
|
8595: 'darr', |
|
8596: 'harr', |
|
8629: 'crarr', |
|
8656: 'lArr', |
|
8657: 'uArr', |
|
8658: 'rArr', |
|
8659: 'dArr', |
|
8660: 'hArr', |
|
8704: 'forall', |
|
8706: 'part', |
|
8707: 'exist', |
|
8709: 'empty', |
|
8711: 'nabla', |
|
8712: 'isin', |
|
8713: 'notin', |
|
8715: 'ni', |
|
8719: 'prod', |
|
8721: 'sum', |
|
8722: 'minus', |
|
8727: 'lowast', |
|
8730: 'radic', |
|
8733: 'prop', |
|
8734: 'infin', |
|
8736: 'ang', |
|
8743: 'and', |
|
8744: 'or', |
|
8745: 'cap', |
|
8746: 'cup', |
|
8747: 'int', |
|
8756: 'there4', |
|
8764: 'sim', |
|
8773: 'cong', |
|
8776: 'asymp', |
|
8800: 'ne', |
|
8801: 'equiv', |
|
8804: 'le', |
|
8805: 'ge', |
|
8834: 'sub', |
|
8835: 'sup', |
|
8836: 'nsub', |
|
8838: 'sube', |
|
8839: 'supe', |
|
8853: 'oplus', |
|
8855: 'otimes', |
|
8869: 'perp', |
|
8901: 'sdot', |
|
8968: 'lceil', |
|
8969: 'rceil', |
|
8970: 'lfloor', |
|
8971: 'rfloor', |
|
9001: 'lang', |
|
9002: 'rang', |
|
9674: 'loz', |
|
9824: 'spades', |
|
9827: 'clubs', |
|
9829: 'hearts', |
|
9830: 'diams', |
|
338: 'OElig', |
|
339: 'oelig', |
|
352: 'Scaron', |
|
353: 'scaron', |
|
376: 'Yuml', |
|
710: 'circ', |
|
732: 'tilde', |
|
8194: 'ensp', |
|
8195: 'emsp', |
|
8201: 'thinsp', |
|
8204: 'zwnj', |
|
8205: 'zwj', |
|
8206: 'lrm', |
|
8207: 'rlm', |
|
8211: 'ndash', |
|
8212: 'mdash', |
|
8216: 'lsquo', |
|
8217: 'rsquo', |
|
8218: 'sbquo', |
|
8220: 'ldquo', |
|
8221: 'rdquo', |
|
8222: 'bdquo', |
|
8224: 'dagger', |
|
8225: 'Dagger', |
|
8240: 'permil', |
|
8249: 'lsaquo', |
|
8250: 'rsaquo', |
|
8364: 'euro' |
|
}; |
|
} |
|
|
|
// Funzione per l'utilizzo di trim() su Internet Explorer |
|
if (typeof String.prototype.trim !== 'function') { |
|
String.prototype.trim = function() { |
|
return this.replace(/^\s+|\s+$/g, ''); |
|
}; |
|
} |
|
String.prototype.ucwords = function() { |
|
str = this.toLowerCase(); |
|
return str.replace(/(^([a-zA-Z\p{M}]))|([ -][a-zA-Z\p{M}])/g, |
|
function(s){ |
|
return s.toLocaleUpperCase(); |
|
}); |
|
}; |
|
String.prototype.ucfirst = function() { |
|
return this.charAt(0).toLocaleUpperCase() + this.slice(1); |
|
}; |
|
|
|
String.prototype.trimStartEx = function(charlist) { |
|
if (charlist === undefined) |
|
charlist = "\s"; |
|
|
|
return this.replace(new RegExp("^[" + charlist + "]+"), ""); |
|
}; |
|
|
|
String.prototype.trimEx = function(charlist) { |
|
return this.trimStartEx(charlist).trimEndEx(charlist); |
|
}; |
|
|
|
String.prototype.trimEndEx = function(charlist) { |
|
if (charlist === undefined) |
|
charlist = "\s"; |
|
|
|
return this.replace(new RegExp("[" + charlist + "]+$"), ""); |
|
}; |
|
|
|
// Inizio funzione espressioni regolari case insensitive |
|
// NEW selector |
|
jQuery.expr[':'].Contains = function(a, i, m) { |
|
return jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase()) >= 0; |
|
}; |
|
// OVERWRITES old selecor |
|
jQuery.expr[':'].contains = function(a, i, m) { |
|
return jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase()) >= 0; |
|
}; |
|
// Fine funzione espressioni regolari case insensitive |
|
|
|
var toolbar_full = [ |
|
['Source'], |
|
['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'], |
|
['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'], |
|
['Link', 'Unlink', 'Anchor'], |
|
['Format', 'FontSize'], |
|
['TextColor', 'BGColor'], |
|
['Table'], |
|
['Image'], |
|
['Find', 'Replace', '-', 'SelectAll', '-', 'SpellChecker', 'Scayt'], |
|
['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', ], |
|
['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'] |
|
]; |
|
|
|
viewSize = function() { |
|
return $('#sizer').find('div:visible').data('size'); |
|
} |
|
|
|
scrollToElement = function (id) { |
|
if ($(id).length > 0) { |
|
var diff = 200; |
|
if ($("#top-container").height() > 170) { |
|
diff = 250; |
|
} |
|
$([document.documentElement, document.body]).animate({ |
|
scrollTop: $(id).offset().top - diff |
|
}, 500); |
|
} |
|
}; |
|
|
|
createSideBarAnchors = function() { |
|
if ($("#sidebar").length > 0) { |
|
titles = $(".card-title"); |
|
if (titles.length > 0) { |
|
var html; |
|
var cont = 0; |
|
html = "<div id='sideAnchors' class='card card-body my-2 p-3 bg-light text-light'>"; |
|
titles.each(function() { |
|
if ($(this).parents(".card-body,.card-footer,#sidebar").length == 0) { |
|
text = $(this).html(); |
|
if (typeof $(this).attr("id") == "undefined") { |
|
id = "ancor" + cont; |
|
cont++; |
|
$(this).attr("id",id); |
|
} else { |
|
id = $(this).attr("id"); |
|
} |
|
html += "<button type='button' class='btn text-left btn-primary btn-block btn-sm' onClick='scrollToElement(\"#"+id+"\")'><span class='fa fa-angle-double-down'></span> "+text+"</button>"; |
|
} |
|
}) |
|
html += "</div>"; |
|
$("#sidebar").append(html); |
|
} |
|
} |
|
} |
|
|
|
window.onscroll = function() {scrollFunction()}; |
|
window.currentSize = viewSize(); |
|
scrollFunction = function() { |
|
limit = $("#top-container").height(); |
|
position = document.body.scrollTop; |
|
if (position == 0) position = document.documentElement.scrollTop; |
|
collapsedTop = false; |
|
if ($(".collapsed-top").length > 0) collapsedTop = true; |
|
minSM = 35; |
|
maxSM = 70; |
|
|
|
minLG = 35; |
|
maxLG = 150; |
|
|
|
maxPD = 50; |
|
minPD = 2; |
|
|
|
maxMenuPD = 15; |
|
minMenuPD = 10; |
|
|
|
maxEM = 2.5; |
|
minEM = 1.8; |
|
if ($("#sidebar").length > 0) { |
|
currentSize = viewSize(); |
|
if (currentSize != "xs") { |
|
var sidebarHeight = $(".card:last","#sidebar").position().top + $(".card:last","#sidebar").height(); |
|
windowHeight = $( window ).height(); |
|
cssHeight = windowHeight - limit - 10; |
|
$("#sidebar").css('height',cssHeight); |
|
$("#sidebar").css('overflow','auto'); |
|
} else { |
|
$("#sidebar").css('top','0'); |
|
$("#sidebar").css('position','relative'); |
|
$("#sidebar").css('overflow','visible'); |
|
$("#sidebar").css('height','auto'); |
|
} |
|
} |
|
if (position > limit) { |
|
if (!collapsedTop) { |
|
$("#stemmaSM").height(minSM+"px"); |
|
$("#stemmaLG").height(minLG+"px"); |
|
$("#SpazioStemmaLG").addClass("float-left"); |
|
$("#SpazioStemmaLG").addClass("float-left"); |
|
$("#menuLG").addClass("float-right"); |
|
$(".menuLG").css("padding",minMenuPD+"px 10px"); |
|
$(".menuLG-icon").slideUp(); |
|
$(".subMenuTop").slideUp(); |
|
$("#denominazioneEnte").hide(); |
|
elPad = $("#menuLgFlex").outerHeight(); |
|
elPad = elPad / 2; |
|
elPad = elPad - (minLG / 2) + 3; |
|
$("#SpazioStemmaLG").css("paddingTop",elPad+"px"); |
|
} |
|
$("#scrollToTop").show(); |
|
|
|
if (currentSize != "xs") { |
|
$("#sidebar").css('width',$("#sidebar").outerWidth()); |
|
if ((position + sidebarHeight) < ($("#main-content").height())) { |
|
$("#sidebar").css('position','fixed'); |
|
$("#sidebar").css('top',limit+10); |
|
} else { |
|
sidebarTop = $("#main-content").height() - sidebarHeight - limit; |
|
$("#sidebar").css('position','absolute'); |
|
$("#sidebar").css('top',sidebarTop); |
|
} |
|
} |
|
} else { |
|
if (!collapsedTop) { |
|
if (position % 5 == 0) { |
|
$("#SpazioStemmaLG").removeClass("float-left"); |
|
$("#menuLG").removeClass("float-right"); |
|
$("#denominazioneEnte").slideDown(); |
|
$(".subMenuTop").slideDown(); |
|
$(".menuLG-icon").slideDown(); |
|
$(".subMenuTop").slideDown(); |
|
perc = 1 - position / limit; |
|
sizeSM = maxSM * perc; |
|
sizeLG = maxLG * perc; |
|
pad = maxPD * perc; |
|
menuPad = maxMenuPD * perc; |
|
em = maxEM * perc; |
|
if (sizeSM < minSM) sizeSM = minSM; |
|
if (sizeLG < minLG) sizeLG = minLG; |
|
if (pad < minPD) pad = minPD; |
|
if (pad < minMenuPD) menuPad = minMenuPD; |
|
if (em < minEM) em = minEM; |
|
if (menuPad < minMenuPD) menuPad = minMenuPD; |
|
$("#stemmaSM").height(sizeSM+"px"); |
|
$("#stemmaLG").height(sizeLG+"px"); |
|
$("#SpazioStemmaLG").css("paddingTop",pad+"px"); |
|
$(".menuLG").css("padding",menuPad+"px 10px"); |
|
$("#SpazioStemmaLG > *").css("fontSize",em+"em"); |
|
} |
|
} |
|
$("#scrollToTop").hide(); |
|
currentSize = viewSize(); |
|
if (currentSize != "xs") { |
|
$("#sidebar").css('width',"auto"); |
|
$("#sidebar").css('position','relative'); |
|
$("#sidebar").css('top','0'); |
|
} |
|
} |
|
} |
|
var serverTime = new Date(); |
|
var currentTime; |
|
var getTime = function () { |
|
$.ajax({ |
|
type: 'GET', |
|
url: '/serverClock.php', |
|
data: {format: 'json'}, |
|
dataType: 'json', |
|
async: "true", |
|
}) |
|
.done(function(data) { |
|
serverTime = new Date(data.year,data.month,data.day,data.hour,data.minute,data.second); |
|
$('#serverDate').html(data.datestring); |
|
$('#serverClockH').html(getHoursWithLeadingZeros(serverTime)); |
|
$('#serverClockI').html(getMinutesWithLeadingZeros(serverTime)); |
|
}); |
|
} |
|
|
|
var updateClock = function() { |
|
currentTime = new Date(serverTime.getTime() + 250); |
|
$('#serverClockH').html(getHoursWithLeadingZeros(currentTime)); |
|
$('#serverClockI').html(getMinutesWithLeadingZeros(currentTime)); |
|
serverTime = currentTime; |
|
} |
|
|
|
var getMinutesWithLeadingZeros = function (date) { |
|
return (date.getMinutes() < 10 ? '0' : '') + date.getMinutes(); |
|
} |
|
|
|
var getHoursWithLeadingZeros = function (date) { |
|
return (date.getHours() < 10 ? '0' : '') + date.getHours(); |
|
} |
|
|
|
var htmlToPlain = function(text){ |
|
return text.replaceAll(/<(.|\n)*?>/g, '') |
|
.replaceAll(/[&]lt[;]/g,'<') |
|
.replaceAll(/[&]gt[;]/g,'>') |
|
.replaceAll(/[&]nbsp[;]/g,' ') |
|
.replaceAll(/[&]agrave[;]/g,'à') |
|
.replaceAll(/[&]egrave[;]/g,'è') |
|
.replaceAll(/[&]eacute[;]/g,'é') |
|
.replaceAll(/[&]igrave[;]/g,'ì') |
|
.replaceAll(/[&]ograve[;]/g,'ò') |
|
.replaceAll(/[&]ugrave[;]/g,'ù') |
|
.replaceAll(/\n/g,''); |
|
} |
|
|
|
f_ready = function() { |
|
drawertoogle(); |
|
fixModal(); |
|
affixTop(); |
|
$(".card-header").children().each(function() { |
|
if (typeof $(this).data('target') !== "undefined") { |
|
if ($($(this).data('target')).length > 0) { |
|
if ($(this).find('.explodeToggle').length == 0) { |
|
$(this).css('cursor','pointer').each(function() { |
|
var fa = "minus"; |
|
if ($($(this).data('target')).css('display') == "none") { |
|
fa = "plus"; |
|
} |
|
$(this).append('<small class="explodeToggle fa fa-'+fa+' float-right"></small>') |
|
}).bind('click',function() { $($(this).data('target')).slideToggle('fast',function() { |
|
var iconElement = $(this).parent().find('.explodeToggle'); |
|
if ($(this).is(":visible")) { |
|
iconElement.removeClass('fa-plus').addClass('fa-minus'); |
|
} else { |
|
iconElement.removeClass('fa-minus').addClass('fa-plus'); |
|
} |
|
}); |
|
}); |
|
} |
|
} |
|
} |
|
}); |
|
|
|
if ($(".ckeditor_guee").length > 0) { |
|
var very_simple_toolbar = [ |
|
['PasteText', '-', 'Undo', 'Redo'] |
|
]; |
|
var very_simple_config = { |
|
toolbar_simpletoolbar: very_simple_toolbar, |
|
toolbar: 'simpletoolbar', |
|
enterMode: CKEDITOR.ENTER_P, |
|
allowedContent: ['p'] |
|
}; |
|
$(".ckeditor_guee").each(function(){ |
|
if ($(this).attr("rel")) { |
|
let rel = $(this).attr("rel").split(";"); |
|
if (rel.length > 2 && rel[2] != "0") { |
|
let maxChars = rel[2]; |
|
$(this).ckeditor(very_simple_config); |
|
let editorInstance = CKEDITOR.instances[$(this).attr('id')] |
|
let textLength = $(this).val().replace(/<(.|\n)*?>/g, '').length; |
|
$(`#${$(this).attr('id')}-world-count`).remove(); |
|
$(this).parent().append(`<small class="mt-2 float-right" id="${$(this).attr('id')}-world-count">${textLength} / ${maxChars}</small>`); |
|
let input = $(this); |
|
|
|
|
|
editorInstance.on('change', function(){ |
|
let currentTextLength = htmlToPlain(input.val()).length |
|
$(`#${input.attr('id')}-world-count`).removeClass("text-danger") |
|
if (currentTextLength > maxChars) { |
|
$(`#${input.attr('id')}-world-count`).addClass("text-danger") |
|
} |
|
$(`#${input.attr('id')}-world-count`).text(`${currentTextLength} / ${maxChars}`); |
|
}) |
|
} else { |
|
$(this).ckeditor(very_simple_config) |
|
} |
|
} |
|
$(this).ckeditor(very_simple_config) |
|
}); |
|
} |
|
|
|
if ($(".ckeditor_full").length > 0) { |
|
for(var i = 0; i < $(".ckeditor_full").length; i++) { |
|
var exist = false; |
|
var editor = $(".ckeditor_full")[i]; |
|
if(window.CKEDITOR.length > 0) { |
|
for(var j = 0; j < window.CKEDITOR.length; j++) { |
|
window.CKEDITOR[j].updateSourceElement(); |
|
if(window.CKEDITOR[j].sourceElement == editor) { |
|
exist = true; |
|
} |
|
} |
|
} |
|
if(! exist) { |
|
Editor.create(editor, { |
|
placeholder: 'Inserisci il testo', |
|
removePlugins: [ 'Title', 'PlainText' ], |
|
htmlSupport: { |
|
allow: ['style'], |
|
}, |
|
toolbar: { |
|
items: [ |
|
'sourceEditing', |
|
'|', |
|
'undo', |
|
'redo', |
|
'|', |
|
'bold', |
|
'italic', |
|
'underline', |
|
'strikethrough', |
|
'subscript', |
|
'superscript', |
|
'|', |
|
'removeFormat', |
|
'link', |
|
'|', |
|
'style', |
|
'fontSize', |
|
'|', |
|
'fontColor', |
|
'fontBackgroundColor', |
|
'|', |
|
'insertTable', |
|
'insertImage', |
|
'|', |
|
'findAndReplace', |
|
'|', |
|
'selectAll', |
|
'|', |
|
'numberedList', |
|
'bulletedList', |
|
'|', |
|
'indent', |
|
'outdent', |
|
'|', |
|
'alignment', |
|
], |
|
shouldNotGroupWhenFull: true |
|
}, |
|
image: { |
|
toolbar: [ |
|
'imageStyle:block', |
|
'imageStyle:side', |
|
'|', |
|
'toggleImageCaption', |
|
'imageTextAlternative', |
|
'|', |
|
'linkImage', |
|
'imageUResize', |
|
'ckboxImageEdit' |
|
], |
|
insert: { |
|
// If this setting is omitted, the editor defaults to 'block'. |
|
// See explanation below. |
|
type: 'link' |
|
} |
|
} |
|
}) |
|
.then(instance => { |
|
if ($(instance.sourceElement).is(":disabled")) { |
|
instance.enableReadOnlyMode(instance.id); |
|
} |
|
const observer = new MutationObserver((mutationList, observer) => { |
|
instance.disableReadOnlyMode(instance.id); |
|
if ($(instance.sourceElement).is(":disabled")) { |
|
instance.enableReadOnlyMode(instance.id); |
|
} |
|
}) |
|
observer.observe(instance.sourceElement, { attributes: true}); |
|
window.CKEDITOR.push(instance); |
|
}) |
|
.catch(error => { |
|
console.log(error); |
|
}); |
|
} |
|
} |
|
} |
|
|
|
if ($(".ckeditor_simple").length > 0) { |
|
for(var i = 0; i < $(".ckeditor_simple").length; i++) { |
|
var exist = false; |
|
var editor = $(".ckeditor_simple")[i]; |
|
if(window.CKEDITOR.length > 0) { |
|
for(var j = 0; j < window.CKEDITOR.length; j++) { |
|
window.CKEDITOR[j].updateSourceElement(); |
|
if(window.CKEDITOR[j].sourceElement == editor) { |
|
exist = true; |
|
} |
|
} |
|
} |
|
if(! exist) { |
|
Editor.create(editor, { |
|
placeholder: 'Inserisci il testo', |
|
removePlugins: [ |
|
"Autoformat", "BlockQuote", "CloudServices", "Link", "Image", "Heading", "ImageCaption", "ImageStyle", "ImageToolbar", "MediaEmbed", "PasteFromOffice", "Table", "TableToolbar", "TextTransformation", "AutoLink", "FontColor", "FontBackgroundColor", "FindAndReplace", "FontSize", "Highlight", "HorizontalLine", "IndentBlock", "ListProperties", "RemoveFormat", "TableCaption", "TableCellProperties", "TableColumnResize", "TableProperties", "WordCount", "Title" |
|
], |
|
toolbar: { |
|
items: [ |
|
'undo', 'redo' |
|
], |
|
shouldNotGroupWhenFull: true |
|
} |
|
}) |
|
.then(instance => { |
|
instance.editing.view.document.on('enter',(evt, data) => { |
|
instance.execute('shiftEnter'); |
|
data.preventDefault(); |
|
evt.stop(); |
|
}, {priority: 'high'}) |
|
if ($(instance.sourceElement).is(":disabled")) { |
|
instance.enableReadOnlyMode(instance.id); |
|
} |
|
const observer = new MutationObserver((mutationList, observer) => { |
|
instance.disableReadOnlyMode(instance.id); |
|
if ($(instance.sourceElement).is(":disabled")) { |
|
instance.enableReadOnlyMode(instance.id); |
|
} |
|
}) |
|
observer.observe(instance.sourceElement, { attributes: true}); |
|
window.CKEDITOR.push(instance); |
|
}) |
|
.catch(error => { |
|
console.log(error); |
|
}); |
|
} |
|
} |
|
} |
|
|
|
if ($(".ckeditor_count").length > 0) { |
|
for(var i = 0; i < $(".ckeditor_count").length; i++) { |
|
var exist = false; |
|
var editor = $(".ckeditor_count")[i]; |
|
if(window.CKEDITOR.length > 0) { |
|
for(var j = 0; j < window.CKEDITOR.length; j++) { |
|
window.CKEDITOR[j].updateSourceElement(); |
|
if(window.CKEDITOR[j].sourceElement == editor) { |
|
exist = true; |
|
} |
|
} |
|
} |
|
if(! exist) { |
|
Editor.create(editor, { |
|
placeholder: "Clicca per scrivere...", |
|
removePlugins: [ |
|
"Autoformat", "BlockQuote", "CloudServices", "Link", "AutoLink", "Image", "ImageCaption", "ImageStyle", "FindAndReplace", "ImageToolbar", "FontBackgroundColor", "FontColor", "FontSize", "Heading", "Highlight", "HorizontalLine", "Heading", "ImageCaption", "ImageStyle", "ImageToolbar", "MediaEmbed", "PasteFromOffice", "Table", "TableToolbar", "TextTransformation", "FontColor", "FontBackgroundColor", "FindAndReplace", "FontSize", "Highlight", "HorizontalLine", "IndentBlock", "ListProperties", "RemoveFormat", "TableCaption", "TableCellProperties", "TableColumnResize", "TableProperties", "List", "ListProperties", "MediaEmbed", "PasteFromOffice", "RemoveFormat", "Table", "TableCaption", "TableCellProperties", "TableColumnResize", "TableProperties", "TableToolbar" , "Title" |
|
], |
|
plugins: [ |
|
"Alignment", "Strikethrough", "Autosave", "Bold", "Essentials", "Indent", "IndentBlock", "Italic", "Underline", "Undo", "WordCount", "Paragraph", |
|
], |
|
toolbar: { |
|
items: [ |
|
'undo', 'redo', '|', |
|
'bold', 'italic', 'underline', 'strikethrough', '|', |
|
'alignment', '|', |
|
'bulletedList', 'numberedList', '|', |
|
'indent', 'outdent' |
|
], |
|
shouldNotGroupWhenFull: false |
|
}, |
|
wordCount: { |
|
onUpdate: stats => { |
|
// $(editor).parent().children('.ck-word-count').text(`Parole: ${ stats.words }`); |
|
// $(editor).parent().children('.ck-word-count__characters').text(`Caratteri: ${ stats.characters }`); |
|
} |
|
} |
|
}) |
|
.then(instance => { |
|
if ($(instance.sourceElement).is(":disabled")) { |
|
instance.enableReadOnlyMode(instance.id); |
|
} |
|
const observer = new MutationObserver((mutationList, observer) => { |
|
instance.disableReadOnlyMode(instance.id); |
|
if ($(instance.sourceElement).is(":disabled")) { |
|
instance.enableReadOnlyMode(instance.id); |
|
} |
|
}) |
|
observer.observe(instance.sourceElement, { attributes: true}); |
|
window.CKEDITOR.push(instance); |
|
const wordCountPlugin = instance.plugins.get('WordCount'); |
|
$(instance.sourceElement).parent().append(wordCountPlugin.wordCountContainer); |
|
}) |
|
.catch(error => { |
|
console.log(error); |
|
}); |
|
} |
|
} |
|
} |
|
|
|
if ($(".very_simple_ckeditor").length > 0) { |
|
for(var i = 0; i < $(".very_simple_ckeditor").length; i++) { |
|
var exist = false; |
|
var editor = $(".very_simple_ckeditor")[i]; |
|
if(window.CKEDITOR.length > 0) { |
|
for(var j = 0; j < window.CKEDITOR.length; j++) { |
|
window.CKEDITOR[j].updateSourceElement(); |
|
if(window.CKEDITOR[j].sourceElement == editor) { |
|
exist = true; |
|
} |
|
} |
|
} |
|
if(! exist) { |
|
CKEditor.create(editor, { |
|
placeholder: 'Inserisci il testo', |
|
removePlugins: [ |
|
"Autoformat", "BlockQuote", "CloudServices", "Link", "Image", "Heading", "ImageCaption", "ImageStyle", "ImageToolbar", "MediaEmbed", "PasteFromOffice", "Table", "TableToolbar", "TextTransformation", "AutoLink", "FontColor", "FontBackgroundColor", "FindAndReplace", "FontSize", "Highlight", "HorizontalLine", "IndentBlock", "ListProperties", "RemoveFormat", "TableCaption", "TableCellProperties", "TableColumnResize", "TableProperties", "WordCount", "Title" |
|
], |
|
toolbar: { |
|
items: [ |
|
'undo', 'redo' |
|
], |
|
shouldNotGroupWhenFull: true |
|
} |
|
}) |
|
.then(instance => { |
|
if ($(instance.sourceElement).is(":disabled")) { |
|
instance.enableReadOnlyMode(instance.id); |
|
} |
|
const observer = new MutationObserver((mutationList, observer) => { |
|
instance.disableReadOnlyMode(instance.id); |
|
if ($(instance.sourceElement).is(":disabled")) { |
|
instance.enableReadOnlyMode(instance.id); |
|
} |
|
}) |
|
observer.observe(instance.sourceElement, { attributes: true}); |
|
window.CKEDITOR.push(instance); |
|
}) |
|
.catch(error => { |
|
console.log(error); |
|
}); |
|
} |
|
} |
|
} |
|
|
|
$("select").not('.swal2-select').not('.not-chosen').chosen({width: '100%',search_contains: true}); |
|
|
|
etichette_testo(); |
|
if ($('.datepick').length > 0) { |
|
$('.datepick').datetimepicker({ |
|
lang: 'it', |
|
timepicker: false, |
|
format: 'd/m/Y', |
|
dayOfWeekStart: 1, |
|
scrollInput: false, |
|
closeOnDateSelect: true |
|
}); |
|
} |
|
//if ($('.datefull')) |
|
if ($('.timepick').length > 0) { |
|
$('.timepick').datetimepicker({ |
|
lang: 'it', |
|
datepicker: false, |
|
format: 'H:i', |
|
step: '30', |
|
minTime: '07:00', |
|
maxTime: '22:00', |
|
dayOfWeekStart: 1, |
|
scrollInput: false, |
|
closeOnDateSelect: true |
|
}); |
|
} |
|
if ($('.datetimepick').length > 0) { |
|
$('.datetimepick').datetimepicker({ |
|
lang: 'it', |
|
startDate: 'today', |
|
step: 15, |
|
format: 'd/m/Y H:i', |
|
dayOfWeekStart: 1, |
|
scrollInput: false, |
|
closeOnDateSelect: false |
|
}); |
|
} |
|
if ($('.datetimepick_today').length > 0) { |
|
$('.datetimepick_today').datetimepicker({ |
|
lang: 'it', |
|
step: 15, |
|
startDate: 0, |
|
format: 'd/m/Y H:i', |
|
minTime: '07:00', |
|
maxTime: '22:00', |
|
dayOfWeekStart: 1, |
|
scrollInput: false, |
|
closeOnDateSelect: true |
|
}); |
|
} |
|
if ($('.datepick_today').length > 0) { |
|
$('.datepick_today').datetimepicker({ |
|
lang: 'it', |
|
startDate: 0, |
|
timepicker: false, |
|
format: 'd/m/Y', |
|
scrollInput: false, |
|
closeOnDateSelect: true |
|
}); |
|
} |
|
|
|
$("input:text,input:password,select,textarea").focusout(function() { |
|
if ($(this).val() !== "") { |
|
$(this).parents('.form-group').first().removeClass("has-error"); |
|
} |
|
}); |
|
|
|
|
|
if ($(".geo-select").length > 0) { |
|
$(".geo-select").unbind('change'); |
|
$(".geo-select").change(function() { |
|
if (typeof $(this).data('target')!=='undefined' && typeof $(this).val()!=='undefined' && typeof $(this).data('source')!=='undefined') { |
|
target = $($(this).data('target')); |
|
var value = $(this).val(); |
|
if (value === null) value = ""; |
|
var source = $(this).data('source'); |
|
target.each(function(index,el) { |
|
current_target = $(this); |
|
var found = false; |
|
if (typeof current_target.data('result')!=='undefined') { |
|
$.ajax({ |
|
url: '/inc/geoData.php?value='+value+"&source="+source+"&result="+current_target.data('result'), |
|
dataType: "json", |
|
async: false, |
|
success: function(result) { |
|
html = "<option value=''>Seleziona...</option>"; |
|
jQuery.each(result, function(i, val) { |
|
found = true; |
|
if (typeof val.sigla_provincia != "undefined") { |
|
html += "<option value=\""+ val.sigla_provincia +"\">" + val.valore + "</option>"; |
|
} else { |
|
html += "<option>" + val.valore + "</option>"; |
|
} |
|
}); |
|
val = current_target.val(); |
|
current_target.val(''); |
|
current_target.html(html); |
|
if (typeof current_target.data('obbligatorio')!=='undefined') { |
|
if (current_target.data('obbligatorio') == "S") { |
|
var rel = current_target.attr("rel"); |
|
rel = rel.substring(1); |
|
if (found) { |
|
rel = "S" + rel; |
|
} else { |
|
rel = "N" + rel; |
|
} |
|
current_target.attr('rel',rel); |
|
} |
|
} |
|
current_target.val(val); |
|
current_target.trigger("chosen:updated"); |
|
}, |
|
complete: function() { |
|
target.change(); |
|
} |
|
}); |
|
} |
|
}); |
|
} |
|
}); |
|
} |
|
|
|
// Funzione per il controllo del submit di tutti i form nel sito |
|
// La funzione svuoterà tutti i campi vuoti in cui è stato inserito il titolo da utilizzare come etichetta |
|
// inoltre validerà il form stesso prima di effettuare il submit. |
|
// Inserire la proprietà rel="validate" nel form per effettuare il controllo dei campi |
|
// Inserire la proprietà target se si vuole effettuare un submit classico |
|
// Non inserire tale proprietà per effettuare un submit tramite ajax |
|
// Inserire la proprietà rel nel tag per effettuare il controllo sul campo |
|
// Sintassi: rel="Obbligatorio;Lunghezza minima;Lunghezza Massima;Tipo" es. rel= "S;3;10;A" |
|
// Obbligatorio = 'S' qualsiasi altro valore sarà considerato non obbligatorio |
|
// Lunghezza minima = Numerico; 0 nessun limite |
|
// Lunghezza Massima = Numerico; 0 nessun limite |
|
// Tipo = A: Alfanumerico ALFA: Alfabetico N: Numerico E:email D: Data F: File I:Immagine YV: Linl a video di youtube |
|
// L: Link |
|
// Checked: Selezionato (Riferito a checkbox) |
|
|
|
$("form").unbind("submit"); |
|
$("form :input").unbind("focusout"); |
|
$("form :input").focusout(function() { |
|
msg = valida($(this)); |
|
}); |
|
|
|
$("form").not('.undeferred').submit(function(event) { |
|
var controllo = false; |
|
if (($(this).attr("rel") !== null) && ($(this).attr("rel") == "validate")) { |
|
controllo = true; |
|
} |
|
var msg = ""; |
|
// Aggiorna il contenuto di eventuali istanze di CKEditor |
|
if(window.CKEDITOR.length > 0) { |
|
for(var j = 0; j < window.CKEDITOR.length; j++) { |
|
window.CKEDITOR[j].updateSourceElement(); |
|
} |
|
} |
|
// Analizza tutti i campi del database |
|
$(this).find(":input, .valida").each(function() { |
|
// Se la proprieta rel è stata impostata su validate per il form passa al controllo |
|
if (controllo) { |
|
if ($(this).parents(".chosen-search").length === 0 && $(this).attr("type") != "radio") { |
|
tmp_msg = valida($(this)); |
|
if (tmp_msg.length > 0) { |
|
for (i=0;i<tmp_msg.length;i++) { |
|
msg += tmp_msg[i] + "<br>"; |
|
} |
|
} |
|
} |
|
} |
|
}); |
|
check_error_tabs(); |
|
if (msg !== "") { |
|
etichette_testo(); |
|
swal({ |
|
title:js_dict.attenzione, |
|
html:"<div class='text-danger rounded-0'>" + msg + "</div>", |
|
type:"error", |
|
confirmButtonText: "OK", |
|
confirmButtonColor: 'var(--success)', |
|
}); |
|
$("#wait_div").slideUp('fast'); |
|
return false; |
|
} else { |
|
$("#wait_div").show(); |
|
$(this).find("input").not(".ckeditor").each(function() { |
|
$(this).val(escapeHtmlEntities($(this).val())); |
|
var stringa = $(this).val(); |
|
var valore = $('<div />').html(stringa).text(); |
|
$(this).val(valore); |
|
}); |
|
if ($(this).attr("target") === undefined) { |
|
var data = $(this).serialize(); // Creazione di una stringa con il valore dei vari input del form da utilizzare per il submit ajax |
|
if (typeof event.originalEvent != "undefined") { |
|
if (typeof event.originalEvent.submitter != "undefined") { |
|
var submitter = $(event.originalEvent.submitter); |
|
|
|
if (typeof submitter.attr('name') != "undefined" && typeof submitter.attr('value') != "undefined" && submitter.attr('name') != "" && submitter.attr('value') != "") { |
|
data += "&" + submitter.attr('name') + "=" + submitter.attr('value'); |
|
} |
|
} |
|
} |
|
etichette_testo(); |
|
$.ajax({ |
|
type: "POST", |
|
url: $(this).attr("action"), |
|
data: data, |
|
dataType: "script", |
|
async: true, |
|
success: function(result) { |
|
result; |
|
$("#wait_div").slideUp('fast'); |
|
}, |
|
error: function (request, textStatus, errorThrown) { |
|
if (errorThrown == "Forbidden") { |
|
swal({title:js_dict.attenzione,text:js_dict["error-permission"],type:"error"}); |
|
} else { |
|
swal({title:js_dict.attenzione,text:js_dict["error-generic"],type:"error"}); |
|
} |
|
$("#wait_div").slideUp('fast'); |
|
} |
|
}); |
|
return false; |
|
} |
|
if ($(this).attr("target") != "_self") $("#wait_div").slideUp('fast'); |
|
} |
|
}); |
|
|
|
$('[data-toggle="tooltip"]').tooltip() |
|
} |
|
|
|
reset_password = function(codice,codice_ente) { |
|
if (typeof codice !== "undefined") { |
|
queryString = "codice="+codice+"&codice_ente="+codice_ente; |
|
$.ajax({ |
|
type: "POST", |
|
url: "/profilo/send-reset.php", |
|
data: queryString, |
|
dataType: "script", |
|
async: true, |
|
success: function(result) { |
|
result; |
|
}, |
|
error: function () { |
|
swal({title:js_dict.attenzione,text:js_dict["error-generic"],type:"error"}); |
|
} |
|
}); |
|
} |
|
return false; |
|
} |
|
|
|
change_password = function() { |
|
var checked = $("#edit-password").prop('checked'); |
|
if (checked) { |
|
if ($("#check-password").length>0) { |
|
$("#check-password").slideDown(); |
|
rel = "S;8;32;P;check-password;="; |
|
$("#check-password").attr("rel","S;8;32;P"); |
|
$("#check-password").removeAttr("disabled"); |
|
} else { |
|
rel = "S;8;32;P"; |
|
} |
|
$("#password").removeAttr("disabled"); |
|
$("#password").attr("rel", rel); |
|
} else { |
|
if ($("#check-password").length>0) { |
|
$("#check-password").slideUp(); |
|
$("#check-password").parents(".form-group").first().removeClass("has-error"); |
|
$("#check-password").attr("rel","N;8;16;A"); |
|
$("#check-password").attr("disabled", true); |
|
} |
|
rel = "N;8;16;A"; |
|
$("#password").attr("disabled", true); |
|
$("#password").parents(".form-group").first().removeClass("has-error"); |
|
$("#password").attr("rel", rel); |
|
} |
|
} |
|
|
|
update_badges = function() { |
|
var badge_containers = $(".badge-container"); |
|
if(badge_containers.length > 0) { |
|
for (var i = badge_containers.length - 1; i >= 0; i--) { |
|
var url = $(badge_containers[i]).data("target"); |
|
if (url !== undefined) { |
|
var total = 0; |
|
$(".badge-count","#main-tools").each(function(index, element) { |
|
if ($(this).html().trim() != "") total += parseInt($(this).html()); |
|
}); |
|
if (total > 0) { |
|
$('#badge-count-total').html(total); |
|
} else { |
|
$('#badge-count-total').html(""); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
$(document).on('show.bs.modal', '.modal', function () { |
|
var zIndex = 1040 + (10 * $('.modal:visible').length); |
|
$(this).css('z-index', zIndex); |
|
setTimeout(function() { |
|
$('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack'); |
|
}, 0); |
|
}); |
|
|
|
$(document).ready(function() { |
|
update_badges(); |
|
f_ready(); |
|
createSideBarAnchors(); |
|
$("#wait_div").slideUp('fast'); |
|
setInterval(updateClock, 250); |
|
// setInterval(getTime, 50250); |
|
setInterval(getTime, 180000); |
|
}); |
|
|
|
|
|
var LightenColor = function(color, percent) { |
|
var num = parseInt(color.replace("#",""), 16), |
|
amt = Math.round(2.55 * percent), |
|
R = (num >> 16) + amt, |
|
B = (num >> 8 & 0x00FF) + amt, |
|
G = (num & 0x0000FF) + amt; |
|
return "#" + (0x1000000 + (R<255?R<1?0:R:255)*0x10000 + (B<255?B<1?0:B:255)*0x100 + (G<255?G<1?0:G:255)).toString(16).slice(1); |
|
}; |
|
|
|
var maxLength = 16; |
|
var minLength = 8; |
|
var uppercaseMinCount = 1; |
|
var lowercaseMinCount = 1; |
|
var numberMinCount = 1; |
|
var specialMinCount = 1; |
|
var UPPERCASE_RE = /([A-Z])/g; |
|
var LOWERCASE_RE = /([a-z])/g; |
|
var NUMBER_RE = /([\d])/g; |
|
var SPECIAL_CHAR_RE = /([\?\-])/g; |
|
var NON_REPEATING_CHAR_RE = /([\w\d\?\-])\1{2,}/g; |
|
|
|
isStrongEnough = function(password) { |
|
var uc = password.match(UPPERCASE_RE); |
|
var lc = password.match(LOWERCASE_RE); |
|
var n = password.match(NUMBER_RE); |
|
var sc = password.match(SPECIAL_CHAR_RE); |
|
var nr = password.match(NON_REPEATING_CHAR_RE); |
|
return password.length >= minLength && |
|
!nr && |
|
uc && uc.length >= uppercaseMinCount && |
|
lc && lc.length >= lowercaseMinCount && |
|
n && n.length >= numberMinCount && |
|
sc && sc.length >= specialMinCount; |
|
} |
|
|
|
customPassword = function() { |
|
var password = ""; |
|
var randomLength = Math.floor(Math.random() * (maxLength - minLength)) + minLength; |
|
while (!isStrongEnough(password)) { |
|
password = generatePassword(randomLength, false, /[\w\d\?\-]/); |
|
} |
|
return password; |
|
} |
|
|
|
leggiCookie = function(nomeCookie) |
|
{ |
|
if (document.cookie.length > 0) |
|
{ |
|
var inizio = document.cookie.indexOf(nomeCookie + "="); |
|
if (inizio != -1) |
|
{ |
|
inizio = inizio + nomeCookie.length + 1; |
|
var fine = document.cookie.indexOf(";",inizio); |
|
if (fine == -1) fine = document.cookie.length; |
|
return unescape(document.cookie.substring(inizio,fine)); |
|
}else{ |
|
return ""; |
|
} |
|
} |
|
return ""; |
|
} |
|
|
|
// Funzione per scaricare il contenuto testuale di un elemento come file |
|
|
|
downloadElementContents = function(element, filename) { |
|
var textToWrite = element.innerText; |
|
var textFileAsBlob = new Blob([textToWrite], {type:'text/plain'}); |
|
var fileNameToSaveAs = filename; |
|
|
|
var downloadLink = document.createElement("a"); |
|
downloadLink.innerHTML = "Download File"; |
|
downloadLink.download = fileNameToSaveAs; |
|
downloadLink.href = window.URL.createObjectURL(textFileAsBlob); |
|
downloadLink.onclick = function(){ |
|
document.body.removeChild(downloadLink); |
|
}; |
|
document.body.appendChild(downloadLink); |
|
|
|
downloadLink.click(); |
|
} |
|
uniqid = function(prefix = "", more_entropy = false) { |
|
const sec = Date.now() * 1000 + Math.random() * 1000; |
|
const id = sec.toString(16).replace(/\./g, "").padEnd(14, "0"); |
|
return `${prefix}${id}${more_entropy ? `_${Math.trunc(Math.random() * 100000000)}`:""}`; |
|
}; |