-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
253 lines (225 loc) · 7.93 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Chat con Login</title>
<style>
/* Stile generale */
body {
font-family: 'Roboto', Arial, sans-serif;
margin: 0;
background-color: #f3f4f6;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
color: #333;
}
.container {
width: 100%;
max-width: 450px;
background: #ffffff;
border-radius: 20px;
padding: 20px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
/* Stile per login e registrazione */
.auth-container {
display: flex;
flex-direction: column;
}
.auth-container h2 {
text-align: center;
margin-bottom: 20px;
color: #6a11cb;
}
.auth-container label {
margin: 10px 0 5px;
font-weight: bold;
}
.auth-container input {
padding: 12px 15px;
margin-bottom: 20px;
border: 2px solid #dddddd;
border-radius: 10px;
font-size: 14px;
outline: none;
transition: border-color 0.2s ease;
}
.auth-container input:focus {
border-color: #6a11cb;
}
.auth-container button {
width: 100%;
background: linear-gradient(45deg, #6a11cb, #2575fc);
color: #ffffff;
border: none;
padding: 12px 20px;
border-radius: 10px;
font-size: 16px;
font-weight: bold;
cursor: pointer;
transition: background 0.3s ease;
}
.auth-container button:hover {
background: linear-gradient(45deg, #2575fc, #6a11cb);
}
.auth-container .toggle-link {
text-align: center;
margin-top: 10px;
font-size: 14px;
color: #6a11cb;
cursor: pointer;
}
/* Stile per la chat */
.chat-container {
display: none;
flex-direction: column;
height: 600px;
}
.chat-header {
background: linear-gradient(45deg, #6a11cb, #2575fc);
color: #ffffff;
text-align: center;
padding: 20px;
font-size: 20px;
font-weight: bold;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
}
.chat-messages {
flex: 1;
padding: 20px;
overflow-y: auto;
background-color: #f9f9f9;
}
.message {
margin: 10px 0;
padding: 12px 18px;
border-radius: 16px;
font-size: 15px;
line-height: 1.4;
width: fit-content;
max-width: 80%;
word-wrap: break-word;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.user-message {
background-color: #e1f5fe;
color: #0277bd;
align-self: flex-end;
border-top-right-radius: 0;
}
.bot-message {
background-color: #fce4ec;
color: #d81b60;
align-self: flex-start;
border-top-left-radius: 0;
}
.chat-input {
display: flex;
padding: 15px;
background-color: #ffffff;
border-top: 1px solid #eeeeee;
}
.chat-input input {
flex: 1;
padding: 12px 15px;
border: 2px solid #dddddd;
border-radius: 20px;
font-size: 14px;
outline: none;
transition: border-color 0.2s ease;
}
.chat-input input:focus {
border-color: #6a11cb;
}
.chat-input button {
background: linear-gradient(45deg, #6a11cb, #2575fc);
color: #ffffff;
border: none;
padding: 12px 20px;
margin-left: 10px;
border-radius: 20px;
font-size: 14px;
cursor: pointer;
transition: background 0.3s ease;
}
.chat-input button:hover {
background: linear-gradient(45deg, #2575fc, #6a11cb);
}
</style>
</head>
<body>
<div class="container">
<!-- Login e Registrazione -->
<div class="auth-container" id="auth-container">
<h2>Accedi</h2>
<label for="email">Email</label>
<input type="email" id="email" placeholder="Inserisci la tua email" required>
<label for="password">Password</label>
<input type="password" id="password" placeholder="Inserisci la tua password" required>
<button id="auth-btn">Entra</button>
<div class="toggle-link" id="toggle-link">Non hai un account? Registrati</div>
</div>
<!-- Chat -->
<div class="chat-container" id="chat-container">
<div class="chat-header">Chat</div>
<div class="chat-messages" id="chat-messages"></div>
<div class="chat-input">
<input type="text" id="user-input" placeholder="Scrivi qui..." autocomplete="off">
<button id="send-btn">Invia</button>
</div>
</div>
</div>
<script>
const authContainer = document.getElementById("auth-container");
const chatContainer = document.getElementById("chat-container");
const toggleLink = document.getElementById("toggle-link");
const authBtn = document.getElementById("auth-btn");
const chatMessages = document.getElementById("chat-messages");
const userInput = document.getElementById("user-input");
const sendBtn = document.getElementById("send-btn");
let isLogin = true;
toggleLink.addEventListener("click", () => {
isLogin = !isLogin;
document.querySelector(".auth-container h2").textContent = isLogin ? "Accedi" : "Registrati";
authBtn.textContent = isLogin ? "Entra" : "Registrati";
toggleLink.textContent = isLogin
? "Non hai un account? Registrati"
: "Hai già un account? Accedi";
});
authBtn.addEventListener("click", () => {
authContainer.style.display = "none";
chatContainer.style.display = "flex";
});
sendBtn.addEventListener("click", () => {
const message = userInput.value.trim();
if (message) {
addMessage("user", message);
simulateBotResponse(message);
userInput.value = "";
}
});
function addMessage(sender, text) {
const messageDiv = document.createElement("div");
messageDiv.classList.add("message", sender === "user" ? "user-message" : "bot-message");
messageDiv.textContent = text;
chatMessages.appendChild(messageDiv);
chatMessages.scrollTop = chatMessages.scrollHeight;
}
function simulateBotResponse(userMessage) {
setTimeout(() => {
let botReply = `Non capisco "${userMessage}". Riprova!`;
if (userMessage.toLowerCase() === "ciao") {
botReply = "Ciao! 😊 Come posso aiutarti?";
} else if (userMessage.toLowerCase().includes("come stai")) {
botReply = "Sto bene, grazie! Tu come stai?";
}
addMessage("bot", botReply);
}, 1000);
}
</script>
</body>
</html>