mirror of
https://github.com/Daniongithub/ER-TPL.git
synced 2025-10-02 19:10:47 +00:00
New JsonGen
This commit is contained in:
38
admin/dani/jsongen/script.js
Normal file
38
admin/dani/jsongen/script.js
Normal file
@@ -0,0 +1,38 @@
|
||||
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++) {
|
||||
let baseJson = {
|
||||
"matricola": i.toString(),
|
||||
"settore": selezione,
|
||||
"modello": modello,
|
||||
"link": link
|
||||
};
|
||||
|
||||
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(() => {
|
||||
}).catch(() => {
|
||||
alert("Errore durante la copia.");
|
||||
});
|
||||
}
|
||||
function pulisci() {
|
||||
document.getElementById("matrda").value = "";
|
||||
document.getElementById("matra").value = "";
|
||||
document.getElementById("link").value = "";
|
||||
document.getElementById("output").innerHTML = "";
|
||||
}
|
Reference in New Issue
Block a user