1// array_ext_foto 2var array_ext_foto=new Array(); 3array_ext_foto[0]="jpg"; 4array_ext_foto[1]="jpeg"; 5array_ext_foto[2]="gif"; 6array_ext_foto[3]="png"; 7array_ext_foto[4]="jpe"; 8array_ext_foto[5]="webp"; 9array_ext_foto[6]="svg"; 10 11// array_ext_foto2 12var array_ext_foto2=new Array(); 13array_ext_foto2[0]="jpg"; 14array_ext_foto2[1]="jpeg"; 15array_ext_foto2[2]="gif"; 16array_ext_foto2[3]="png"; 17array_ext_foto2[4]="jpe"; 18array_ext_foto2[5]="swf"; 19array_ext_foto2[6]="webp"; 20array_ext_foto2[7]="svg"; 21 22 23// array_ext_file 24var array_ext_file=new Array(); 25array_ext_file[0]="pdf"; 26array_ext_file[1]="doc"; 27array_ext_file[2]="docx"; 28array_ext_file[3]="rtf"; 29array_ext_file[4]="xls"; 30array_ext_file[5]="xlsx"; 31array_ext_file[6]="pps"; 32array_ext_file[7]="ppsx"; 33array_ext_file[8]="ppt"; 34array_ext_file[9]="pptx"; 35array_ext_file[10]="zip"; 36array_ext_file[11]="rar"; 37array_ext_file[12]="mp3"; 38array_ext_file[13]="avi"; 39array_ext_file[14]="gif"; 40array_ext_file[15]="jpg"; 41array_ext_file[16]="jpeg"; 42array_ext_file[17]="jpe"; 43array_ext_file[18]="png"; 44array_ext_file[19]="bmp"; 45array_ext_file[20]="3gp"; 46array_ext_file[21]="odt"; 47array_ext_file[22]="ods"; 48array_ext_file[23]="odp"; 49array_ext_file[24]="odg"; 50array_ext_file[25]="epub"; 51array_ext_file[26]="mobi"; 52array_ext_file[27]="p7m"; 53array_ext_file[28]="xml"; 54array_ext_file[29]="csv"; 55array_ext_file[30]="swf"; 56array_ext_file[31]="mp4"; 57array_ext_file[32]="kml"; 58array_ext_file[33]="mov"; 59array_ext_file[34]="webm"; 60array_ext_file[35]="ogg"; 61array_ext_file[36]="ogv"; 62array_ext_file[37]="gpx"; 63array_ext_file[38]="webp"; 64array_ext_file[39]="svg"; 65 66 67// array_ext_video 68var array_ext_video=new Array(); 69array_ext_video[0]="mpg"; 70array_ext_video[1]="mp4"; 71array_ext_video[2]="wmv"; 72array_ext_video[3]="avi"; 73array_ext_video[4]="flv"; 74 75//serve per dare un limite di inserimento caratteri nelle aree di testo 76 77function MaxText(objTxarea, max) 78 { 79 if(objTxarea.value.length <= max) 80 { 81 document.getElementById('contatore').value = objTxarea.value.length; 82 } 83 else 84 { 85 return false; 86 } 87 } 88 89function addslashes(str) 90 { 91 str=str.replace(/\\/g,'\\\\'); 92 str=str.replace(/\'/g,'\\\''); 93 str=str.replace(/\"/g,'\\"'); 94 str=str.replace(/\0/g,'\\0'); 95 96 return str; 97 } 98 99function stripslashes(str) 100 { 101 str=str.replace(/\\'/g,'\''); 102 str=str.replace(/\\"/g,'"'); 103 str=str.replace(/\\0/g,'\0'); 104 str=str.replace(/\\\\/g,'\\'); 105 106 return str; 107 } 108 109 110 111/*per il prezzo della ricerca immobili*/ 112 113// formatta automaticamente il prezzo durante l'inserimento 114function prezzoCheckFormat(valore,event,blurOnCheck,accettaDec, decimali) 115 { 116 117 if (!valore || !valore.value) 118 { 119 return false; 120 } 121 122 if (typeof decimali == "undefined") 123 { 124 decimali = 2; 125 } 126 127 if (typeof accettaDec == "undefined") 128 { 129 accettaDec = false; 130 decimali = 0; 131 } 132 133 134 var ev = event ? event : window.event; 135 136 var prezzo = valore.value.replace(/\./g,''); 137 138 var iLength_init = valore.value.length; 139 140 if (!prezzo) 141 { 142 valore.value = ""; 143 return false; 144 } 145 146 var PosCursore; 147 if (ev) 148 { 149 PosCursore = getPosCursore(valore); 150 } 151 152 var length = prezzo.length; 153 154 var prezzo_old = prezzo; 155 156 prezzo = ""; 157 alreadyAddedDecSep = false; 158 for (var i=0;i<length;i++) 159 { 160 if ( isNumeric(prezzo_old.charAt(i))) 161 { 162 if (prezzo_old.charAt(i)==",") 163 { 164 if(!accettaDec || alreadyAddedDecSep) 165 continue; 166 alreadyAddedDecSep = true; 167 } 168 prezzo = prezzo + "" + prezzo_old.charAt(i); 169 } 170 else 171 { 172 if (i < PosCursore) 173 { 174 PosCursore--; 175 } 176 } 177 } 178 179 var decimal = ""; 180 var hasDecimal = prezzo.search(/,/); 181 if (hasDecimal > 0) 182 { 183 var aPrezzo = prezzo.split(","); 184 185 if (2 == aPrezzo.length) 186 { 187 prezzo = aPrezzo[0]; 188 decimal = aPrezzo[1]; 189 190 if(decimal.length>decimali) 191 { 192 decimal=decimal.substring(0, decimali ); 193 } 194 } 195 } 196 197 length = prezzo.length; 198 var newPrice = new Array(); 199 var newPriceIdx = 0; 200 var digitCounter = 1; 201 for (var i=length;i>=1;i--) 202 { 203 newPrice[newPriceIdx++] = prezzo.charAt(i-1); 204 205 if (((i-1 % 3) != 0) && ((digitCounter % 3) == 0)) 206 { 207 digitCounter = 1; 208 newPrice[newPriceIdx++] = "."; 209 } 210 else 211 { 212 digitCounter++; 213 } 214 } 215 216 var output = ""; 217 for (var i=newPrice.length-1;i>=0;i--) 218 { 219 output+=newPrice[i]; 220 } 221 222 if (hasDecimal > 0) 223 output+=","+decimal; 224 225 valore.value = output; 226 var iLength_post = valore.value.length; 227 228 if (iLength_post > iLength_init) 229 PosCursore++; 230 231 if (ev) 232 setPosCursore(valore,PosCursore); 233 234 return true; 235 } 236 237 238function getPosCursore(oField) { 239 240 // Initialize 241 var iPosCursore = 0; 242 243 // IE Support 244 if (document.selection) { 245 246 // Set focus on the element 247 oField.focus (); 248 249 // To get cursor position, get empty selection range 250 var oSel = document.selection.createRange (); 251 252 // Move selection start to 0 position 253 oSel.moveStart ('character', -oField.value.length); 254 255 // The caret position is selection length 256 iPosCursore = oSel.text.length; 257 } 258 259 // Firefox support 260 else if (oField.selectionStart || oField.selectionStart == '0') 261 iPosCursore = oField.selectionStart; 262 263 // Return results 264 return (iPosCursore); 265} 266 267function setPosCursore(fieldOrId,pos){ 268 269 var oField = (typeof fieldOrId == "string" || fieldOrId instanceof String) ? document.getElementById(fieldOrId) : fieldOrId; 270 271 if(!oField){ 272 return false; 273 }else if(oField.createTextRange){ 274 var textRange = oField.createTextRange(); 275 textRange.collapse(true); 276 textRange.moveEnd('character',pos); 277 textRange.moveStart('character',pos); 278 textRange.select(); 279 280 281 return true; 282 }else if(oField.setSelectionRange){ 283 284 oField.setSelectionRange(pos,pos); 285 return true; 286 } 287 288 return false; 289} 290 291 292 293function isNumeric(valore) 294 295{ 296 if (typeof valore == "undefined" || valore == "") 297 return false; 298 299 var ValidChars = "0123456789,.-"; 300 var IsNumber=true; 301 var Char; 302 303 304 for (var i = 0; i < valore.length && IsNumber == true; i++) 305 { 306 Char = valore.charAt(i); 307 if (ValidChars.indexOf(Char) == -1) 308 { 309 IsNumber = false; 310 } 311 } 312 return IsNumber; 313 314} 315 316
317var StilePopupDiretta = "top=10, left=10, width=850, height=600, status=no, menubar=no, toolbar=no, scrollbars=yes"; 318 319function PopupDiretta(url,name) 320 { 321 window.open(url, name, StilePopupDiretta,false); 322 } 323 324 325 326function aggiungiLink(){ 327 var linkURL = prompt("Inserisci il link da aggiungere:", ""); 328 AttivaFrame("editArea").execCommand("createLink", false, linkURL); 329} 330 331function aggiungiLinkMailto(){ 332 var linkURL = prompt("Inserisci l'indirizzo email da utilizzare:", ""); 333 AttivaFrame("editArea").execCommand("createLink", false, "mailto:"+linkURL); 334} 335 336function applicaComando(cmdStr,valCmdStr){ 337 AttivaFrame('editArea').execCommand(cmdStr,false,valCmdStr); 338} 339 340// JavaScript Document 341function applicaTag(tag, form) 342 { 343 if(tag=='bold') 344 { 345 var tag_start="<strong>"; 346 var tag_end="</strong>"; 347 } 348 else if(tag=='italic') 349 { 350 var tag_start="<em>"; 351 var tag_end="</em>"; 352 } 353 else if(tag=='underline') 354 { 355 var tag_start="<u>"; 356 var tag_end="</u>"; 357 } 358 else if(tag=='strike') 359 { 360 var tag_start="<strike>"; 361 var tag_end="</strike>"; 362 } 363 else if(tag=='right') 364 { 365 var tag_start='<div align="right">'; 366 var tag_end="</div>"; 367 } 368 else if(tag=='left') 369 { 370 var tag_start='<div align="left">'; 371 var tag_end="</div>"; 372 } 373 else if(tag=='center') 374 { 375 var tag_start='<div align="center">'; 376 var tag_end="</div>"; 377 } 378 else if(tag=='justify') 379 { 380 var tag_start='<div align="justify">'; 381 var tag_end="</div>"; 382 } 383 384 var text 385 386 if(tag=='elenco') 387 { 388 if(document.all) 389 { 390 //IE7 IE6 IE5 OPERA 391 text = (document.all) ? document.selection.createRange().text : document.getSelection(); 392 if (text=="") 393 return false 394 else 395 { 396 text=elabora(text); 397 if (document.all) 398 document.selection.createRange().text=text 399 return true 400 } 401 } 402 //FIREFOX 403 else if(window.getSelection) 404 { 405 var rv = ""; 406 var i,x; 407 408 if(form) 409 { 410 var modulo=eval('document.'+form); 411 } 412 else 413 { 414 var modulo=eval('document.modulo'); 415 } 416 417 for (i = 0; x = modulo.elements[i]; i++) 418 { 419 if(x.type=='textarea' || x.type=='text') 420 { 421 rv = x.value.substr(x.selectionStart, x.selectionEnd - x.selectionStart) 422 if(rv!="") 423 { 424 rv=elabora(rv) 425 x.value=x.value.substr(0,x.selectionStart) + rv +x.value.substring(x.selectionEnd,x.value.length) 426 } 427 } 428 } 429 } 430 } 431 else 432 { 433 //IE7 IE6 IE5 OPERA 434 if(document.all) 435 { 436 text = (document.all) ? document.selection.createRange().text : document.getSelection(); 437 if (text=="") 438 { 439 return false 440 } 441 else 442 { 443 text=tag_start + text + tag_end 444 if (document.all) 445 document.selection.createRange().text=text 446 return true 447 } 448 } 449 //FIREFOX 450 else if(window.getSelection) 451 { 452 var rv = ""; 453 var i,x; 454 455 if(form) 456 { 457 var modulo=eval('document.'+form); 458 } 459 else 460 { 461 var modulo=eval('document.modulo'); 462 } 463 464 for (i = 0; x = modulo.elements[i]; i++) 465 { 466 if(x.type=='textarea' || x.type=='text') 467 { 468 rv = x.value.substr(x.selectionStart, x.selectionEnd - x.selectionStart); 469 if(rv!="") 470 { 471 x.value=x.value.substr(0,x.selectionStart) + tag_start + rv + tag_end +x.value.substring(x.selectionEnd,x.value.length); 472 } 473 } 474 } 475 } 476 } 477 } 478 479 480function applicaTagColore(tag, form, value) 481 { 482 if(tag=='colore') 483 { 484 if (typeof String.prototype.startsWith != 'function') { 485 // see below for better implementation! 486 String.prototype.startsWith = function (str){ 487 return this.indexOf(str) === 0; 488 }; 489 } 490 491 if(value.startsWith("#")) 492 { 493 var tag_start='<span style="color: '+value+';">'; 494 } 495 else 496 { 497 var tag_start='<span style="color: #'+value+';">'; 498 } 499 500 var tag_end="</span>"; 501 } 502 503 504 var text; 505 506 //IE7 IE6 IE5 OPERA 507 if(document.all) 508 { 509 text = (document.all) ? document.selection.createRange().text : document.getSelection(); 510 if (text=="") 511 { 512 return false 513 } 514 else 515 {
516 text=tag_start + text + tag_end 517 if (document.all) 518 document.selection.createRange().text=text 519 return true 520 } 521 } 522 //FIREFOX 523 else if(window.getSelection) 524 { 525 var rv = ""; 526 var i,x; 527 528 if(form) 529 { 530 var modulo=eval('document.'+form); 531 } 532 else 533 { 534 var modulo=eval('document.modulo'); 535 } 536 537 for (i = 0; x = modulo.elements[i]; i++) 538 { 539 if(x.type=='textarea' || x.type=='text') 540 { 541 rv = x.value.substr(x.selectionStart, x.selectionEnd - x.selectionStart) 542 if(rv!="") 543 { 544 x.value=x.value.substr(0,x.selectionStart) + tag_start + rv + tag_end +x.value.substring(x.selectionEnd,x.value.length) 545 } 546 } 547 } 548 } 549 } 550 551 552function applicaTagColoreEvidenziatore(tag, form, value) 553 { 554 if(tag=='colore') 555 { 556 if (typeof String.prototype.startsWith != 'function') { 557 // see below for better implementation! 558 String.prototype.startsWith = function (str){ 559 return this.indexOf(str) === 0; 560 }; 561 } 562 563 if(value.startsWith("#")) 564 { 565 var tag_start='<span style="background-color: '+value+';">'; 566 } 567 else 568 { 569 var tag_start='<span style="background-color: #'+value+';">'; 570 } 571 572 var tag_end="</span>"; 573 } 574 575 576 var text; 577 578 //IE7 IE6 IE5 OPERA 579 if(document.all) 580 { 581 text = (document.all) ? document.selection.createRange().text : document.getSelection(); 582 if (text=="") 583 { 584 return false 585 } 586 else 587 { 588 text=tag_start + text + tag_end 589 if (document.all) 590 document.selection.createRange().text=text 591 return true 592 } 593 } 594 //FIREFOX 595 else if(window.getSelection) 596 { 597 var rv = ""; 598 var i,x; 599 600 if(form) 601 { 602 var modulo=eval('document.'+form); 603 } 604 else 605 { 606 var modulo=eval('document.modulo'); 607 } 608 609 for (i = 0; x = modulo.elements[i]; i++) 610 { 611 if(x.type=='textarea' || x.type=='text') 612 { 613 rv = x.value.substr(x.selectionStart, x.selectionEnd - x.selectionStart) 614 if(rv!="") 615 { 616 x.value=x.value.substr(0,x.selectionStart) + tag_start + rv + tag_end +x.value.substring(x.selectionEnd,x.value.length) 617 } 618 } 619 } 620 } 621 } 622 623function applicaTagConValore(tag, form, value) 624 { 625 if(tag=='font') 626 { 627 var tag_start='<span style="font-family: '+value+';">'; 628 var tag_end='</span>'; 629 } 630 else if(tag=='size') 631 { 632 var tag_start='<span style="font-size: '+value+'px;">'; 633 var tag_end='</span>'; 634 } 635 636 var text; 637 638 //IE7 IE6 IE5 OPERA 639 if(document.all) 640 { 641 text = (document.all) ? document.selection.createRange().text : document.getSelection(); 642 if (text=="") 643 { 644 return false 645 } 646 else 647 { 648 text=tag_start + text + tag_end 649 if (document.all) 650 document.selection.createRange().text=text 651 return true 652 } 653 } 654 //FIREFOX 655 else if(window.getSelection) 656 { 657 var rv = ""; 658 var i,x; 659 660 if(form) 661 { 662 var modulo=eval('document.'+form); 663 } 664 else 665 { 666 var modulo=eval('document.modulo'); 667 } 668 669 for (i = 0; x = modulo.elements[i]; i++) 670 { 671 if(x.type=='textarea' || x.type=='text') 672 { 673 rv = x.value.substr(x.selectionStart, x.selectionEnd - x.selectionStart) 674 if(rv!="") 675 { 676 x.value=x.value.substr(0,x.selectionStart) + tag_start + rv + tag_end +x.value.substring(x.selectionEnd,x.value.length) 677 } 678 } 679 } 680 } 681 } 682 683 684function array_search(needle, haystack, argStrict) { 685 // discuss at: http://phpjs.org/functions/array_search/ 686 // original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 687 // input by: Brett Zamir (http://brett-zamir.me) 688 // bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 689 // depends on: array 690 // test: skip 691 // example 1: array_search('zonneveld', {firstname: 'kevin', middle: 'van', surname: 'zonneveld'}); 692 // returns 1: 'surname' 693 // example 2: ini_set('phpjs.return_phpjs_arrays', 'on'); 694 // example 2: var ordered_arr = array({3:'value'}, {2:'value'}, {'a':'value'}, {'b':'value'}); 695 // example 2: var key = array_search(/val/g, ordered_arr); // or var key = ordered_arr.search(/val/g); 696 // returns 2: '3'
697 698 var strict = !! argStrict, 699 key = ''; 700 701 if (haystack && typeof haystack === 'object' && haystack.change_key_case) { // Duck-type check for our own array()-created PHPJS_Array 702 return haystack.search(needle, argStrict); 703 } 704 if (typeof needle === 'object' && needle.exec) { // Duck-type for RegExp 705 if (!strict) { // Let's consider case sensitive searches as strict 706 var flags = 'i' + (needle.global ? 'g' : '') + 707 (needle.multiline ? 'm' : '') + 708 (needle.sticky ? 'y' : ''); // sticky is FF only 709 needle = new RegExp(needle.source, flags); 710 } 711 for (key in haystack) { 712 if (needle.test(haystack[key])) { 713 return key; 714 } 715 } 716 return false; 717 } 718 719 for (key in haystack) { 720 if ((strict && haystack[key] === needle) || (!strict && haystack[key] == needle)) { 721 return key; 722 } 723 } 724 725 return false; 726} 727 728function AttivaFrame(iFrameID){ 729 if (document.getElementById(iFrameID).contentDocument){ 730 //Mozilla 731 return document.getElementById(iFrameID).contentDocument; 732 } else { 733 //Internet Explorer 734 return document.frames[iFrameID].document; 735 } 736 } 737 738function converti_ajax(stringa) 739 { 740 var str=String(stringa); 741 742 str=str.replace(/%C2%B4/g,"'"); //converte il segno ô 743 744 return str; 745 } 746 747function count(mixed_var, mode) { 748 // discuss at: http://phpjs.org/functions/count/ 749 // original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 750 // input by: Waldo Malqui Silva 751 // input by: merabi 752 // bugfixed by: Soren Hansen 753 // bugfixed by: Olivier Louvignes (http://mg-crea.com/) 754 // improved by: Brett Zamir (http://brett-zamir.me) 755 // example 1: count([[0,0],[0,-4]], 'COUNT_RECURSIVE'); 756 // returns 1: 6 757 // example 2: count({'one' : [1,2,3,4,5]}, 'COUNT_RECURSIVE'); 758 // returns 2: 6 759 760 var key, cnt = 0; 761 762 if (mixed_var === null || typeof mixed_var === 'undefined') { 763 return 0; 764 } else if (mixed_var.constructor !== Array && mixed_var.constructor !== Object) { 765 return 1; 766 } 767 768 if (mode === 'COUNT_RECURSIVE') { 769 mode = 1; 770 } 771 if (mode != 1) { 772 mode = 0; 773 } 774 775 for (key in mixed_var) { 776 if (mixed_var.hasOwnProperty(key)) { 777 cnt++; 778 if (mode == 1 && mixed_var[key] && (mixed_var[key].constructor === Array || mixed_var[key].constructor === 779 Object)) { 780 cnt += this.count(mixed_var[key], 1); 781 } 782 } 783 } 784 785 return cnt; 786} 787 788function implode(glue, pieces) { 789 // discuss at: http://phpjs.org/functions/implode/ 790 // original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 791 // improved by: Waldo Malqui Silva 792 // improved by: Itsacon (http://www.itsacon.net/) 793 // bugfixed by: Brett Zamir (http://brett-zamir.me) 794 // example 1: implode(' ', ['Kevin', 'van', 'Zonneveld']); 795 // returns 1: 'Kevin van Zonneveld' 796 // example 2: implode(' ', {first:'Kevin', last: 'van Zonneveld'}); 797 // returns 2: 'Kevin van Zonneveld' 798 799 var i = '', 800 retVal = '', 801 tGlue = ''; 802 if (arguments.length === 1) { 803 pieces = glue; 804 glue = ''; 805 } 806 if (typeof pieces === 'object') { 807 if (Object.prototype.toString.call(pieces) === '[object Array]') { 808 return pieces.join(glue); 809 } 810 for (i in pieces) { 811 retVal += tGlue + pieces[i]; 812 tGlue = glue; 813 } 814 return retVal; 815 } 816 return pieces; 817} 818 819//elenco puntato 820function elabora(testo) 821 { 822 var s=new String(testo); 823 s=s.replace("<ul>",""); 824 s=s.replace("</ul>",""); 825 pippo = "<li>"; 826 pluto = ""; 827 while (s.indexOf(pippo)>-1) 828 { 829 PosReplace = s.indexOf(pippo); 830 s = "" + (s.substring(0, PosReplace) + "" + s.substring((PosReplace + pippo.length), s.length)); 831 } 832 pippo = "</li>"; 833 pluto = ""; 834 while (s.indexOf(pippo)>-1) 835 { 836 PosReplace = s.indexOf(pippo); 837 s = "" + (s.substring(0, PosReplace) + "" + s.substring((PosReplace + pippo.length), s.length)); 838 } 839 840 var out = new String; 841 var nomi = new Array(); 842 nomi = s.split("\n"); 843 out += "<ul>"; 844 for (i=0;i<nomi.length;i++) 845 { 846 pippo = "\n"; 847 pluto = ""; 848 while (nomi[i].indexOf(pippo)>-1) 849 { 850 PosReplace = nomi[i].indexOf(pippo); 851 nomi[i] = "" + (nomi[i].substring(0, PosReplace) + "" + nomi[i].substring((PosReplace + pippo.length), nomi[i].length)); 852 } 853 854 out += "<li>" + nomi[i] + "</li>"; 855 } 856 857 out += "</ul>"; 858 return out; 859 } 860 861function end (arr) { 862 // http://kevin.vanzonneveld.net 863 // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 864 // + bugfixed by: Legaev Andrey 865 // + revised by: J A R 866 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 867 // + restored by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 868 // + revised by: Brett Zamir (http://brett-zamir.me) 869 // % note 1: Uses global: php_js to store the array pointer 870 // * example 1: end({0: 'Kevin', 1: 'van', 2: 'Zonneveld'});
871 // * returns 1: 'Zonneveld' 872 // * example 2: end(['Kevin', 'van', 'Zonneveld']); 873 // * returns 2: 'Zonneveld' 874 // BEGIN REDUNDANT 875 this.php_js = this.php_js || {}; 876 this.php_js.pointers = this.php_js.pointers || []; 877 var indexOf = function (value) { 878 for (var i = 0, length = this.length; i < length; i++) { 879 if (this[i] === value) { 880 return i; 881 } 882 } 883 return -1; 884 }; 885 // END REDUNDANT 886 var pointers = this.php_js.pointers; 887 if (!pointers.indexOf) { 888 pointers.indexOf = indexOf; 889 } 890 if (pointers.indexOf(arr) === -1) { 891 pointers.push(arr, 0); 892 } 893 var arrpos = pointers.indexOf(arr); 894 if (Object.prototype.toString.call(arr) !== '[object Array]') { 895 var ct = 0; 896 for (var k in arr) { 897 ct++; 898 var val = arr[k]; 899 } 900 if (ct === 0) { 901 return false; // Empty 902 } 903 pointers[arrpos + 1] = ct - 1; 904 return val; 905 } 906 if (arr.length === 0) { 907 return false; 908 } 909 pointers[arrpos + 1] = arr.length - 1; 910 return arr[pointers[arrpos + 1]]; 911} 912 913function fetchAscii(obj) 914 { 915 var convertedObj = ''; 916 /* commentato da ylenia il 03/09/2025 917 for(i = 0; i < obj.length; i++) 918 { 919 var asciiChar = '&#' + obj.charCodeAt(i) + ';'; 920 convertedObj += asciiChar; 921 } */ 922 923 for (let i = 0; i < obj.length; i++) 924 { 925 let codePoint = obj.codePointAt(i); 926 console.log("New Indice:", i, "CodePoint:", codePoint); 927 928 convertedObj += '&#' + codePoint + ';'; 929 930 // Se è un carattere fuori BMP (richiede 2 code unit), salta la successiva 931 if (codePoint > 0xFFFF) 932 { 933 i++; 934 } 935 } 936 937 938 939 return convertedObj; 940 } 941 942function in_array (needle, haystack, argStrict) { 943 // http://kevin.vanzonneveld.net 944 // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 945 // + improved by: vlado houba 946 // + input by: Billy 947 // + bugfixed by: Brett Zamir (http://brett-zamir.me) 948 // * example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']); 949 // * returns 1: true 950 // * example 2: in_array('vlado', {0: 'Kevin', vlado: 'van', 1: 'Zonneveld'}); 951 // * returns 2: false 952 // * example 3: in_array(1, ['1', '2', '3']); 953 // * returns 3: true 954 // * example 3: in_array(1, ['1', '2', '3'], false); 955 // * returns 3: true 956 // * example 4: in_array(1, ['1', '2', '3'], true); 957 // * returns 4: false 958 var key = '', 959 strict = !! argStrict; 960 961 if (strict) { 962 for (key in haystack) { 963 if (haystack[key] === needle) { 964 return true; 965 } 966 } 967 } else { 968 for (key in haystack) { 969 if (haystack[key] == needle) { 970 return true; 971 } 972 } 973 } 974 975 return false; 976} 977 978function LimitText (campo, contatore, maxchar) 979 { 980 var valore=campo.value; 981 982 var length=strLength(valore); 983 984 if (length > maxchar) 985 { 986 campo.value = valore.substring(0, maxchar); 987 } 988 else 989 { 990 contatore.value = maxchar - length; 991 } 992 } 993 994function load(nomeiframe, nometextarea){ 995 AttivaFrame(nomeiframe).designMode = "On"; 996 997 document.getElementById(nometextarea).style.display = "none"; 998 document.getElementById(nometextarea).style.visibility = "hidden"; 999 1000} 1001 1002function MM_openBrWindow(theURL,winName,features) { //v2.0 1003 window.open(theURL,winName,features); 1004} 1005 1006function mostraDiv(nomediv) { 1007 document.getElementById(nomediv).style.visibility = "visible"; 1008 document.getElementById(nomediv).style.display = "block"; 1009} 1010 1011function mostraElenco(elenco) { 1012 document.getElementById(elenco).style.visibility = "visible"; 1013 document.getElementById(elenco).style.display = "block"; 1014 1015 document.getElementById("chiudi_"+elenco).style.visibility = "visible"; 1016 document.getElementById("chiudi_"+elenco).style.display = "inline"; 1017} 1018 1019function nascondiDiv(nomediv) { 1020 document.getElementById(nomediv).style.visibility = "hidden"; 1021 document.getElementById(nomediv).style.display = "none"; 1022} 1023 1024function nascondiElenco(elenco) { 1025 document.getElementById(elenco).style.visibility = "hidden"; 1026 document.getElementById(elenco).style.display = "none"; 1027 1028 document.getElementById("chiudi_"+elenco).style.visibility = "hidden"; 1029 document.getElementById("chiudi_"+elenco).style.display = "none"; 1030} 1031 1032function parseHtmlEnteties(str) { 1033 return str.replace(/&#([0-9]{1,3});/gi, function(match, numStr) { 1034 var num = parseInt(numStr, 10); // read num as normal number 1035 return String.fromCharCode(num); 1036 });
1037} 1038 1039function pulisciCodice(nomeiframe,nometextarea){ 1040 var contenuto = AttivaFrame(nomeiframe).body.innerHTML; 1041 contenuto = contenuto.replace(/<br\>/gi,"<br>"); 1042 contenuto = contenuto.replace(/(<p\>)(.*)(<\/p\>)/gi,"$2<br><br>"); 1043 contenuto = contenuto.replace(/<\a/gi,"<a"); 1044 contenuto = contenuto.replace(/<\/a\>/gi,"</a>"); 1045 contenuto = contenuto.replace(/<\div\>/gi,""); 1046 contenuto = contenuto.replace(/<\/div\>/gi,"<br><br>"); 1047 //contenuto = contenuto.replace(/(<strong\>)(.*)(<\/strong\>)/gi,"<span style=\"font-weight: bold;\">$2</span>"); 1048 contenuto = contenuto.replace(/(<ul\>)(.*)(<\/ul\>)/gi,"<ul>$2</ul>"); 1049 contenuto = contenuto.replace(/(<li\>)(.*)(<\/li\>)/gi,"<li>$2</li>"); 1050 //internet explorer 1051 contenuto = contenuto.replace(/(<font )(color)(=)(#?([A-Fa-f0-9]){3}(([A-Fa-f0-9]){3})?)(>)(.*)(<\/font\>)/gi,"<span style=\"$2:$4;\">$9</span>"); 1052 contenuto = contenuto.replace(/(<p )(align)(=)([A-Za-z]*)(>)(.*)(<\/p\>)/gi,"$6<br><br>"); 1053 contenuto = contenuto.replace(/(<em\>)(.*)(<\/em\>)/gi,"<span style=\"font-style: italic;\">$2</span>"); 1054 1055 // PULISCE COPIA E INCOLLA DA WORD 1056 1057 contenuto = contenuto.replace(/<\?xml:[^>]*>/g, ''); 1058 contenuto = contenuto.replace(/<\/?st1:[^>]*>/g,''); 1059 contenuto = contenuto.replace(/<\meta[^>]*>/g, ''); 1060 contenuto = contenuto.replace(/<\link[^>]*>/g, ''); 1061 contenuto = contenuto.replace(/<\xml[^>]*>/g, ''); 1062 contenuto = contenuto.replace(/<\w:[^>]*>/g, ''); 1063 contenuto = contenuto.replace(/<\/w:[^>]*>/g, ''); 1064 contenuto = contenuto.replace(/<\m:[^>]*>/g, ''); 1065 contenuto = contenuto.replace(/<\/m:[^>]*>/g, ''); 1066 contenuto = contenuto.replace(/<\style[^>]*>/g, ''); 1067 contenuto = contenuto.replace(/<\/style[^>]*>/g, ''); 1068 contenuto = contenuto.replace(/\style="text-align: [^>]*"/g, ''); 1069 contenuto = contenuto.replace(/<\o:[^>]*>/g, ''); 1070 contenuto = contenuto.replace(/<\/o:[^>]*>/g, ''); 1071 1072 // CORSIVO E GRASSETTO 1073 contenuto = contenuto.replace(/<\I[^>]*>/g, '<span style="font-style: italic;">'); 1074 contenuto = contenuto.replace(/<\/I[^>]*>/g, '</span>'); 1075 contenuto = contenuto.replace(/<\i[^>]*>/g, '<span style="font-style: italic;">'); 1076 contenuto = contenuto.replace(/<\/i[^>]*>/g, '</span>'); 1077 1078 /*contenuto = contenuto.replace(/<\b[^>]*>/g, '<span style="font-weight: bold;">'); 1079 contenuto = contenuto.replace(/<\/b[^>]*>/g, '</span>'); 1080 contenuto = contenuto.replace(/<\B[^>]*>/g, '<span style="font-weight: bold;">'); 1081 contenuto = contenuto.replace(/<\/B[^>]*>/g, '</span>'); 1082 contenuto = contenuto.replace(/<\strong[^>]*>/g, '<span style="font-weight: bold;">'); 1083 contenuto = contenuto.replace(/<\/strong[^>]*>/g, '</span>'); 1084 contenuto = contenuto.replace(/<\STRONG[^>]*>/g, '<span style="font-weight: bold;">'); 1085 contenuto = contenuto.replace(/<\/STRONG[^>]*>/g, '</span>');*/ 1086 1087 1088 //opera 1089 contenuto = contenuto.replace(/(<font )(color)(=\")(#?([A-Fa-f0-9]){3}(([A-Fa-f0-9]){3})?)(\")(>)(.*)(<\/font\>)/gi,"<span style=\"$2:$4;\">$10</span>"); 1090 contenuto = contenuto.replace(/(<div )(align)(=\")([A-Za-z]*)(\")(>)(.*)(<\/div\>)/gi,"$7<br><br>"); 1091 contenuto = contenuto.replace(/(<i\>)(.*)(<\/i\>)/gi,"<span style=\"font-style: italic;\">$2</span>"); 1092 1093 document.getElementById(nometextarea).value = contenuto; 1094 } 1095 1096function riconverti_json(stringa) 1097 { 1098 var str=String(stringa); 1099 1100 str=str.replace(/-puntoevirgola-/g,";"); 1101 //str=str.replace(/\n/g,aCapo); 1102 1103 return str; 1104 } 1105 1106 1107function riconvertiInputTextJQ(stringa) 1108 { 1109 var str=String(stringa); 1110 1111 str=str.replace(/</g,"<"); 1112 str=str.replace(/>/g,"gt;"); 1113 str=str.replace(/\"/g,"""); 1114 str=str.replace(/\'/g,"'"); 1115 str=str.replace(/\â¢/g,"•"); 1116 //str=addslashes(str); 1117 1118 return str; 1119 } 1120 1121function strpos (haystack, needle, offset) { 1122 // http://kevin.vanzonneveld.net 1123 // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 1124 // + improved by: Onno Marsman 1125 // + bugfixed by: Daniel Esteban 1126 // + improved by: Brett Zamir (http://brett-zamir.me) 1127 // * example 1: strpos('Kevin van Zonneveld', 'e', 5); 1128 // * returns 1: 14 1129 var i = (haystack + '').indexOf(needle, (offset || 0)); 1130 return i === -1 ? false : i; 1131} 1132 1133function mb_strtolower (str) { 1134 // http://kevin.vanzonneveld.net 1135 // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 1136 // + improved by: Onno Marsman 1137 // * example 1: mb_strtolower('Kevin van Zonneveld'); 1138 // * returns 1: 'kevin van zonneveld' 1139 return (str + '').toLowerCase(); 1140} 1141 1142function trim (str, charlist) { 1143 // From: http://phpjs.org/functions 1144 // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 1145 // + improved by: mdsjack (http://www.mdsjack.bo.it) 1146 // + improved by: Alexander Ermolaev (http://snippets.dzone.com/user/AlexanderErmolaev) 1147 // + input by: Erkekjetter 1148 // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) 1149 // + input by: DxGx 1150 // + improved by: Steven Levithan (http://blog.stevenlevithan.com) 1151 // + tweaked by: Jack 1152 // + bugfixed by: Onno Marsman 1153 // * example 1: trim(' Kevin van Zonneveld '); 1154 // * returns 1: 'Kevin van Zonneveld' 1155 // * example 2: trim('Hello World', 'Hdle'); 1156 // * returns 2: 'o Wor' 1157 // * example 3: trim(16, 1); 1158 // * returns 3: 6 1159 var whitespace, l = 0, 1160 i = 0; 1161 str += ''; 1162 1163 if (!charlist) { 1164 // default list 1165 whitespace = " \n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000"; 1166 } else { 1167 // preg_quote custom list 1168 charlist += ''; 1169 whitespace = charlist.replace(/([\[\]\(\)\.\?\/\*\{\}\+\$\^\:])/g, '$1'); 1170 } 1171 1172 l = str.length; 1173 for (i = 0; i < l; i++) { 1174 if (whitespace.indexOf(str.charAt(i)) === -1) { 1175 str = str.substring(i); 1176 break; 1177 } 1178 } 1179 1180 l = str.length; 1181 for (i = l - 1; i >= 0; i--) { 1182 if (whitespace.indexOf(str.charAt(i)) === -1) { 1183 str = str.substring(0, i + 1); 1184 break; 1185 } 1186 } 1187 1188 return whitespace.indexOf(str.charAt(0)) === -1 ? str : ''; 1189} 1190 1191 1192function validateEmail(indirizzo_email) { 1193 var indirizzo_emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,6})?$/; 1194 if (!indirizzo_emailReg.test(indirizzo_email) || indirizzo_email=='') { 1195 return false; 1196 } else { 1197 return true; 1198 } 1199} 1200 1201function vediCodice(){
1202 var contenuto = AttivaFrame("editArea").body.innerHTML; 1203 document.getElementById("codice").innerHTML = contenuto.replace(/</g,"<"); 1204 } 1205 1206 1207 1208 function ceil(value) { 1209 // discuss at: http://phpjs.org/functions/ceil/ 1210 // original by: Onno Marsman 1211 // example 1: ceil(8723321.4); 1212 // returns 1: 8723322 1213 1214 return Math.ceil(value); 1215} 1216 1217 1218 1219 1220function SelezionaTutti(conta,form,cosa) 1221 { 1222 1223 for (var idx = 1; idx <=conta; idx++) 1224 { 1225 eval("document."+form+"."+cosa+""+idx+".checked=true"); 1226 } 1227 return true; 1228 } 1229 1230function DeselezionaTutti(conta,form,cosa) { 1231 1232 for (var idx = 1; idx <=conta; idx++) 1233 { 1234 eval("document."+form+"."+cosa+""+idx+".checked=false"); 1235 } 1236 return true; 1237 } 1238 1239 1240 1241 1242var $JQFunzioniPerTutti = jQuery.noConflict(); 1243 1244$JQFunzioniPerTutti(document).ready(function (){ 1245 1246 var cache = []; 1247 $JQFunzioniPerTutti.preLoadImages = function() { 1248 var args_len = arguments.length; 1249 for (var i = args_len; i--;) { 1250 var cacheImage = document.createElement('img'); 1251 cacheImage.src = arguments[i]; 1252 cache.push(cacheImage); 1253 } 1254 } 1255 $JQFunzioniPerTutti.preLoadImages("img/loading.gif"); 1256 1257 1258 1259 $JQFunzioniPerTutti(".viewPassword").unbind('click') 1260 1261 $JQFunzioniPerTutti(".viewPassword").click(function () { 1262 1263 var identificatore=$JQFunzioniPerTutti(this).siblings("input").attr("id"); //siblings= fratello 1264 var form=$JQFunzioniPerTutti(this).closest("form"); 1265 var formId=form.attr("id"); 1266 var formName=form.attr("name"); 1267 1268 console.log("#"+formId+" #"+identificatore+" = "+$JQFunzioniPerTutti("#"+formId+" #"+identificatore).val()) 1269 1270 1271 var input=eval("document."+formName+"."+identificatore); 1272 1273 if ($JQFunzioniPerTutti("#"+formId+" #"+identificatore).attr("type") === "password") 1274 { 1275 console.log('1') 1276 input.setAttribute('type', 'text'); 1277 $JQFunzioniPerTutti(this).html("visibility_off"); 1278 } 1279 else 1280 { 1281 console.log('2') 1282 input.setAttribute('type', 'password'); 1283 $JQFunzioniPerTutti(this).html("visibility"); 1284 } 1285 }); 1286 1287 1288 1289 1290 //tooltip 1291 if($JQFunzioniPerTutti('.tooltipText').length) 1292 { 1293 $JQFunzioniPerTutti('.tooltipText').hide(); 1294 1295 $JQFunzioniPerTutti('.tooltipInfo').mouseover(function(e) { 1296 if($JQFunzioniPerTutti(this).attr("data-cambiaPosizione")!=0) 1297 { 1298 var top = e.pageY; 1299 var left = e.pageX; 1300 1301 var wWidth=$JQFunzioniPerTutti( window ).width(); 1302 1303 if((left+400)>wWidth) 1304 { 1305 left=wWidth-400 1306 } 1307 1308 1309 $JQFunzioniPerTutti(this).next('.tooltipText').css({ 1310 display: 'block', 1311 top: top +10, 1312 left: left-30 1313 }); 1314 } 1315 else 1316 { 1317 $JQFunzioniPerTutti(this).next('.tooltipText').show(); 1318 } 1319 }); 1320 1321 $JQFunzioniPerTutti('.tooltipInfo').mouseout(function(e) { 1322 $JQFunzioniPerTutti('.tooltipText').fadeOut("slow"); 1323 }); 1324 } 1325 1326 1327 1328 if($JQFunzioniPerTutti(".input").length) 1329 { 1330 $JQFunzioniPerTutti("input").bind("focus blur", 1331 {"background-color":"#FFFFCC"}, 1332 function(event) { 1333 if(event.type=="focus") 1334 { 1335 $JQFunzioniPerTutti(this).css(event.data); 1336 } 1337 else 1338 { 1339 $JQFunzioniPerTutti(this).css({"background-color":""}); 1340 } 1341 }); 1342 1343 $JQFunzioniPerTutti("input").bind("focus blur", 1344 {"background-color":"#FFFFCC"}, 1345 function(event) { 1346 if(event.type=="focus") 1347 { 1348 $JQFunzioniPerTutti(this).css(event.data); 1349 } 1350 else 1351 { 1352 $JQFunzioniPerTutti(this).css({"background-color":""}); 1353 } 1354 }); 1355 } 1356 1357 1358 1359 // CERCA 1360 if($JQFunzioniPerTutti(".windows_ModuloCerca").length) 1361 { 1362 if($JQFunzioniPerTutti.isFunction("draggable")) 1363 { 1364 $JQFunzioniPerTutti(".windows_ModuloCerca").draggable(); 1365 } 1366 1367 $JQFunzioniPerTutti("#cerca").click(function (e) 1368 { 1369 ShowModuloCerca(); 1370 }); 1371 1372 1373 $JQFunzioniPerTutti("#FinestraChiudiModuloCerca").click(function (e) 1374 { 1375 HideModuloCerca(); 1376 }); 1377 1378 1379 $JQFunzioniPerTutti("#ModuloCercaForm").submit(function () 1380 { 1381 $JQFunzioniPerTutti("#load_ModuloCercaForm").html('<img src="/img/loading.gif" alt="loading...">'); 1382 }); 1383 } 1384 1385 1386 inizializzaFunzioniPerTutti(); 1387}); 1388 1389 1390function inizializzaFunzioniPerTutti() 1391 { 1392 if($JQFunzioniPerTutti( ".formato_data" ).length>0) 1393 { 1394 $JQFunzioniPerTutti( ".formato_data" ).datepicker({ 1395 showButtonPanel: true, 1396 changeMonth: true, 1397 changeYear: true 1398 }); 1399 } 1400 1401 if($JQFunzioniPerTutti( ".formato_ora" ).length>0) 1402 { 1403 $JQFunzioniPerTutti('.formato_ora').timepicker({ 1404 showPeriodLabels: false, 1405 showNowButton: true, 1406 showDeselectButton: true, 1407 showCloseButton: true 1408 }); 1409 } 1410 1411 $JQFunzioniPerTutti("[data-minconsiglio], [data-maxconsiglio]").unbind("
1411keyup change focus"); 1412 1413 $JQFunzioniPerTutti("[data-minconsiglio], [data-maxconsiglio]").bind("keyup change focus",function (e) { 1414 1415 var idcampo=$JQFunzioniPerTutti(this).attr("id"); 1416 var idform = $JQFunzioniPerTutti(this).closest('form').attr("id"); 1417 1418 AvvisoPollice(idform, idcampo); 1419 }); 1420 1421 1422 1423 1424 1425 1426 $JQFunzioniPerTutti('.formato_url').bind("paste",function(e) { 1427 1428 var id=$JQFunzioniPerTutti(this).attr("id"); 1429 1430 var url=e.originalEvent.clipboardData.getData('text'); 1431 var array_url=url.split('://'); 1432 1433 setTimeout(function(){ // questo serve altrimenti mette il testo doppio 1434 1435 if($JQFunzioniPerTutti("#"+id+"_prefisso option[value='"+array_url[0]+"://']").length>0) 1436 { 1437 $JQFunzioniPerTutti("#"+id+"_prefisso option[value='"+array_url[0]+"://']").attr('selected','selected'); 1438 1439 var newurl=url.replace(array_url[0]+"://","") 1440 1441 $JQFunzioniPerTutti("#"+id).val(newurl); 1442 } 1443 },0); 1444 }); 1445 } 1446 1447 1448function AvvisoPollice(idform, idcampo) 1449 { 1450 //console.log(idform+' '+idcampo); 1451 1452 var minCharConsiglio=$JQFunzioniPerTutti("#"+idform+" #"+idcampo).attr("data-minconsiglio"); 1453 var maxCharConsiglio=$JQFunzioniPerTutti("#"+idform+" #"+idcampo).attr("data-maxconsiglio"); 1454 1455 if(minCharConsiglio!='' && maxCharConsiglio!='') 1456 { 1457 var valore=$JQFunzioniPerTutti("#"+idform+" #"+idcampo).val(); 1458 //console.log(valore); 1459 1460 var iconaPollice='thumb_up'; 1461 var colorePollice='#43A047'; 1462 var titlePollice='Il valore rispetta i consigli per i motori di ricerca'; 1463 1464 if(valore.length<minCharConsiglio || valore.length>maxCharConsiglio) 1465 { 1466 iconaPollice='thumb_down'; 1467 colorePollice='#D50000'; 1468 titlePollice='Il valore rispetta i consigli per i motori di ricerca'; 1469 } 1470 1471 var esistePollice=$JQFunzioniPerTutti("#"+idform+" #pollice_"+idcampo).length; 1472 1473 var idPollice="#"+idform+" #pollice_"+idcampo; 1474 if(esistePollice==0) 1475 { 1476 idPollice="#pollice_"+idcampo; 1477 } 1478 1479 //console.log(esistePollice+' '+idPollice); 1480 1481 $JQFunzioniPerTutti(idPollice).html(iconaPollice); 1482 $JQFunzioniPerTutti(idPollice).css({"color":colorePollice}); 1483 $JQFunzioniPerTutti(idPollice).attr("title", titlePollice); 1484 1485 } 1486 } 1487 1488 1489 1490 1491// CERCA 1492function ShowModuloCerca(modal) 1493 { 1494 $JQFunzioniPerTutti(".windows_ModuloCerca_sfondo").show(); 1495 $JQFunzioniPerTutti(".windows_ModuloCerca").fadeIn(300); 1496 1497 $JQFunzioniPerTutti(".windows_ModuloCerca_sfondo").click(function (e) 1498 { 1499 HideModuloCerca(); 1500 }); 1501 } 1502 1503function HideModuloCerca() 1504 { 1505 $JQFunzioniPerTutti(".windows_ModuloCerca_sfondo").hide(); 1506 $JQFunzioniPerTutti(".windows_ModuloCerca").fadeOut(300); 1507 } 1508 1509function HideWindowConfirmPws() 1510 { 1511 $JQFunzioniPerTutti("#windows_confirmpws").fadeOut(300); 1512 } 1513 1514function HideWindowElimina(classSearch='') 1515 { 1516 $JQFunzioniPerTutti("#windows_confirm_delete"+classSearch).fadeOut(300); 1517 } 1518 1519 1520 1521 1522// WINDOWS 1523function ShowWindow(finestra) 1524 { 1525 $JQFunzioniPerTutti(finestra+"_sfondo").show(); 1526 $JQFunzioniPerTutti(finestra).fadeIn(300); 1527 1528 $JQFunzioniPerTutti(finestra+"_sfondo").click(function (e) 1529 { 1530 HideWindow(finestra); 1531 }); 1532 } 1533 1534function HideWindow(finestra) 1535 { 1536 $JQFunzioniPerTutti(finestra+"_sfondo").hide(); 1537 $JQFunzioniPerTutti(finestra).fadeOut(300); 1538 } 1539// 1540 1541function switchMode(mode) 1542 { 1543 document.querySelectorAll('.mode-switch button').forEach(btn => btn.classList.remove('active')); 1544 1545 document.getElementById('btn' + mode.charAt(0).toUpperCase() + mode.slice(1)).classList.add('active'); 1546 } 1547 1548function LimitInsertChar (idform, idcampo, idcontatore, maxchar) 1549 { 1550 var valore=$JQFunzioniPerTutti("#"+idform+" #"+idcampo).val(); 1551 1552 var length=strLength(valore); 1553 1554 if (length > maxchar) 1555 { 1556 $JQFunzioniPerTutti("#"+idform+" #"+idcampo).val(valore.substring(0, maxchar)); 1557 } 1558 1559 $JQFunzioniPerTutti("#"+idform+" #"+idcontatore).html(maxchar-length); 1560 } 1561 1562 1563function CountInsertChar (idform, idcampo, idcontatore) 1564 { 1565 var valore=$JQFunzioniPerTutti("#"+idform+" #"+idcampo).val(); 1566
1567 var length=strLength(valore); 1568 $JQFunzioniPerTutti("#"+idform+" #"+idcontatore).html(length); 1569 } 1570 1571function strLength (text) 1572 { 1573 var textLength = text.length; 1574 var textNewline = (text.match(/\n/g) || []).length; 1575 1576 var length=parseInt(textLength)+parseInt(textNewline); 1577 1578 return length; 1579 } 1580 1581 1582 1583 1584function SelezionaTuttiRadio(conta,form,cosa,valore,conta2) 1585 { 1586 if(conta2=='' || conta2==0) 1587 { 1588 for (var idx = 0; idx <conta; idx++) 1589 { 1590 $JQFunzioniPerTutti("#"+form+" input:radio[id='"+cosa+idx+valore+"']").attr('checked','checked'); 1591 } 1592 } 1593 else 1594 { 1595 for (var idx = 0; idx <conta; idx++) 1596 { 1597 for (var idx2 = 0; idx2 <conta2; idx2++) 1598 { 1599 $JQFunzioniPerTutti("#"+form+" input:radio[id='"+cosa+idx+'_'+idx2+valore+"']").attr('checked','checked'); 1600 } 1601 } 1602 } 1603 return true; 1604 } 1605 1606function DeselezionaTuttiRadio(conta,form,cosa,valore,conta2) 1607 { 1608 if(conta2=='' || conta2==0) 1609 { 1610 for (var idx = 0; idx <conta; idx++) 1611 { 1612 $JQFunzioniPerTutti("#"+form+" input:radio[id='"+cosa+idx+valore+"']").attr('checked',false); 1613 } 1614 } 1615 else 1616 { 1617 for (var idx = 0; idx <conta; idx++) 1618 { 1619 for (var idx2 = 0; idx2 <conta2; idx2++)
1620 { 1621 $JQFunzioniPerTutti("#"+form+" input:radio[id='"+cosa+idx+'_'+idx2+valore+"']").attr('checked',false); 1622 } 1623 } 1624 } 1625 return true; 1626 } 1627 1628 1629function number_format (number, decimals, decPoint, thousandsSep) 1630 { 1631 number = (number + '').replace(/[^0-9+\-Ee.]/g, ''); 1632 var n = !isFinite(+number) ? 0 : +number; 1633 var prec = !isFinite(+decimals) ? 0 : Math.abs(decimals); 1634 var sep = (typeof thousandsSep === 'undefined') ? ',' : thousandsSep; 1635 var dec = (typeof decPoint === 'undefined') ? '.' : decPoint; 1636 var s = ''; 1637 var toFixedFix = function (n, prec) 1638 { 1639 var k = Math.pow(10, prec); 1640 return '' + (Math.round(n * k) / k).toFixed(prec); 1641 } 1642 // @todo: for IE parseFloat(0.55).toFixed(0) = 0; 1643 s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.'); 1644 1645 if (s[0].length > 3) 1646 { 1647 s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep); 1648 } 1649 1650 if ((s[1] || '').length < prec) 1651 { 1652 s[1] = s[1] || ''; 1653 s[1] += new Array(prec - s[1].length + 1).join('0'); 1654 } 1655 return s.join(dec); 1656 } 1657
1658 1659 /** 1660 * PHP-like print_r() equivalent for JavaScript Object 1661 * 1662 * @author Faisalman [email protected] 1663 * @license http://www.opensource.org/licenses/mit-license.php 1664 * @link http://gist.github.com/879208 1665 */ 1666var print_r = function (obj, t) { 1667 1668 // define tab spacing 1669 var tab = t || ''; 1670 1671 // check if it's array 1672 var isArr = Object.prototype.toString.call(obj) === '[object Array]'; 1673 1674 // use {} for object, [] for array 1675 var str = isArr ? ('Array\n' + tab + '[\n') : ('Object\n' + tab + '{\n'); 1676 1677 // walk through it's properties 1678 for (var prop in obj) { 1679 if (obj.hasOwnProperty(prop)) { 1680 var val1 = obj[prop]; 1681 var val2 = ''; 1682 var type = Object.prototype.toString.call(val1); 1683 switch (type) { 1684 1685 // recursive if object/array 1686 case '[object Array]': 1687 case '[object Object]': 1688 val2 = print_r(val1, (tab + '\t')); 1689 break; 1690 1691 case '[object String]': 1692 val2 = '\'' + val1 + '\''; 1693 break; 1694 1695 default: 1696 val2 = val1; 1697 } 1698 str += tab + '\t' + prop + ' => ' + val2 + ',\n'; 1699 } 1700 } 1701 1702 // remove extra comma for last property 1703 str = str.substring(0, str.length - 2) + '\n' + tab; 1704 1705 return isArr ? (str + ']') : (str + '}'); 1706}; 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717//funzione generica da mettere su tutti piano piano 1718function checkPerTutti(modulo) 1719 { 1720 var errori=0; 1721 var identificatore=''; 1722 1723 //obbligatorieta 1724 $JQFunzioniPerTutti(modulo+" .campo_obbligatorio").each(function() { 1725 1726 if($JQFunzioniPerTutti(this).is(':disabled')==false) 1727 { 1728 if(strpos ($JQFunzioniPerTutti(this).attr("class"), 'formato_file', 0)===false && strpos ($JQFunzioniPerTutti(this).attr("class"), 'formato_filefoto', 0)===false) //solo per la modifica perché in modifica se un campo file è obbligatorio in realtà dovrebbe esere gia presente, altrimenti anche se nel db c'è già , fa comq il controllo e non mi fa salvare 1729 { 1730 var valore=$JQFunzioniPerTutti.trim($JQFunzioniPerTutti(this).val()); 1731 var identificatore=$JQFunzioniPerTutti(this).attr("id"); 1732 1733 //se il campo obbligatorio è di tipo radio devo controllare le specifiche 1734 if(strpos ($JQFunzioniPerTutti(this).attr("class"), 'formato_radio', 0)!==false) 1735 { 1736 var trovato=0; 1737 $JQFunzioniPerTutti(modulo+" input[name='"+identificatore+"']").each(function() 1738 { 1739 if($JQFunzioniPerTutti(this).attr('checked')) 1740 { 1741 trovato++; 1742 } 1743 }); 1744 1745 if(trovato==0) 1746 { 1747 errori++; 1748 1749 $JQFunzioniPerTutti(modulo+" #label"+identificatore).addClass("txt-errore"); 1750 } 1751 else 1752 { 1753 $JQFunzioniPerTutti(modulo+" #label"+identificatore).removeClass("txt-errore"); 1754 } 1755 } 1756 else if(strpos ($JQFunzioniPerTutti(this).attr("class"), 'formato_checkbox', 0)!==false) 1757 { 1758 var trovato=0; 1759 var arraySplit=identificatore.split('__'); 1760 $JQFunzioniPerTutti(modulo+" input[name^='"+arraySplit[0]+"']").each(function() 1761 { 1762 if($JQFunzioniPerTutti(this).attr('checked')) 1763 { 1764 trovato++; 1765 } 1766 }); 1767 1768 if(trovato==0) 1769 { 1770 errori++; 1771 1772 $JQFunzioniPerTutti(modulo+" #label"+arraySplit[0]).addClass("txt-errore"); 1773 } 1774 else 1775 { 1776 $JQFunzioniPerTutti(modulo+" #label"+arraySplit[0]).removeClass("txt-errore"); 1777 } 1778 } 1779 else 1780 { 1781 if(valore=='') 1782 { 1783 errori++; 1784 1785 $JQFunzioniPerTutti(this).addClass("field-errore"); 1786 1787 if($JQFunzioniPerTutti(modulo+" #label"+identificatore).length) 1788 { 1789 $JQFunzioniPerTutti(modulo+" #label"+identificatore).addClass("txt-errore"); 1790 } 1791 1792 if($JQFunzioniPerTutti(modulo+" #textEditor"+identificatore).length) 1793 { 1794 $JQFunzioniPerTutti(modulo+" #textEditor"+identificatore).addClass("field-errore"); 1795 } 1796 } 1797 else 1798 { 1799 $JQFunzioniPerTutti(this).removeClass("field-errore"); 1800 1801 if($JQFunzioniPerTutti(modulo+" #label"+identificatore).length) 1802 { 1803 $JQFunzioniPerTutti(modulo+" #label"+identificatore).removeClass("txt-errore"); 1804 } 1805 1806 if($JQFunzioniPerTutti(modulo+" #textEditor"+identificatore).length) 1807 { 1808 $JQFunzioniPerTutti(modulo+" #textEditor"+identificatore).removeClass("field-errore"); 1809 } 1810 } 1811 } 1812 } 1813 } 1814 }); 1815 1816 1817 1818 1819 //filefoto 1820 $JQFunzioniPerTutti(modulo+' .formato_filefoto').each(function() { 1821 1822 if($JQFunzioniPerTutti(this).is(':disabled')==false) 1823 { 1824 var valore=$JQFunzioniPerTutti.trim($JQFunzioniPerTutti(this).val()); 1825 1826 if(valore!='') 1827 { 1828 var identificatore=$JQFunzioniPerTutti(this).attr("id"); 1829 1830 var arrayValore=valore.split("."); 1831 1832 var ext=end(arrayValore); 1833 ext=mb_strtolower(ext); 1834 1835 if(!in_array(ext, array_ext_foto2)) 1836 { 1837 errori++; 1838 1839 $JQFunzioniPerTutti(this).addClass("field-errore"); 1840 $JQFunzioniPerTutti(modulo+" #label"+identificatore).addClass("txt-errore"); 1841 } 1842 else 1843 { 1844 $JQFunzioniPerTutti(this).removeClass("field-errore"); 1845 $JQFunzioniPerTutti(modulo+" #label"+identificatore).removeClass("txt-errore"); 1846 } 1847 } 1848 } 1849 }); 1850 1851 //time 1852 $JQFunzioniPerTutti('.formato_ora, .formato_oranotimepicker').each(function() { 1853 1854 if($JQFunzioniPerTutti(this).is(':disabled')==false) 1855 { 1856 var valore=$JQFunzioniPerTutti.trim($JQFunzioniPerTutti(this).val()); 1857 1858 if(valore!='') 1859 { 1860 var identificatore=$JQFunzioniPerTutti(this).attr("id"); 1861 1862 var dtRegex = new RegExp(/^(([0-1]?[0-9])|([2][0-3])):([0-5]?[0-9])?$/i); 1863 1864 if(!dtRegex.test(valore)) 1865 { 1866 errori++; 1867 1868 $JQFunzioniPerTutti(this).addClass("field-errore"); 1869 if($JQFunzioniPerTutti(modulo+" #label"+identificatore).length) 1870 { 1871 $JQFunzioniPerTutti("#label"+identificatore).addClass("txt-errore"); 1872 } 1873 } 1874 else 1875 { 1876 $JQFunzioniPerTutti(this).removeClass("field-errore"); 1877 if($JQFunzioniPerTutti(modulo+" #label"+identificatore).length) 1878 { 1879 $JQFunzioniPerTutti("#label"+identificatore).removeClass("txt-errore"); 1880 } 1881 } 1882 } 1883 else if(!$JQFunzioniPerTutti(this).hasClass("campo_obbligatorio")) 1884 { 1885 $JQFunzioniPerTutti(this).removeClass("field-errore"); 1886 1887 if($JQFunzioniPerTutti(modulo+" #label"+identificatore).length) 1888 { 1889 $JQFunzioniPerTutti("#label"+identificatore).removeClass("txt-errore"); 1890 } 1891 } 1892 } 1893 }); 1894 1895 //data 1896 $JQFunzioniPerTutti(modulo+" .formato_data").each(function() { 1897 1898 if($JQFunzioniPerTutti(this).is(':disabled')==false) 1899 { 1900 var valore=$JQFunzioniPerTutti.trim($JQFunzioniPerTutti(this).val()); 1901 1902 if(valore!='') 1903 { 1904 var identificatore=$JQFunzioniPerTutti(this).attr("id"); 1905 1906 var dtRegex = new RegExp(/\b\d{1,2}[\/]\d{1,2}[\/]\d{4}\b/); 1907 1908 if(!dtRegex.test(valore)) 1909 { 1910 errori++; 1911 1912 $JQFunzioniPerTutti(this).addClass("field-errore"); 1913 if($JQFunzioniPerTutti(modulo+" #label"+identificatore).length) 1914 { 1915 $JQFunzioniPerTutti(modulo+" #label"+identificatore).addClass("txt-errore"); 1916 } 1917 } 1918 else 1919 { 1920 $JQFunzioniPerTutti(this).removeClass("field-errore"); 1921 if($JQFunzioniPerTutti(modulo+" #label"+identificatore).length) 1922 { 1923 $JQFunzioniPerTutti(modulo+" #label"+identificatore).removeClass("txt-errore"); 1924 } 1925 } 1926 } 1927 else if(!$JQFunzioniPerTutti(this).hasClass("campo_obbligatorio")) 1928 { 1929 $JQFunzioniPerTutti(this).removeClass("field-errore"); 1930 1931 if($JQFunzioniPerTutti(modulo+" #label"+identificatore).length) 1932 { 1933 $JQFunzioniPerTutti("#label"+identificatore).removeClass("txt-errore"); 1934 } 1935 } 1936 } 1937 }); 1938 1939 1940 //numdec numero positivo con punto come separatore decimale 1941 // formato_numdec2 significa numero positivo con 2 decimali 1942 // formato_numdec3 significa numero positivo con 3 decimali 1943 // formato_numdec6 significa numero positivo con 6 decimali 1944 $JQFunzioniPerTutti(modulo+' input[class*="formato_numdec"]').each(function() { 1945 1946 if($JQFunzioniPerTutti(this).is(':disabled')==false) 1947 { 1948 var identificatore=$JQFunzioniPerTutti(this).attr("id"); 1949 1950 var id2Tmp=$JQFunzioniPerTutti(this).attr("class").split('formato_numdec'); 1951 var id2=id2Tmp[1].split(' '); 1952 var nDec=id2[0]; //numero decimali 1953 1954 var valore=$JQFunzioniPerTutti.trim($JQFunzioniPerTutti(this).val()); 1955 1956 if(valore!='') 1957 { 1958 var expreg=eval('/^[0-9]+\\.?[0-9]{0,'+nDec+'}$/g'); 1959 var dtRegex = new RegExp(expreg); 1960 1961 if(!dtRegex.test(valore)) 1962 { 1963 errori++; 1964 1965 $JQFunzioniPerTutti(this).addClass("field-errore"); 1966 $JQFunzioniPerTutti(modulo+" #label"+identificatore).addClass("txt-errore"); 1967 } 1968 else 1969 { 1970 $JQFunzioniPerTutti(this).removeClass("field-errore"); 1971 $JQFunzioniPerTutti(modulo+" #label"+identificatore).removeClass("txt-errore"); 1972 } 1973 } 1974 else if(!$JQFunzioniPerTutti(this).hasClass("campo_obbligatorio")) 1975 { 1976 $JQFunzioniPerTutti(this).removeClass("field-errore"); 1977 1978 if($JQFunzioniPerTutti(modulo+" #label"+identificatore).length) 1979 { 1980 $JQFunzioniPerTutti("#label"+identificatore).removeClass("txt-errore"); 1981 } 1982 } 1983 } 1984 }); 1985 1986 //negposnumdec numero negativo o positivo con punto come separatore decimale 1987 // formato_negposnumdec2 significa numero negativo con 2 decimali 1988 // formato_negposnumdec3 significa numero negativo con 3 decimali 1989 // formato_negposnumdec6 significa numero negativo con 6 decimali 1990 $JQFunzioniPerTutti(modulo+' input[class*="formato_negposnumdec"]').each(function() { 1991 1992 if($JQFunzioniPerTutti(this).is(':disabled')==false) 1993 { 1994 var identificatore=$JQFunzioniPerTutti(this).attr("id"); 1995 1996 var id2Tmp=$JQFunzioniPerTutti(this).attr("class").split('formato_negposnumdec'); 1997 var id2=id2Tmp[1].split(' '); 1998 var nDec=id2[0]; //numero decimali 1999 2000 var valore=$JQFunzioniPerTutti.trim($JQFunzioniPerTutti(this).val()); 2001 2002 if(valore!='') 2003 { 2004 var expreg=eval('/^(-){0,1}[0-9]+\\.?[0-9]{0,'+nDec+'}$/g'); 2005 var dtRegex = new RegExp(expreg); 2006 2007 if(!dtRegex.test(valore)) 2008 { 2009 errori++; 2010 2011 $JQFunzioniPerTutti(this).addClass("field-errore"); 2012 $JQFunzioniPerTutti(modulo+" #label"+identificatore).addClass("txt-errore"); 2013 } 2014 else 2015 { 2016 $JQFunzioniPerTutti(this).removeClass("field-errore"); 2017 $JQFunzioniPerTutti(modulo+" #label"+identificatore).removeClass("txt-errore"); 2018 } 2019 } 2020 } 2021 }); 2022 2023 2024 2025 2026 //int 2027 $JQFunzioniPerTutti(modulo+" .formato_int").each(function() { 2028 2029 if($JQFunzioniPerTutti(this).is(':disabled')==false) 2030 { 2031 var valore=$JQFunzioniPerTutti.trim($JQFunzioniPerTutti(this).val()); 2032 2033 if(valore!='') 2034 { 2035 var identificatore=$JQFunzioniPerTutti(this).attr("id"); 2036 2037 var dtRegex = new RegExp(/^\d+$/); 2038 2039 if(!dtRegex.test(valore)) 2040 { 2041 errori++; 2042 2043 $JQFunzioniPerTutti(this).addClass("field-errore"); 2044 $JQFunzioniPerTutti(modulo+" #label"+identificatore).addClass("txt-errore"); 2045 } 2046 else 2047 { 2048 $JQFunzioniPerTutti(this).removeClass("field-errore"); 2049 $JQFunzioniPerTutti(modulo+" #label"+identificatore).removeClass("txt-errore"); 2050 } 2051 } 2052 } 2053 }); 2054 2055 2056 2057 2058 2059 2060 if(errori==0) 2061 { 2062 if($JQFunzioniPerTutti(modulo+" input:submit").length) 2063 { 2064 $JQFunzioniPerTutti(modulo+" input:submit").removeAttr('disabled'); 2065 } 2066 if($JQFunzioniPerTutti(modulo+" input[type='image']").length) 2067 { 2068 $JQFunzioniPerTutti(modulo+" input[type='image']").removeAttr('disabled'); 2069 } 2070 2071 if($JQFunzioniPerTutti(modulo+" #checkClient").length) 2072 { 2073 $JQFunzioniPerTutti(modulo+" #checkClient").html(''); 2074 } 2075 } 2076 else 2077 { 2078 if($JQFunzioniPerTutti(modulo+" input:submit").length) 2079 { 2080 $JQFunzioniPerTutti(modulo+" input:submit").attr('disabled', 'disabled'); 2081 } 2082 if($JQFunzioniPerTutti(modulo+" input[type='image']").length) 2083 { 2084 $JQFunzioniPerTutti(modulo+" input[type='image']").attr('disabled', 'disabled'); 2085 } 2086 2087 if($JQFunzioniPerTutti(modulo+" #checkClient").length) 2088 { 2089 $JQFunzioniPerTutti(modulo+" #checkClient").html('Attenzione, non tutti i campi obbligatori sono stati compilati o non sono stati compilati correttamente'); 2090 } 2091 } 2092 } 2093 2094 2095function getViewportOffset($e) { 2096 var $window = $JQFunzioniPerTutti(window), scrollLeft = $window.scrollLeft(), scrollTop = $window.scrollTop(), offset = $e.offset(), rect1 = { 2097 x1 : scrollLeft, 2098 y1 : scrollTop, 2099 x2 : scrollLeft + $window.width(), 2100 y2 : scrollTop + $window.height() 2101 }, rect2 = { 2102 x1 : offset.left, 2103 y1 : offset.top, 2104 x2 : offset.left + $e.width(), 2105 y2 : offset.top + $e.height() 2106 }; 2107 return { 2108 left : offset.left - scrollLeft, 2109 top : offset.top - scrollTop, 2110 insideViewport : rect1.x1 < rect2.x2 && rect1.x2 > rect2.x1 && rect1.y1 < rect2.y2 && rect1.y2 > rect2.y1 2111 }; 2112} 2113 2114 2115 2116function getScrollBarWidth() 2117 { 2118 $JQFunzioniPerTutti('body').append('<div id="fakescrollbar" style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"></div>'); 2119 fakeScrollBar = $JQFunzioniPerTutti('#fakescrollbar'); 2120 fakeScrollBar.append('<div style="height:100px;"> </div>'); 2121 var w1 = fakeScrollBar.find('div').innerWidth(); 2122 fakeScrollBar.css('overflow-y', 'scroll'); 2123 var w2 = $JQFunzioniPerTutti('#fakescrollbar').find('div').html('html is required to init new width.').innerWidth(); 2124 fakeScrollBar.remove(); 2125 2126 return (w1-w2); 2127 } 2128 2129function SelectText(element) { 2130 var doc = document 2131 , text = doc.getElementById(element) 2132 , range, selection 2133 ; 2134 if (doc.body.createTextRange) { 2135 range = document.body.createTextRange(); 2136 range.moveToElementText(text); 2137 range.select(); 2138 } else if (window.getSelection) { 2139 selection = window.getSelection(); 2140 range = document.createRange(); 2141 range.selectNodeContents(text); 2142 selection.removeAllRanges(); 2143 selection.addRange(range); 2144 } 2145} 2146 2147 2148function strip_tags (input, allowed) { 2149 allowed = (((allowed || "") + "").toLowerCase().match(/<[a-z][a-z0-9]*>/g) || []).join(''); // making sure the allowed arg is a string containing only tags in lowercase (<a><b><c>) 2150 var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi, 2151 commentsAndPhpTags = /<!--[\s\S]
2151*?-->|<\?(?:php)?[\s\S]*?\?>/gi; 2152 return input.replace(commentsAndPhpTags, '').replace(tags, function ($0, $1) { 2153 return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : ''; 2154 }); 2155} 2156 2157 2158 2159$JQFunzioniPerTutti.fn.isInViewport = function () { 2160 let elementTop = $JQFunzioniPerTutti(this).offset().top; 2161 let elementBottom = elementTop + $JQFunzioniPerTutti(this).outerHeight(); 2162 2163 let viewportTop = $JQFunzioniPerTutti(window).scrollTop(); 2164 let viewportBottom = viewportTop + $JQFunzioniPerTutti(window).height(); 2165 2166 return elementBottom > viewportTop && elementTop < viewportBottom; 2167}; 2168 2169 2170 2171function getTransitionDuration( element, with_delay ) 2172{ 2173 var el = $JQFunzioniPerTutti( element ); 2174 var prefixes = 'moz webkit ms o khtml'.split( ' ' ); 2175 var result = 0; 2176 2177 for ( var i = 0; i < prefixes.length; i++ ) 2178 { 2179 var duration = el.css( '-' + prefixes[i] + '-transition-duration' ); 2180 2181 if ( duration ) 2182 { 2183 duration = ( duration.indexOf( 'ms' ) >- 1 ) ? parseFloat( duration ) : parseFloat( duration ) * 1000; 2184 2185 if ( with_delay ) 2186 { 2187 var delay = el.css( '-' + prefixes[i] + '-transition-delay' ); 2188 duration += ( delay.indexOf( 'ms' ) >- 1 ) ? parseFloat( delay ) : parseFloat( delay ) * 1000; 2189 } 2190 2191 result = duration; 2192 2193 break; 2194 } 2195 } 2196 2197 return result; 2198} 2199 2200 2201//controlla se un device è touch 2202function is_touch_device() 2203 { 2204 try 2205 { 2206 document.createEvent("TouchEvent"); 2207 return true; 2208 } 2209 catch (e) 2210 { 2211 return false; 2212 } 2213 } 2214 2215 2216function AllargaStringi(cosa) 2217 { 2218 if($JQFunzioniPerTutti("."+cosa).css('display')!='none') 2219 { 2220 $JQFunzioniPerTutti("."+cosa).hide(); 2221 2222 $JQFunzioniPerTutti("#link"+cosa).attr('title','mostra specifiche'); 2223 $JQFunzioniPerTutti("#link"+cosa).html('<img src="/gestione/img/icona_piu.png" alt="icona mosra specifiche" style="margin-top: -3px;">'); 2224 } 2225 else 2226 { 2227 $JQFunzioniPerTutti("."+cosa).show(); 2228 2229 $JQFunzioniPerTutti("#link"+cosa).attr('title','nascondi specifiche'); 2230 $JQFunzioniPerTutti("#link"+cosa).html('<img src="/gestione/img/icona_meno.png" alt="icona narcondi specifiche" style="margin-top: -3px;">'); 2231 } 2232 } 2233 2234function preg_match (regex, str) 2235 { 2236 if (new RegExp(regex).test(str)) 2237 { 2238 return regex.exec(str); 2239 } 2240 2241 return false; 2242 } 2243 2244 2245function getCookie(name) { 2246 // Split cookie string and get all individual name=value pairs in an array 2247 var cookieArr = document.cookie.split(";"); 2248 2249 // Loop through the array elements 2250 for(var i = 0; i < cookieArr.length; i++) { 2251 var cookiePair = cookieArr[i].split("="); 2252 2253 /* Removing whitespace at the beginning of the cookie name 2254 and compare it with the given string */ 2255 if(name == cookiePair[0].trim()) { 2256 // Decode the cookie value and return 2257 return decodeURIComponent(cookiePair[1]); 2258 } 2259 } 2260 2261 // Return null if not found 2262 return null; 2263} 2264 2265function coloreTestoIdeale(coloreHex) { 2266 // Rimuove il simbolo # se presente 2267 coloreHex = coloreHex.replace('#', ''); 2268 2269 // Converte in numeri decimali R, G, B 2270 var r = parseInt(coloreHex.substring(0, 2), 16); 2271 var g = parseInt(coloreHex.substring(2, 4), 16); 2272 var b = parseInt(coloreHex.substring(4, 6), 16); 2273 2274 // Calcola la luminanza percepita (formula di YIQ) 2275 var luminanza = (r * 299 + g * 587 + b * 114) / 1000; 2276 2277 // Se luminanza alta, meglio nero; se bassa, meglio bianco 2278 return luminanza >= 128 ? 'black' : 'white'; 2279} 2280 2281 2282 2283//esempio di utilizzo: 2284// aspettaElementoETrigger("#ID_SELETTORE"); 2285// aspettaElementoETrigger(".CLASS_ESELETTORE", "TRIGGER"); 2286// aspettaElementoETrigger("[data-box='VALORE']", "TRIGGER"); 2287// TRIGGER: click, focus, change, ecc 2288function aspettaElementoETrigger(selettore, evento = "click", tentativi = 20, intervallo = 100) 2289 { 2290 const el = $JQFunzioniPerTutti(selettore); 2291 2292 // Caso evento vuoto: restituisci true se esiste, false altrimenti 2293 if (evento === "") 2294 { 2295 if (el.length > 0) return true; 2296 if (tentativi > 0) 2297 { 2298 setTimeout(() => aspettaElementoETrigger(selettore, "", tentativi - 1, intervallo), intervallo); 2299 } 2300 else 2301 { 2302 console.warn("Elemento non trovato:", selettore); 2303 return false; 2304 } 2305 return; // esce dalla funzione 2306 } 2307 2308 // Caso normale con trigger 2309 if (el.length > 0) 2310 { 2311 el.trigger(evento); 2312 } 2313 else if (tentativi > 0) 2314 { 2315 setTimeout(() => aspettaElementoETrigger(selettore, evento, tentativi - 1, intervallo), intervallo); 2316 } 2317 else 2318 { 2319 console.warn("Elemento non trovato per il trigger:", selettore); 2320 } 2321 }
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.