var INPUTCOLOR = "#cccccc"; //colore del bordo dell'input di default
var GIORNI = Array("lun","mar","mer","gio","ven","sab","dom");
var REGBR = new RegExp(" ","g");
var timeOutId; //Timeout di alertWin
var tmplMex ='
';
//******************************TinyMce objects******************************//
tinyFull = {
// General options
// mode : "textareas",
language : "it",
mode : "exact",
skin:"lightgray",
width : "590",
height : "330",
body_class: "editing",
//invalid_elements : "strong",
//valid_elements : "b/strong",
plugins: [
"advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker",
"searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking",
"save table contextmenu directionality emoticons template paste textcolor google_tools biblioteca youtube"
],
menu: {
file: {title: 'File', items: 'newdocument print'},
edit: {title: 'Edit', items: 'undo redo | cut copy paste pastetext | selectall | searchreplace'},
insert: {title: 'Insert', items: 'link image google_tools biblioteca youtube | charmap hr insertdatetime template'},
view: {title: 'View', items: 'visualchars visualblocks visualaid | preview fullscreen'},
format: {title: 'Format', items: 'bold italic underline strikethrough superscript subscript | formats | removeformat'},
table: {title: 'Table', items: 'inserttable tableprops deletetable | cell row column'}
},
//menubar: "file edit insert view format table", //tools
toolbar: "bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist | outdent indent | code | image template google_tools biblioteca youtube",
content_css : "css/tiny.css?" + new Date().getTime(),
// Drop lists for link/image/media/template dialogs
// template_external_list_url : "lists/template_list.js",
// external_link_list_url : "lists/link_list.js",
// external_image_list_url : "lists/image_list.js",
// media_external_list_url : "lists/media_list.js",
templates : [
{title: "Centrato",
url: "js/tinymce/templates/tmpl1.htm",
description: "Slide con titolo e testo centrati."
},
{title: "A sinistra",
url: "js/tinymce/templates/tmpl2.htm",
description: "Slide con titolo e testo allineati a sinistra."
},
{title: "A destra",
url: "js/tinymce/templates/tmpl3.htm",
description: "Slide con titolo e testo allineati a destra."
},
{title: "Immagine grande centrata",
url: "js/tinymce/templates/tmpl4.htm",
description: "Slide con titolo e immagine grande centrata testo allineato a sinistra."
}
],
relative_urls:false
}
tinyNota = {
// Lezione nota
// General options
// mode : "textareas",
body_class: "editing",
language : "it",
mode : "exact",
skin:"lightgray",
toolbar: "bold italic underline",
content_css : "css/tiny.css?" + new Date().getTime(),
relative_urls:false,
menubar : false
//statusbar: false
}
tinyMini = {
language : "it",
mode : "exact",
skin:"lightgray",
//width : "590",
menubar : false,
toolbar: "bold italic underline | numlist",
content_css : "css/tiny.css?" + new Date().getTime(),
relative_urls:false
}
// Eventi nella pagina
function addEvent(obj, evType, fn){
if (obj.addEventListener){
obj.addEventListener(evType, fn, true);
return true;
} else if (obj.attachEvent){
var r = obj.attachEvent("on"+evType, fn);
return r;
} else {
return false;
}
}
//------------------------------------------------------------
// ****************** APERTO CHIUSO *********************
// ****************** ON OFF *********************
function switchAccesoSpento(idInput,obj){
idInputOld = document.getElementById(idInput).value;
idInputNew = idInputOld=='0'?"1":"0";
document.getElementById(idInput).value = idInputNew;
if(idInputNew=='1'){
replaceClass(obj,'spento','acceso');
}else{
replaceClass(obj,'acceso','spento');
}
}
function switchAccesoSpenti(obj,idHidden,val){ // radio buttons
var hid = document.getElementById(idHidden);
var lnks = hid.parentNode.getElementsByTagName('A');
for(var l in lnks){
if(lnks[l].nodeType==1){
if(lnks[l].className.indexOf('acceso')>-1){
replaceClass(lnks[l],'acceso','spento');
}
}
}
replaceClass(obj,'spento','acceso');
hid.value = val;
}
function switchClass(obj,aClass){
obj = document.getElementById(obj);
if(hasClass(obj,aClass)){
replaceClass(obj,'aperto','chiuso');
}else{
replaceClass(obj,'chiuso','aperto');
}
}
// ****************** fine ON OFF *********************
function replaceClass(obj,oldClass,newClass){
objClass = obj.className;
objClassAr = objClass.split(" ");
newText = new Array();
for(var n=0; n= 0)
return true;
return false;
}
}
function convDate(data){
dummy2 = data.split("-").reverse().join("-");
return dummy2;
}
function controlField(nome,id,id2,tipo){
switch(tipo){
case "_": // controlla se il campo = vuoto
if(document.getElementById(id).value == false){
alertWinScroll(id, 400, ""+nome+": Campo mancante");
document.getElementById(id).focus();
document.getElementById(id).style.border = "1px solid #FF9900";
return false;
}else{
return true;
}
break;
case "__": // controlla se il campo = vuoto con ""
if(document.getElementById(id).value == ""){
alertWinScroll(id, 400, ""+nome+": Campo mancante");
document.getElementById(id).focus();
document.getElementById(id).style.border = "1px solid #FF0000";
return false;
}else{
return true;
}
break;
case "@": // controlla la validita del campo mail
if(!indirizzoEmailValido(document.getElementById(id).value)){
alertWinScroll(id, 400, ""+nome+": ##campo_non_valido##");
document.getElementById(id).style.border = "1px solid #FF9900";
document.getElementById(id).focus();
return false;
}else{
return true;
}
break;
case "=": // confronta due campi
if(document.getElementById(id).value != document.getElementById(id2).value){
//alertWin("Le "+nome+" non Coincidono");
alertWinScroll(id, 400, ""+nome+": ##non_coincidenti##");
document.getElementById(id).focus();
document.getElementById(id).style.border = "1px solid #FF9900";
document.getElementById(id2).value = "";
return false;
}else{
return true;
}
break;
case "h": // controlla se il campo hidden = vuoto
if(document.getElementById(id2).value == false){
alertWinScroll(id, 400, ""+nome+": Campo mancante");
document.getElementById(id).focus();
document.getElementById(id).style.border = "1px solid #FF0000";
return false;
}else{
return true;
}
break;
case "hS": // controlla se il campo autoSuggest = vuoto
if(document.getElementById(id2).value == ""){
if(document.getElementById(id).value == false){
alertWinScroll(id, 400, ""+nome+": Campo mancante");
}else{
alertWin(nome+": non presente tra i dati disponibili");
}
document.getElementById(id).focus();
document.getElementById(id).style.border = "1px solid #FF0000";
return false;
}else{
return true;
}
break;
case "c": // controlla se il campo e' piu' lungo di un tot
if(document.getElementById(id).value.length > id2){
alertWin(nome+": il campo deve contenere un massimo di "+id2+" caratteri");
document.getElementById(id).focus();
document.getElementById(id).style.border = "1px solid #FF0000";
return false;
}else{
return true;
}
break;
case "c<": // controlla se il campo e' piu' corto di un tot
if(document.getElementById(id).value.length < id2){
alertWinScroll(id, 400, ""+nome+": ##campo_lunghezza_minima## " +id2+ " ##caratteri##" );
document.getElementById(id).focus();
document.getElementById(id).style.border = "1px solid #FF0000";
return false;
}else{
return true;
}
break;
case "n=": // controlla se il campo e' lungo n
if(document.getElementById(id).value.length != id2){
alertWin(nome+": il campo deve contenere "+id2+" caratteri");
document.getElementById(id).focus();
document.getElementById(id).style.border = "1px solid #FF0000";
return false;
}else{
return true;
}
break;
case "n": // controlla se il campo e' un numero
if(isNaN(document.getElementById(id).value.replace(',','.'))){
alertWin(nome+": il campo deve contenere solo numeri");
document.getElementById(id).focus();
document.getElementById(id).style.border = "1px solid #FF0000";
return false;
}else{
return true;
}
case "v<": // controlla se il valore del campo e' < di tot
if(parseInt(document.getElementById(id).value)>id2){
alertWin(nome+": il valore del campo deve essere inferiore a "+id2);
document.getElementById(id).focus();
document.getElementById(id).style.border = "1px solid #FF0000";
return false;
}else{
return true;
}
case "v>": // controlla se il valore del campo e' > di tot
if(parseInt(document.getElementById(id).value)id2){
alertWin(nome+": il valore del campo deve essere inferiore o uguale a "+id2);
document.getElementById(id).focus();
document.getElementById(id).style.border = "1px solid #FF0000";
return false;
}else{
return true;
}
case "v>=": // controlla se il valore del campo e' >= di tot
if(parseInt(document.getElementById(id).value)= del I
if(convDate(document.getElementById(id).value)>convDate(document.getElementById(id2).value)){
alertWin(nome+": il campo deve essere superiore o uguale al precedente");
document.getElementById(id2).focus();
document.getElementById(id2).style.border = "1px solid #FF0000";
return false;
}else{
return true;
}
break;
case "doc": // controllo se il file = un doc
obj = document.getElementById(id);
var extensions = new Array();
extensions[1] = "doc";
extensions[0] = "docx";
extensions[2] = "pdf";
extensions[3] = "rtf";
/*extensions[4] = "bmp";*/
var image_file = obj.value;
var image_length = image_file.length;
var pos = image_file.lastIndexOf('.') + 1;
var ext = image_file.substring(pos, image_length);
var final_ext = ext.toLowerCase();
for (i = 0; i < extensions.length; i++){
if(extensions[i] == final_ext){
return true;
}
}
alertWinScroll(id, 400, ""+nome+": ##formato_non_valido##");
document.getElementById(id).focus();
document.getElementById(id).style.border = "1px solid #FF9900";
return false;
break;
case "img": // controllo se il file = una img
obj = document.getElementById(id);
var extensions = new Array();
extensions[1] = "jpg";
extensions[0] = "jpeg";
extensions[2] = "gif";
extensions[3] = "png";
/*extensions[4] = "bmp";*/
var image_file = obj.value;
var image_length = image_file.length;
var pos = image_file.lastIndexOf('.') + 1;
var ext = image_file.substring(pos, image_length);
var final_ext = ext.toLowerCase();
for (i = 0; i < extensions.length; i++){
if(extensions[i] == final_ext){
return true;
}
}
alertWin("Seleziona un'immagine con una delle seguenti estensioni:\n\n gif, jpeg, jpg");
return false;
break;
default:
alertWin("tipo non riconosciuto");
return false;
}
}
/***** Nuovo ctrlField *****/
function ctrlObjField(tipo,nome,obj,objH){
var val = obj.value;
switch(tipo){
case "_": // stringa non vuoto
return notEmptyFld(nome,obj);
break;
case "true": // true
if(val=='0' || val=='false') val = 0;
val = Boolean(val);
if(val==false) alertWin(""+nome+": obbligatorio.");
return val;
break;
case "=": // due campi uguali
var r = val != objH.value
if(r){
$(window).scrollTop($(obj).offset().top-300);
alertWin(""+nome+": non coincidono.");
obj.focus();
obj.style.border = "1px solid #FF9900";
objH.value = "";
}
return !r;
break;
case "@": // email valida
var r = indirizzoEmailValido(val);
if(!r){
$(window).scrollTop($(obj).offset().top-300);
alertWin(""+nome+": non valida.");
obj.focus();
obj.style.border = "1px solid #FF9900";
}
return r;
break;
case "l<": // controlla se il campo e' piu' corto di un tot
var r = val.length < objH;
if(r){
$(window).scrollTop($(obj).offset().top-300);
alertWin(""+nome+": deve contenere almeno "+objH+" caratteri.");
obj.focus();
obj.style.border = "1px solid #FF9900";
}
return !r;
break;
default:
alertWin("tipo non riconosciuto");
return false;
}
}
function notEmptyFld(nome,obj){
if(obj.value == false){
$(window).scrollTop($(obj).offset().top-300);
alertWin(""+nome+": Campo mancante");
obj.focus();
obj.style.border = "1px solid #FF9900";
return false;
}else{
return true;
}
}
function viewLoader(mex){
jQuery('#message').fadeOut();
sc = document.body.scrollTop || document.documentElement.scrollTop || window.pageYOffset || 0;//document.documentElement.scrollTop;
dTop = sc+200;
sWidth = document.body.clientWidth;
sx = (sWidth-300)/2;
if(sx <0) sx = 0;
var t = tmplLoad;
t = t.replace(/##w##/g, '300');
t = t.replace(/##h##/g, '62');
t = t.replace(/##mex##/g, mex);
document.getElementById('loader').innerHTML = t;
document.getElementById('loader').style.top = dTop+"px";
document.getElementById('loader').style.left = sx+"px";
document.getElementById('loader').style.display = "block";
}
function hideLoader(cont,dbg){
if(dbg){
if(typeof(cont)!='string') cont = JSON.stringify(cont);
document.getElementById('loader').innerHTML = cont;
document.getElementById('loader').style.display = "block";
}else{
document.getElementById('loader').style.display = "none";
document.getElementById('loader').innerHTML = "";
}
}
function alertWin(mex){
sc = document.body.scrollTop || document.documentElement.scrollTop || window.pageYOffset || 0;
dTop = sc+200;
sWidth = document.body.clientWidth;
sx = (sWidth-400)/2;
if(sx <0) sx = 0;
var t = tmplMex;
t = t.replace(/##w##/g, '400');
t = t.replace(/##h##/g, '200');
t = t.replace(/##titolo##/g, 'Avviso!');
t = t.replace(/##mex##/g, mex);
document.getElementById('message').innerHTML = t;
document.getElementById('message').style.top = dTop+"px";
document.getElementById('message').style.left = sx+"px";
document.getElementById('message').style.display = "block";
if(timeOutId) clearTimeout(timeOutId);
timeOutId = setTimeout(hideWin,3000);
}
function hideWin(){
if(timeOutId) clearTimeout(timeOutId);
document.getElementById('message').style.display = "none";
document.getElementById('message').innerHTML = "";
}
function alertWinScroll(id, duration, mex){
$(window).scrollTop($('#'+id).offset().top-300);
alertWin(mex);
}
function openSemiModal(w,h,title,type,url,uri,doEvent){
var obj = {};
obj.win = document.getElementById('semiModal');
obj.close = function(){
this.win.style.display = "none";
this.win.innerHTML = "";
}
obj.caller = this;
if(doEvent=='') doEvent= undefined;
obj.doEvent = doEvent;
if(uri==undefined) uri = '';
if(url==undefined) url = '';
if(type=='') type = 'text';
if(w=='') w = document.body.clientWidth-20;
if(h=='') h = window.screen.availHeight-20;
var sc = document.body.scrollTop || document.documentElement.scrollTop || window.pageYOffset || 0;
obj.win.innerHTML='';
var dTop = sc+40;
var sx = (document.body.clientWidth-w)/2;
if(sx<0) sx = 0;
viewLoader("Caricamento in corso...");
obj.endLoad = function(res){
hideLoader(res,0);
if(this.win.style.display!="block"){
this.win.style.top= dTop+"px";
this.win.style.left=sx+"px";
}
var t = tmplSemiModal;
t = t.replace(/##w##/g, w);
t = t.replace(/##h##/g, h);
if(type=='json'){//Dati JSON
if(this.doEvent==undefined) t = t.replace(/##mex##/g, JSON.stringfy(res));
}else{// Text
if(this.doEvent==undefined) t = t.replace(/##mex##/g, res);
}
t = t.replace(/##mex##/g,'');
if(title!=''){
t = t.replace(/##tit##/g, Encoder.htmlEncode(title));
}else{
if(res.t!=undefined && res.t!=''){
t = t.replace(/##tit##/g, Encoder.htmlEncode(res.t));
}else{
t = t.replace(/##tit##/g, Encoder.htmlEncode(title));
}
}
/*if(url=='' || type=='text'){
t = t.replace(/##tit##/g, Encoder.htmlEncode(title));
}else if(res.t!=undefined && res.t!=''){
t = t.replace(/##tit##/g, Encoder.htmlEncode(res.t));
}*/
this.win.innerHTML = t;
var oThis = this;
$('.mexClose').bind('click',function(){oThis.close()});
if(typeof this.doEvent === 'function') this.doEvent.call(this.caller,res);
$(this.win).draggable({ handle: ".mexTitle" });
this.win.style.display="block";
}
if(url==''){
obj.endLoad(uri);
}else{
$.post('https://prometeo3.palumboeditore.it/'+url,uri,function(){},type)
.done(function(r){obj.endLoad(r)}).fail(openSemiModal.bind(obj.caller,w,h,title,type,url,uri,obj.doEvent));
//.fail(function(){openSemiModal(w,h,type,url,uri,doEvent)});
}
}
function openModal(title,body,footer){
viewLoader("Caricamento in corso...");
var win = document.getElementById('modal-one');
win.style.display = "block";
var t = tmplModal;
t = t.replace(/##title##/g, title);
t = t.replace(/##body##/g, body);
t = t.replace(/##footer##/g, footer);
win.innerHTML = t;
var links = win.getElementsByTagName('TEXTAREA');
for(var l in links){
if(links[l].nodeType==1){
if(links[l].name=='corpo'){
links[l].id = "editableArea";
tinyMCE.editors=[];
tinyMCE.init(tinyMini);
tinyMCE.execCommand('mceAddEditor',false,"editableArea");
};
}
}
hideLoader('',0);
}
function closeModal(){
hideLoader('',0);
$('video, audio').each(function() {
$(this)[0].player.pause();
});
history.pushState(null, null, '#close');
var win = document.getElementById('modal-one');
win.style.display = "none";
win.innerHTML = "";
}
function ctrlKey(e,o){
if(e.keyCode==13) document.getElementById(o).click();
}
function stopRedirect(ev,lnk){
e = ev || window.event;
trg = e.srcElement || e.target;
if(trg.nodeName!='INPUT') window.location.href = lnk;
}
function getPosX(obj) {
var curleft = 0;
if (obj.offsetParent) {
while (obj.offsetParent) {
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (obj.x)
curleft += obj.x;
return curleft;
}
function getPosY(obj) {
var curtop = 0;
if (obj.offsetParent) {
while (obj.offsetParent) {
curtop += obj.offsetTop
obj = obj.offsetParent;
}
}
else if (obj.y)
curtop += obj.y;
return curtop;
}
/*
function openDivEvent(w,urlAj,corrX,corrY,doEvent){
this.win = document.getElementById('win');
xx = corrX;//getPosX(document.getElementById(idOpen))+corrX;
sc = document.body.scrollTop || document.documentElement.scrollTop || window.pageYOffset || 0;//document.documentElement.scrollTop;
yy = corrY+sc;//getPosY(document.getElementById(idOpen))+corrY+document.body.scrollTop;
win.style.width = w+"px";
viewLoader("Caricamento in corso...");
myajax.post(urlAj,"");
myajax.echoFunction=function(response){
hideLoader(response,0);
if(win.style.display !="block"){
win.style.top=yy+"px";
win.style.left=xx+"px";
}
win.innerHTML = response;
win.style.display="block";
Drag.init(document.getElementById("handle"),document.getElementById('win'));
doEvent();
}
}
function loadDivContent(obj,urlAj,uriAj,doEvent,dbg){
obj = document.getElementById(obj);
viewLoader("Caricamento in corso...");
myajax.post(urlAj,uriAj);
myajax.echoFunction=function(response){
hideLoader(response,dbg);
obj.innerHTML = response;
doEvent();
}
}
*/
function openSelect(w,h,idName,idValue,urlAj,corrX,corrY,multi,any){
this.win = document.getElementById('select');
//selIds = "";
selIds = document.getElementById(idValue).value;
selNames = document.getElementById(idName).value;
if(!multi){
document.onmouseup=function(e){
e = e || window.event;
trg = e.srcElement || e.target;
if(trg.id!="select"){
document.getElementById('select').style.display='none';
document.onmouseup='';
}
}
}else {
//selIds = document.getElementById(idValue).value;
}
xx = getPosX(document.getElementById(idName))+corrX;
yy = getPosY(document.getElementById(idName))+corrY;
win.style.width = w+"px";
win.style.height = h+"px";
win.style.overflow = "auto";
viewLoader("Caricamento in corso...");
myajax.post(urlAj,'idName='+idName+'&idValue='+escape(idValue)+'&multi='+multi+'&any='+any+'&selIds='+selIds+'&selNames='+escape(selNames));
myajax.echoFunction=function(response){
hideLoader(response,0);
win.style.top=yy+"px";
win.style.left=xx+"px";
win.style.textAlign = "left";
win.innerHTML = response;
win.style.display="block";
}
}
function openSelectEvent(w,h,idName,idValue,urlAj,corrX,corrY,multi,any,doEvent){
this.win = document.getElementById('select');
selIds = "";
if(!multi){
document.onmouseup=function(){
document.getElementById('select').style.display='none';
document.onmouseup='';
}
}else {
selIds = document.getElementById(idValue).value;
}
xx = getPosX(document.getElementById(idName))+corrX;
yy = getPosY(document.getElementById(idName))+corrY;
win.style.width = w+"px";
win.style.height = h+"px";
win.style.overflow = "auto";
viewLoader("Caricamento in corso...");
myajax.post(urlAj,'idName='+idName+'&idValue='+escape(idValue)+'&multi='+multi+'&any='+any+'&selIds='+selIds);
myajax.echoFunction=function(response){
hideLoader(response,0);
win.style.top=yy+"px";
win.style.left=xx+"px";
win.style.textAlign = "left";
win.innerHTML = response;
win.style.display="block";
doEvent();
}
}
function xsetControl(val, obj){
var parentObj = obj.parentNode.childNodes;
for(i=0; ilat "
+ results[0].geometry.location.lat() + "
lng "
+ results[0].geometry.location.lng() + "
hai cercato:"
+ address + "
");
infowindow.open(map, marker);
/*google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map, marker);
});*/
} else {
alert("Indirizzo non trovato, risposta del geocoder: " + status);
}
});
}
}
}
//PLUGIN CONFIGURATION
var gtools_options = {
//Google API Key (please read install.txt)
google_developer_key: "AIzaSyDYWB9HnzHjECZxM6DlzQ3FeqiFlOP6fEI",
//Google API ID (please read install.txt)
api_id: "539789617912-122fqs68vrjui0vrg98r2i1498urqm3p.apps.googleusercontent.com",
//Better not touch.
google_scopes: [
'https://gdata.youtube.com', //Youtube info
'https://www.googleapis.com/auth/drive.file', //Drive info
'https://picasaweb.google.com/data/' //Picasa info
],
//Language (es, en, etc.)
locale: 'it',
//Available views (just change it to true or false to load or not)
show_drive_docs: true,
show_image_search: false,
show_youtube_videos: false,
show_youtube_search: false,
show_recent_docs: true,
allow_multiselect: true,
//Allow links to open on a new window
new_window: true
}
//******************************************
//********** FINE GOOGLE MAP **********
//******************************************
// ************* Storage *************
var chkStorage = true;
function setStorage(nome) {
if(typeof(Storage) === "undefined") {
if(chkStorage) alert('Dispositivo non supportato');
chkStorage = false;
return false;
}
obj = new storageClass(nome);
return obj;
}
function storageClass(nome){
this.nome = nome;
this.store = '';
if(localStorage.getItem(this.nome)==null) localStorage.setItem(this.nome,"{}");
this.store = JSON.parse(localStorage.getItem(this.nome));
}
storageClass.prototype.set = function (n,v) {
if(v==undefined){alert("db.set errato");return false};
var obj = n.split('.');
var addr = '';
for(k in obj){
addr += "['"+obj[k]+"']";
eval("if(this.store"+addr+"==undefined) this.store"+addr+" = new Object()");
}
eval("this.store"+addr+" = v");
//this.store[n] = v;
localStorage.setItem(this.nome,JSON.stringify(this.store));
}
storageClass.prototype.get = function (n) {
return this.store[n];
}
storageClass.prototype.del = function (n) {
delete this.store[n];
localStorage.setItem(this.nome,JSON.stringify(this.store));
}
// ************* Fine Storage *************
// ************* Detrit *************
// ************* Decimal tree *************
function detrit(array,key) {
this.id = key;
this.root = {value:null};
for(k in array){
this.set(array[k]);
}
return this;
}
detrit.prototype.set = function(el){
this.pt = this.root;
this.add(el,String(el[this.id]));
}
detrit.prototype.lastArray = function(str){
var n = str.length-1;
return([str[n],str.slice(0,n)]);
}
detrit.prototype.add = function(el,name){
var idx = this.lastArray(name);
if(this.pt[idx[0]]==undefined) this.pt[idx[0]] = {value:null};
this.pt = this.pt[idx[0]];
if(idx[1]==''){
this.pt.value = el;
}else{
this.add(el,idx[1]);
}
}
detrit.prototype.get = function(key){
var keys = String(key).split('').reverse().join('][');
if(keys==''){
return null;
}else{
try{
return eval('this.root['+keys+'].value');
}catch(err) {return null}
}
}
// ************* !Detrit *************
String.prototype.escapeSpecialChars = function() {
return this.replace(/[\\]/g, '\\\\')
.replace(/[\"]/g, '\\\"')
.replace(/[\/]/g, '\\/')
.replace(/[\b]/g, '\\b')
.replace(/[\f]/g, '\\f')
.replace(/[\n]/g, '\\n')
.replace(/[\r]/g, '\\r')
.replace(/[\t]/g, '\\t');
// for backslash, quotation, forward slash, backspace, formfeed, newline, return, tab
};
function fancyConfirm(msg,callbackYes,callbackNo) {
var ret;
jQuery.fancybox({
'modal' : true,
/* 'content' : "
"+
msg+"
"+
" "+
"
",
*/
'content' : "
"+
msg+"
"+
" "+
"
",
'beforeShow' : function() {
jQuery("#fancyconfirm_cancel").click(function() {
$.fancybox.close();
callbackNo();
});
jQuery("#fancyConfirm_ok").click(function() {
$.fancybox.close();
callbackYes();
});
}
});
}
function ja(o){
alert(JSON.stringify(o));
console.log(JSON.stringify(o));
}
function sja(o){
var str = '';
for(var i in o){
if(str!='') str +=',';
str += i +":" + typeof o[i];
}
alert(str);
}
/**************** User **********************/
function ctrlLogin(obj){
flag = true;
flag = flag && controlField('Username','userL','','_');
flag = flag && controlField('Password','passL','','_');
if(flag){
viewLoader("Caricamento in corso");
strUri = buildUri(obj);
$.post('https://prometeo3.palumboeditore.it/validate',strUri,function(){},'json')
.done(function(resp){
if(resp.status=="ok"){
/*modifica effettuata da fabrizio il 14/09/2017 dopo il login si viene reinderizzati alla biblioteca*/
window.location.href = 'https://prometeo3.palumboeditore.it/biblioteca';
/*setTimeout(function(){window.location.reload(false)},300);*/
}else if(resp.status=="rg") {
window.location.href = 'https://prometeo3.palumboeditore.it/registra';
}else if(resp.status=="ko") {
alertWin("Utente non valido");
}else if(resp.status=="dup"){
alertWin("Utente già loggato");
}
}).fail(function(){})
.always(function(resp){hideLoader(resp,0);});
}
}
function rePass(obj){
resetBorder(obj);
flag = controlField("User-name",'blablaR','','_');
if(flag){
viewLoader("Recupero password...");
var strUri = buildUri(obj);
$.post('https://prometeo3.palumboeditore.it/resetPass',strUri,function(){},'json')
.done(function(resp){
if(resp.s=="ok"){
alertWin("Abbiamo inviato la password provvisoria alla tua casella e-mail.");
}else if(resp.s=="nf") {
alertWin("Utente non trovato.");
}else if(resp.s=="ko"){
alertWin("Errore durante il recupero della password.");
}else if(resp.s=="at") {
alertWin("Non abbiamo la tua email. Per recuperare la password, contattaci agli indirizzi posti in basso.");
}
}).fail(function(){alertWin("Errore di connessione");})
.always(function(resp){hideLoader(resp,0);});
}
}
function modUtente(frm){
var flds = formToObject(frm);
var flag = true;
flag = flag && ctrlObjField('_','Nome',flds.nome);
flag = flag && ctrlObjField('_','Cognome',flds.cognome);
flag = flag && ctrlObjField('_','Email',flds.email);
flag = flag && ctrlObjField('@','Email',flds.email);
if(flds.password.value!='' || flds.expassword.value!=''){
flag = flag && ctrlObjField('_','Cambia password',flds.password);
flag = flag && ctrlObjField('l<','Cambia password',flds.password,4);
flag = flag && ctrlObjField('=','Cambia password e ripeti password',flds.password,flds.repassword);
flag = flag && ctrlObjField('_','Vecchia password',flds.expassword);
}
if(flag){
var uri = {};
for(var a in flds) uri[flds[a].name] = encodeURIComponent(flds[a].value);
viewLoader("Caricamento in corso...");
$.post('https://prometeo3.palumboeditore.it/profiloMod','r='+JSON.stringify(uri),function(){},'json')
.done(function(r){
if(r.s=='ok' || r.s=='op'){
alertWin('Modifica effettuata.');
flds.password.value='';
flds.repassword.value='';
flds.expassword.value='';
}else if(r.s=='pw'){
alertWin('Vecchia password errata.');
}else{
alertWin('Errore durante la modifica.');
}})
.fail(function(){alertWin('Errore di conessione.')})
.always(function(){hideLoader('',0);});;
}
}
//-------------EBookPlus----------------
function addEBookP(idCap,type,content){
var uriStr = {idC:idCap,t:type,c:content};
$.post('https://prometeo3.palumboeditore.it/eBookAdd','r='+JSON.stringify(uriStr),function(){},'json')
.done(function(r){
if(r.s=='ok'){
alertWin('Contenuto aggiunto all\'E-Book+.');
if(''>'1'){
openSemiModal(950,600,'Gestione destinatari','','eBookDest','&idE='+r.c.idEb,function(res){document.getElementById('semiModal').firstChild.lastChild.innerHTML=res;});
}
}else if(r.s=='dup'){
alertWin('Contenuto già presente nell\'E-Book+.')
}else if(r.s=='ko'){
alertWin('Errore durante il salvataggio.');
};
})
.fail(function(){alertWin('Errore durante il salvataggio.')})
.always(function(){})
}
function switchEBookDest(obj,idEb,idCl){
flag = true;
if(idEb =="" || idCl=="") flag = false;
if(flag){
viewLoader("Caricamento in corso");
strUri = 'idEb='+encodeURIComponent(idEb)+'&idCl='+encodeURIComponent(idCl);
$.post('https://prometeo3.palumboeditore.it/eBookDestMod',strUri,function(){},'json')
.done(function(resp){
if(resp.s=="ok"){
if(resp.v=='1'){
replaceClass(obj,'spento','acceso');
}else{
replaceClass(obj,'acceso','spento');
}
}
})
.fail(function(){alertWin("Errore di connessione");})
.always(function(resp){hideLoader(resp,0);});
}
}
/****************Social gestione classi **********************/
function addClasse(obj){
flag = true;
flag = flag && controlField('Codice ministeriale','idCodMin','','_');
flag = flag && controlField('sezione','sezione','','_');
if(flag){
viewLoader("Caricamento in corso");
strUri = buildUri(obj);
$.post('https://prometeo3.palumboeditore.it/addClasse',strUri,function(){},'json')
.done(function(resp){
if(resp.status=="ok"){
window.location.reload(false);
}else if(resp.status=="ko") {
alertWin("Errore durante la creazione.");
}else if(resp.status=="dup"){
alertWin("Classe già esistente");
}
}).fail(function(){alertWin("Errore di connessione");})
.always(function(resp){hideLoader(resp,0);});
}
}
function selScuola(){
viewLoader("Caricamento in corso");
obj=document.getElementById('provinciaId');
strUri = "prv="+ obj.options[obj.selectedIndex].value;
$.post('https://prometeo3.palumboeditore.it/selScuola',strUri,function(){},'')
.done(function(resp){
document.getElementById('scuolaId').style.height='150px';
document.getElementById('scuolaId').innerHTML = resp;
document.getElementById('scuolaId').style.display='block';
})
.fail(function(){alertWin("Errore di connessione");})
.always(function(resp){hideLoader(resp,0);});
}
function setCodmin(val,nome){
document.getElementById('idCodMin').value=val;
document.getElementById('codMin').value=val;
document.getElementById('segnaPostoScuola').innerHTML=" Intestazione: "+Encoder.htmlEncode(nome)+"
'+ ' '+ ' Visualizza tutti i ##nCommenti## commenti'+ ' '+ '
'+ ''+ '- '+
' ##fotoMia##'+
'
'+
' '+
' '+
'
'+ //non mettere testo tra i due uso un lastchild ''+ '- Biblioteca
'+
' - Quaderno
'+
' - Slideshow
'+
' - Pagina web
'+
' - File personale
'+
' - Lezione
'+
' - Laboratori
'+ '