mirror of
https://github.com/Daniongithub/ER-TPL.git
synced 2025-12-06 08:42:05 +00:00
Updating my swiss-knife tool for jsons.
This commit is contained in:
@@ -16,11 +16,20 @@
|
|||||||
<input type="number" id="matra">
|
<input type="number" id="matra">
|
||||||
</div>
|
</div>
|
||||||
<p>Seleziona settore:</p>
|
<p>Seleziona settore:</p>
|
||||||
<select id="selezione">
|
<label for="privati">Stai inserendo un <i>vettore</i> privato?</label>
|
||||||
<option value="Urbano">Urbano</option>
|
<input type="checkbox" name="privati" id="flag">
|
||||||
<option value="Suburbano">Suburbano</option>
|
<br>
|
||||||
<option value="Extraurbano">Extraurbano</option>
|
<div style="margin-top: 15px;">
|
||||||
</select>
|
<select id="selezione">
|
||||||
|
<option value="Urbano">Urbano</option>
|
||||||
|
<option value="Suburbano">Suburbano</option>
|
||||||
|
<option value="Extraurbano">Extraurbano</option>
|
||||||
|
<option value="C.T.R.T.">C.T.R.T.</option>
|
||||||
|
<option value="Gamberini">Gamberini</option>
|
||||||
|
<option value="Pollini">Pollini</option>
|
||||||
|
<option value="Zaganelli">Zaganelli</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<p>Inserisci modello mezzo:</p>
|
<p>Inserisci modello mezzo:</p>
|
||||||
<input type="text" id="modello">
|
<input type="text" id="modello">
|
||||||
<p>Inserisci link HTML:</p>
|
<p>Inserisci link HTML:</p>
|
||||||
|
|||||||
@@ -1,29 +1,34 @@
|
|||||||
function genera() {
|
function genera() {
|
||||||
const matrda = document.getElementById("matrda").value.trim();
|
const matrda = document.getElementById("matrda").value.trim();
|
||||||
const matra = document.getElementById("matra").value.trim();
|
const matra = document.getElementById("matra").value.trim();
|
||||||
const selezione = document.getElementById("selezione").value.trim();
|
const selezione = document.getElementById("selezione").value.trim();
|
||||||
const modello = document.getElementById("modello").value.trim();
|
const modello = document.getElementById("modello").value.trim();
|
||||||
const link = document.getElementById("link").value.trim();
|
const link = document.getElementById("link").value.trim();
|
||||||
const startMatricola = parseInt(matrda);
|
const flag = document.getElementById("flag");
|
||||||
const endMatricola = parseInt(matra);
|
const startMatricola = parseInt(matrda);
|
||||||
let jsonArray = [];
|
const endMatricola = parseInt(matra);
|
||||||
for (let i = startMatricola; i <= endMatricola; i++) {
|
let jsonArray = [];
|
||||||
link2 = link + "#" + i.toString();
|
for (let i = startMatricola; i <= endMatricola; i++) {
|
||||||
let baseJson = {
|
let link2 = link + "#" + i.toString();
|
||||||
"matricola": i.toString(),
|
let tipo = "settore";
|
||||||
"settore": selezione,
|
if (flag.checked){
|
||||||
"modello": modello,
|
tipo = "vettore"
|
||||||
"link": link2
|
}
|
||||||
};
|
let baseJson = {
|
||||||
|
"matricola": i.toString(),
|
||||||
|
[tipo]: selezione,
|
||||||
|
"modello": modello,
|
||||||
|
"link": link2
|
||||||
|
};
|
||||||
|
jsonArray.push(baseJson);
|
||||||
|
}
|
||||||
|
document.getElementById("output").textContent =
|
||||||
|
jsonArray.map((item, index) => {
|
||||||
|
const jsonStr = JSON.stringify(item, null, 2);
|
||||||
|
return (index < jsonArray.length - 1) ? jsonStr + "," : jsonStr;
|
||||||
|
}).join("\n");
|
||||||
|
}
|
||||||
|
|
||||||
jsonArray.push(baseJson);
|
|
||||||
}
|
|
||||||
document.getElementById("output").textContent =
|
|
||||||
jsonArray.map((item, index) => {
|
|
||||||
const jsonStr = JSON.stringify(item, null, 2);
|
|
||||||
return (index < jsonArray.length - 1) ? jsonStr + "," : jsonStr;
|
|
||||||
}).join("\n");
|
|
||||||
}
|
|
||||||
function copiaOutput() {
|
function copiaOutput() {
|
||||||
const code = document.getElementById("output").innerText;
|
const code = document.getElementById("output").innerText;
|
||||||
navigator.clipboard.writeText(code).then(() => {
|
navigator.clipboard.writeText(code).then(() => {
|
||||||
@@ -31,6 +36,7 @@ function copiaOutput() {
|
|||||||
alert("Errore durante la copia.");
|
alert("Errore durante la copia.");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function pulisci() {
|
function pulisci() {
|
||||||
document.getElementById("matrda").value = "";
|
document.getElementById("matrda").value = "";
|
||||||
document.getElementById("matra").value = "";
|
document.getElementById("matra").value = "";
|
||||||
|
|||||||
Reference in New Issue
Block a user