parent
6e3dbe96ee
commit
a07077ba1a
|
@ -9,11 +9,12 @@
|
|||
</head>
|
||||
<body>
|
||||
<h1>Generatore di <td> per ER-TPL</h1>
|
||||
<a href="notrue.html">Generatore <img></a>
|
||||
<p>Inserisci matricola:</p>
|
||||
<input type="number" id="matricola" required="required">
|
||||
<p>Inserisci link share:</p>
|
||||
<input type="url" id="link" required="required">
|
||||
<button onclick="genera()">Conferma</button>
|
||||
<button onclick="generatd()">Conferma</button>
|
||||
<button onclick="copiaOutput()">Copia negli appunti</button>
|
||||
<button onclick="pulisci()">Pulisci</button>
|
||||
<pre><code id="output"></code></pre>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function genera() {
|
||||
function generatd() {
|
||||
const matricola = document.getElementById("matricola").value.trim();
|
||||
const link = document.getElementById("link").value.trim();
|
||||
|
||||
|
@ -31,6 +31,39 @@ function genera() {
|
|||
}
|
||||
}
|
||||
|
||||
function generaimg() {
|
||||
const mezzo = document.getElementById("mezzo").value.trim();
|
||||
const link = document.getElementById("link").value.trim();
|
||||
|
||||
if (!mezzo || !link) {
|
||||
alert("Compila entrambi i campi.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const urlObj = new URL(link);
|
||||
const params = new URLSearchParams(urlObj.search);
|
||||
const path = params.get("file");
|
||||
|
||||
if (!path) {
|
||||
alert("Parametro ?file= mancante nell'URL.");
|
||||
return;
|
||||
}
|
||||
|
||||
const htmlString = `<img id="${mezzo}" class="bus" src="${link}" onerror='this.onerror=null; changeUrlToFallbackNoTrue("","${mezzo}","${path}");' alt="Server foto non raggiungibile.">`;
|
||||
|
||||
const escapedOutput = htmlString
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">");
|
||||
|
||||
document.getElementById("output").innerHTML = escapedOutput;
|
||||
|
||||
} catch (error) {
|
||||
alert("URL non valido.");
|
||||
}
|
||||
}
|
||||
|
||||
function copiaOutput() {
|
||||
const code = document.getElementById("output").innerText;
|
||||
navigator.clipboard.writeText(code).then(() => {
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Generatore <td></title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<script src="linkgen.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Generatore di <img> per ER-TPL</h1>
|
||||
<a href="index.html">Generatore <td></a>
|
||||
<p>Inserisci nome mezzo html:</p>
|
||||
<input type="text" id="mezzo" required="required">
|
||||
<p>Inserisci link share:</p>
|
||||
<input type="url" id="link" required="required">
|
||||
<button onclick="generaimg()">Conferma</button>
|
||||
<button onclick="copiaOutput()">Copia negli appunti</button>
|
||||
<button onclick="pulisci()">Pulisci</button>
|
||||
<pre><code id="output"></code></pre>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue