Skip to content

Commit a2769eb

Browse files
aggiunti contenuti pagina login, welcome, script
1 parent de1be5f commit a2769eb

File tree

3 files changed

+100
-0
lines changed

3 files changed

+100
-0
lines changed

index.html

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE html>
2+
<html lang="it">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
<title>Login</title>
7+
<style>
8+
body { font-family: Arial, sans-serif; display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #f4f6f8; margin: 0; }
9+
.login-box { width: 320px; background: #fff; padding: 24px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); }
10+
.login-box h2 { margin: 0 0 16px; }
11+
.field { margin-bottom: 12px; }
12+
.field label { display: block; font-size: 13px; margin-bottom: 6px; color: #444; }
13+
.field input { width: 100%; padding: 10px 12px; border: 1px solid #d0d7de; border-radius: 6px; font-size: 14px; }
14+
button { width: 100%; padding: 10px 14px; background: #0969da; color: #fff; border: none; border-radius: 6px; font-weight: bold; cursor: pointer; }
15+
button:hover { background: #0758b7; }
16+
.note { font-size: 12px; color: #666; margin-top: 10px; }
17+
</style>
18+
</head>
19+
<body>
20+
<div class="login-box">
21+
<h2>Login</h2>
22+
23+
<div class="field">
24+
<label for="name">Nome</label>
25+
<input type="text" id="name" placeholder="Mario Rossi" required />
26+
</div>
27+
28+
<div class="field">
29+
<label for="email">Email</label>
30+
<input type="email" id="email" placeholder="mario@example.com" required />
31+
</div>
32+
33+
<button onclick="login()">Accedi</button>
34+
<p class="note">Accetta qualsiasi nome/email. I dati vengono salvati in <b>localStorage</b>.</p>
35+
</div>
36+
37+
<!-- Collega correttamente lo script -->
38+
script.js</script>
39+
</body>
40+
</html>

script.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
function login() {
2+
const name = document.getElementById('name').value.trim();
3+
const email = document.getElementById('email').value.trim();
4+
5+
// Accetta qualsiasi nome/email, ma suggeriamo di non lasciare vuoti
6+
if (!name || !email) {
7+
alert('Inserisci nome ed email.');
8+
return;
9+
}
10+
11+
// Salva in localStorage per riutilizzo (es. chat)
12+
localStorage.setItem('name', name);
13+
localStorage.setItem('email', email);
14+
15+
// Reindirizza alla welcome
16+
window.location.href = 'welcome.html';
17+
}

welcome.html

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html>
2+
<html lang="it">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
<title>Benvenuto</title>
7+
<style>
8+
body { font-family: Arial, sans-serif; display: flex; justify-content: center; align-items: center; min-height: 100vh; background: #f4f6f8; margin: 0; }
9+
.box { background: #fff; padding: 24px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.1); text-align: center; }
10+
h1 { margin: 0 0 10px; }
11+
.email { color: #444; margin-bottom: 16px; }
12+
a.button { display: inline-block; padding: 10px 14px; background: #0969da; color: #fff; border-radius: 6px; text-decoration: none; }
13+
a.button:hover { background: #0758b7; }
14+
</style>
15+
</head>
16+
<body>
17+
<div class="box">
18+
<h1 id="welcome-message">Benvenuto!</h1>
19+
<p class="email" id="email-line"></p>
20+
21+
<!-- Esempio: passa l'email come parametro alla chat -->
22+
<a id="chat-link" class="button" href="#">Apri chat= localStorage.getItem('name');
23+
const email = localStorage.getItem('email');
24+
25+
// Fallback se l’utente arriva senza login
26+
const displayName = name || 'Utente';
27+
document.getElementById('welcome-message').innerText = `Benvenuto, ${displayName}!`;
28+
29+
if (email) {
30+
document.getElementById('email-line').innerText = `Email: ${email}`;
31+
} else {
32+
document.getElementById('email-line').innerText = `Email non disponibile`;
33+
}
34+
35+
// Prepara link verso una chat passando l’email come querystring
36+
// Sostituisci 'chat.html' con la tua pagina chat reale
37+
const chatUrl = `chat.html?email=${encodeURIComponent(email || '')}`;
38+
const chatLink = document.getElementById('chat-link');
39+
chatLink.href = chatUrl;
40+
chatLink.innerText = 'Vai alla chat';
41+
</script>
42+
</body>
43+
</html>

0 commit comments

Comments
 (0)