Tutti gli altri (6-10)

This commit is contained in:
2026-02-03 00:08:30 +01:00
parent 0043f1f83f
commit e6f6f17769
54 changed files with 3205 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<title>Username Generator</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<a href="../index.html" style="position: absolute; top: 20px; left: 20px; text-decoration: none; color: #555; font-weight: bold;">← Dashboard</a>
<div class="card-generator">
<h2>🆔 Crea il tuo Username</h2>
<p>Inserisci i tuoi dati, genereremo un nome utente sicuro.</p>
<div class="input-group">
<label>Nome</label>
<input type="text" id="input-nome" placeholder="Es: Mario ">
</div>
<div class="input-group">
<label>Cognome</label>
<input type="text" id="input-cognome" placeholder="Es: Rossi Esposito">
</div>
<button id="btn-genera">Genera Username</button>
<div id="box-risultato" class="hidden">
<p>Username suggerito:</p>
<div id="output-username" class="username-box">...</div>
</div>
</div>
<script src="script.js"></script>
</body>
</html>

View File

@@ -0,0 +1,56 @@
// SELEZIONE ELEMENTI DOM
const inputNome = document.querySelector('#input-nome');
const inputCognome = document.querySelector('#input-cognome');
const btnGenera = document.querySelector('#btn-genera');
const boxRisultato = document.querySelector('#box-risultato');
const outputUsername = document.querySelector('#output-username');
/**
* FUNZIONE: Genera Username
* Obiettivo: Creare un username formato da:
* [Prime 3 lettere Nome] + [Cognome Pulito] + [Numero Random]
* Tutto in minuscolo.
* * Passi da completare:
* 1. Recupera i valori degli input (nome e cognome).
* 2. Validazione: se uno dei due è vuoto, avvisa con alert() e fermati.
* 3. Pulizia NOME:
* - Rimuovi spazi vuoti ai lati (.trim())
* - Prendi solo le prime 3 lettere (.slice(0, 3) oppure .substring(0, 3))
* - Converti in minuscolo (.toLowerCase())
* 4. Pulizia COGNOME:
* - Rimuovi spazi vuoti ai lati (.trim())
* - Sostituisci eventuali spazi interni (es. "De Luca") con un punto o niente (.replace(" ", "") oppure .replaceAll)
* - Converti in minuscolo
* 5. Genera un numero casuale tra 10 e 99 (Math.random, Math.floor).
* 6. Unisci tutto (Nome + Cognome + Numero) e mostralo nell'output.
*/
btnGenera.addEventListener('click', function() {
// --- SCRIVI QUI IL TUO CODICE ---
// 1. Leggi
// let nome = ...
// let cognome = ...
// 2. Valida
// 3. Elabora Nome (trim, slice, toLowerCase)
// let parteNome = ...
// 4. Elabora Cognome (trim, replace, toLowerCase)
// let parteCognome = ...
// 5. Numero Random (tra 10 e 99)
// Formula: Math.floor(Math.random() * (max - min + 1)) + min
// let numero = ...
// 6. Output
// let risultato = ...
// outputUsername.textContent = risultato;
// --- FINE CODICE ---
// Mostra il risultato
boxRisultato.classList.remove('hidden');
});

View File

@@ -0,0 +1,91 @@
body {
font-family: 'Segoe UI', sans-serif;
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.card-generator {
background: white;
padding: 40px;
border-radius: 15px;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
width: 350px;
text-align: center;
}
.input-group {
text-align: left;
margin-bottom: 15px;
}
label {
display: block;
font-size: 0.9rem;
color: #666;
margin-bottom: 5px;
}
input {
width: 100%;
padding: 10px;
border: 2px solid #eee;
border-radius: 8px;
font-size: 1rem;
box-sizing: border-box;
transition: 0.3s;
}
input:focus {
border-color: #6c5ce7;
outline: none;
}
button {
width: 100%;
padding: 12px;
background-color: #6c5ce7;
color: white;
border: none;
border-radius: 8px;
cursor: pointer;
font-weight: bold;
margin-top: 10px;
transition: 0.2s;
}
button:hover {
background-color: #5649c0;
transform: translateY(-2px);
}
.hidden {
display: none;
}
#box-risultato {
margin-top: 25px;
padding-top: 20px;
border-top: 1px solid #eee;
animation: fadeIn 0.5s;
}
.username-box {
background: #f0f3f4;
color: #2d3436;
font-family: 'Courier New', monospace;
font-size: 1.4rem;
font-weight: bold;
padding: 10px;
border-radius: 8px;
letter-spacing: 1px;
border: 1px dashed #b2bec3;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}