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