// Creazione di Ivo Sansovini - Governo del Territorio - Comune di Rimini (v. 27-09-2022) // // FUNZIONE DI CARICAMENTO SCRIPT E LANCIO DELLA FUNZION: // CaricamentoScript_FunzioniDiFineLoad() ; e ElencoFunzioni_FineCaricamento(); A PAGINA COMPLETATA // si può inserire la parte iniziale di indirizzo che termini con / che sarà unito agli script che seguono purchè non inizino con / o http // es. ElencoScript = ['/sites/default/files/', '2022-02/Esegue-CreaClassPerStiliPersonali_2022-02-15_16-44.txt'] // // Creare una funzione: function ElencoFunzioni_FineCaricamento(); {} // all'interno (delle graffe) si mettono le funzioni da eseguire come CreaClassPerStiliPersonali(); // // All'inizio documento inserire un elenco numerato di 2 O 3 righe: // 1) CaricamentoScriptçìçeventuale-inizio.comuneçnome-o-resto-dello-scriptçn-script-separati-da-ç // 2) CaricamentoFunzioniçìçelenco-di-funzioni-separate-da-çfunz1();çfunz2(); // 3) VisualizzaElencoçìç scritta esattamente per non eliminare l'elenco script e funzioni, // se dopo çìç è presente un ? visualizza l'elenco script caricati e l'elenco funzioni // Se negli elenchi il primo carattere dopo la ç è un ? verrà chiesto se caricare lo script o eseguire quel comando/funzione // Se negli elenchi il primo carattere dopo la ç è un ! NON verrà caricato lo script o eseguita la funzione // CaricamentoScriptçìçpercorsoscript1ç?percorsoscript2... ? chiede se caricare lo script (per test) // CaricamentoFunzioniçìçFunz1():ç?Funz2();... ? chiede se eseguire per test e salvataggi var Wbody = document.getElementsByTagName('body')[0]; // variabile Wbody elemento body // var Wbodyfunzpresenti = Wbody.getAttribute("onload"); // Wbody.setAttribute("onload", "Exec_FunzioniDiFineLoad(); ElencoFunzioni_FineCaricamento(); " + Wbodyfunzpresenti); document.addEventListener('readystatechange', event => { // When window loaded ( external resources are loaded too- `css`,`src`, etc...) if (event.target.readyState === "complete") { if (typeof ElencoFunzioni_FineCaricamento === "function") { ElencoFunzioni_FineCaricamento(); } else { if (typeof ElencoFunzioni_perCorrelati === "function") { ElencoFunzioni_perCorrelati(); } } Exec_FunzioniDiFineLoad(); } }); var curTip; var TipByIdMappa = {}; var InfoTipId = {}; var ElencoScript = []; // Array di elenco script da caricare var prefixScript = ""; var ElencoFunzioniDiFineLoad = []; var CaricamentoElenchiIniziali = null; var testScript = ""; var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); // CaricamentoScript_FunzioniDiFineLoad è eseguito immediatamente quindi questo script va inserito dopo l'elenco numerato (ad es. in fondo alla pagina) // se non va provare // CaricamentoElencoScript() va eseguita per prima DOPO aver riempito (tra apici e separati da virgola) la var "ElencoScript" // oppure // CaricamentoScript_FunzioniDiFineLoad() va eseguita per prima DOPO aver creato l'elenco numerato separato da ç di // function CaricamentoElencoScript() { var elementoscriptTOload; var scriptTOload; for (var iES = 0; iES < ElencoScript.length; iES++) { if (ElencoScript[iES] > " ") { scriptTOload = ElencoScript[iES]; if (scriptTOload.substring(0, 1) == "!") { continue; } if (scriptTOload.substring(0, 1) == "?") { scriptTOload = scriptTOload.substring(1); if (false === confirm("CARICARE: " + scriptTOload)) { continue; } } if (scriptTOload.substring(scriptTOload.length-1) == "/") { prefixScript = scriptTOload; } else { if ((scriptTOload.substring(0, 4)) != "http" && (scriptTOload.substring(0, 1) != "/")) { // scriptTOload = scriptTOload; // } else { scriptTOload = prefixScript + scriptTOload; } testScript = testScript + scriptTOload + "\n "; LoadScriptTxtDaElenco(scriptTOload); Wbody = document.getElementsByTagName('body')[0]; } } } } function CaricamentoScript_FunzioniDiFineLoad() { var AllTagOL = []; var AllTagLI = []; var HtmlLI; AllTagOL = Wbody.getElementsByTagName('OL'); if (AllTagOL.length == 0) { return; } for (var iO = 0; iO < AllTagOL.length; iO++) { if (AllTagOL[iO].innerHTML.search(/(CaricamentoScriptçìç|CaricamentoFunzioniçìç)/) > 0) { CaricamentoElenchiIniziali = AllTagOL[iO]; AllTagLI = CaricamentoElenchiIniziali.getElementsByTagName("LI"); CaricamentoElenchiIniziali.style.visibility = 'hidden'; CaricamentoElenchiIniziali.style.display = 'none'; CaricamentoElenchiIniziali.id = 'persElencoScriptFunzioni'; CaricamentoElenchiIniziali.className = 'pers99'; break; } } var CosaEsegue = ''; var ParametriDaEseguire = ''; var PosSep = -1; for (var iLI = 0; iLI < AllTagLI.length; iLI++) { HtmlLI = AllTagLI[iLI].innerHTML; PosSep = HtmlLI.search('çìç'); if (PosSep < 0) { continue; } CosaEsegue = HtmlLI.substring(0, PosSep); ParametriDaEseguire = HtmlLI.substring(3 + PosSep); ParametriDaEseguire = ParametriDaEseguire.replace(/\ /ig, " "); ParametriDaEseguire = ParametriDaEseguire.replace(/(\r|\n|\f|\t)/g, " "); ParametriDaEseguire = ParametriDaEseguire.replace(/\s\s/g, " "); ParametriDaEseguire = ParametriDaEseguire.replace(/çç çç/g, ""); ParametriDaEseguire = ParametriDaEseguire.replace(/\&/ig, "&"); ParametriDaEseguire = ParametriDaEseguire.replace(/\</ig, "<"); ParametriDaEseguire = ParametriDaEseguire.replace(/\>/ig, ">"); switch (CosaEsegue) { case 'CaricamentoScript': ElencoScript = ParametriDaEseguire.split('ç'); CaricamentoElencoScript(); break; case 'CaricamentoFunzioni': ElencoFunzioniDiFineLoad = ParametriDaEseguire.split('ç'); break; case 'VisualizzaElenco': CaricamentoElenchiIniziali.className = 'pers99vis'; CaricamentoElenchiIniziali.style.display = 'block'; CaricamentoElenchiIniziali.style.visibility = 'visible'; if (ParametriDaEseguire.indexOf("?") >= 0) { alert("Caricati: \n " + testScript + " Elenco Funzioni: \n " + ElencoFunzioniDiFineLoad); } break; default: break; } } if (CaricamentoElenchiIniziali == null) { return; } if (CaricamentoElenchiIniziali.style.visibility == 'visible') { return; } var testpausa = "" + ElencoFunzioniDiFineLoad; if (testpausa.indexOf("?") >= 0) { return; } CaricamentoElenchiIniziali.outerHTML = '' } function Exec_FunzioniDiFineLoad() { Wbody = document.getElementsByTagName('body')[0]; var TempFunz; var FunzTemp; for (var iF = 0; iF < ElencoFunzioniDiFineLoad.length; iF++) { TempFunz = ElencoFunzioniDiFineLoad[iF]; if (TempFunz.substring(0, 1) == "!") { continue; } if (TempFunz.substring(0, 1) == "?") { TempFunz = TempFunz.substring(1); if (false === confirm("ESEGUIRE: " + TempFunz)) { continue; } } try { FunzTemp = new Function(TempFunz); FunzTemp(); } catch(err) { alert("errore in " + TempFunz + " Err.cach: " + err); } } } function LoadScriptTxtDaElenco(httpScript) { // var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); xhr.open("GET", httpScript, false); xhr.onload=function(){ var respXHR = xhr.responseText; var jsc = document.createElement('script'); jsc.type = 'text/javascript'; jsc.charset = "UTF-8"; var code = respXHR; try { jsc.appendChild(document.createTextNode(code)); Wbody.appendChild(jsc); } catch (e) { jsc.text = code; Wbody.appendChild(jsc); } } xhr.send(); } // LoadScriptTxt("https://www.comune.rimini.it//sites/default/files/2022-10/Load_JS_e_CallFunz_da_ElencoNumerato_2022-10-04.txt"); CaricamentoScript_FunzioniDiFineLoad(); var persCLASSstyle = document.createElement('style'); persCLASSstyle.type = 'text/css'; persCLASSstyle.id = 'CSSpers99'; persCLASSstyle.innerHTML = persCLASSstyle.innerHTML + ".pers99 {display:none; visibility:hidden;}"; persCLASSstyle.innerHTML = persCLASSstyle.innerHTML + ".pers99vis {display:block; visibility:visible;}"; Wbody.appendChild(persCLASSstyle);