New JsonGen
This commit is contained in:
parent
40bd98b06b
commit
e80915a408
|
@ -0,0 +1,33 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>JsonGen</title>
|
||||
<link rel="stylesheet" href="/admin/dani/linkgen/style.css">
|
||||
<script src="script.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>JsonGen</h1>
|
||||
<div>
|
||||
<p>Inserisci matricola a partire da:</p>
|
||||
<input type="number" id="matrda">
|
||||
<p>Matricola a:</p>
|
||||
<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>
|
||||
<p>Inserisci modello mezzo:</p>
|
||||
<input type="text" id="modello">
|
||||
<p>Inserisci link HTML:</p>
|
||||
<input type="text" id="link">
|
||||
<button onclick="genera()">Conferma</button>
|
||||
<button onclick="copiaOutput()">Copia negli appunti</button>
|
||||
<button onclick="pulisci()">Pulisci</button>
|
||||
<pre><code id="output"></code></pre>
|
||||
</body>
|
||||
</html>
|
|
@ -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 = "";
|
||||
}
|
|
@ -2,3 +2,6 @@ body{
|
|||
text-align: center;
|
||||
font-family: Consolas;
|
||||
}
|
||||
pre{
|
||||
text-align: left;
|
||||
}
|
|
@ -13,5 +13,6 @@
|
|||
<h1>Pagina dei servizi del Dani</h1>
|
||||
<p>Complimenti! Se hai trovato questa pagina sei davvero un grande smanettone.<br> Tranquillo, qui non troverai segreti statali e mai ci saranno.</p>
|
||||
<a href="/admin/dani/linkgen/linkgen.html">Generatore <td> e <img></a>
|
||||
<a href="/"></a>
|
||||
</body>
|
||||
</html>
|
|
@ -1,6 +1,8 @@
|
|||
[
|
||||
{
|
||||
"matricola": "placeholderMatricola",
|
||||
"settore": "placeholderSettore",
|
||||
"modello": "placeholderModello",
|
||||
"link": "placeholderLink"
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue