Skip to content

Commit cbf0bfa

Browse files
authored
Update login.html
Signed-off-by: Server Tutorial <servertutorial45@gmail.com>
1 parent a699bc3 commit cbf0bfa

File tree

1 file changed

+67
-59
lines changed

1 file changed

+67
-59
lines changed

Best/login.html

Lines changed: 67 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1" />
66
<title>Login e Donazione</title>
7+
<!-- Favicon di default (verrà aggiornato dinamicamente) -->
8+
<link id="dynamic-favicon" rel="icon" href="https://i.postimg.cc/XYfBdscq/icon.png" type="image/png" />
79
<style>
8-
/* Stili moderni e minimal, per un design pulito */
10+
/* Stili moderni e minimal per un design pulito */
911
body {
10-
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
12+
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
1113
background: #f2f2f2;
1214
display: flex;
1315
align-items: center;
@@ -36,28 +38,45 @@
3638
font-weight: 600;
3739
}
3840
input[type="text"],
39-
input[type="password"],
40-
input[type="number"] {
41+
input[type="password"] {
4142
width: 100%;
4243
padding: 0.5rem;
4344
font-size: 1rem;
4445
border: 1px solid #ccc;
4546
border-radius: 4px;
4647
}
47-
button {
48-
width: 100%;
48+
/* Container per i pulsanti */
49+
.button-group {
50+
display: flex;
51+
justify-content: space-between;
52+
gap: 10px;
53+
margin-top: 1rem;
54+
}
55+
.button-group button,
56+
.button-group a {
57+
flex: 1;
58+
text-align: center;
4959
padding: 0.7rem;
50-
background-color: #4caf50;
51-
color: #fff;
60+
font-size: 1rem;
5261
border: none;
5362
border-radius: 4px;
54-
font-size: 1rem;
5563
cursor: pointer;
5664
transition: background-color 0.3s;
65+
text-decoration: none;
66+
color: #fff;
5767
}
58-
button:hover {
68+
.button-group button {
69+
background-color: #4caf50;
70+
}
71+
.button-group button:hover {
5972
background-color: #45a049;
6073
}
74+
.donate-btn {
75+
background-color: #2196f3;
76+
}
77+
.donate-btn:hover {
78+
background-color: #1976d2;
79+
}
6180
.info {
6281
font-size: 0.9rem;
6382
color: #555;
@@ -66,7 +85,6 @@
6685
color: red;
6786
text-align: center;
6887
}
69-
/* Stile per l'icona di donazione */
7088
.donation-icon {
7189
max-width: 40px;
7290
vertical-align: middle;
@@ -86,12 +104,15 @@ <h2>Accedi per visualizzare i giochi</h2>
86104
<label for="password">Password:</label>
87105
<input type="password" id="password" name="password" required />
88106
</div>
89-
<!-- Sezione donazione: verrà popolata dinamicamente tramite version.json -->
90-
<div id="donation-section">
91-
<!-- Il contenuto statico viene sostituito dal fetch al file version.json -->
107+
<!-- Sezione per il messaggio di donazione -->
108+
<div id="donation-info">
92109
<p class="info">Caricamento informazioni donazione...</p>
93110
</div>
94-
<button type="submit">Accedi</button>
111+
<!-- Gruppo pulsanti: Accedi e Dona -->
112+
<div class="button-group">
113+
<button type="submit">Accedi</button>
114+
<a href="#" id="donate-btn" class="donate-btn" target="_blank">Dona</a>
115+
</div>
95116
</form>
96117
<div id="error-message" class="error"></div>
97118
</div>
@@ -100,78 +121,69 @@ <h2>Accedi per visualizzare i giochi</h2>
100121
let accountsData = null;
101122
let versionData = null;
102123

103-
// Funzione per caricare i dati degli account da remoto
124+
// Carica i dati degli account da remoto
104125
async function fetchAccounts() {
105126
try {
106-
const response = await fetch(
107-
"https://raw.githubusercontent.com/Server21/PCGames/refs/heads/main/accounts.json"
108-
);
127+
const response = await fetch("https://raw.githubusercontent.com/Server21/PCGames/refs/heads/main/accounts.json");
109128
if (!response.ok) throw new Error("Errore di rete");
110129
accountsData = await response.json();
111130
} catch (error) {
112-
document.getElementById("error-message").innerText =
113-
"Errore nel caricamento degli account.";
131+
document.getElementById("error-message").innerText = "Errore nel caricamento degli account.";
114132
console.error(error);
115133
}
116134
}
117135

118-
// Funzione per caricare i dati di versione/donazione
136+
// Carica i dati di versione/donazione da version.json
119137
async function fetchVersionInfo() {
120138
try {
121-
const response = await fetch(
122-
"https://raw.githubusercontent.com/Server21/PCGames/refs/heads/main/version.json"
123-
);
139+
const response = await fetch("https://raw.githubusercontent.com/Server21/PCGames/refs/heads/main/version.json");
124140
if (!response.ok) throw new Error("Errore di rete");
125141
versionData = await response.json();
126142
updateDonationSection();
143+
updateFavicon();
127144
} catch (error) {
128145
console.error("Errore nel caricamento delle info di versione:", error);
129146
}
130147
}
131148

132-
// Aggiorna il blocco donazione con i dati caricati in version.json
149+
// Aggiorna il blocco donazione con i dati di version.json
133150
function updateDonationSection() {
134-
const donationSection = document.getElementById("donation-section");
151+
const donationInfo = document.getElementById("donation-info");
135152
if (versionData) {
136-
donationSection.innerHTML = `
153+
donationInfo.innerHTML = `
137154
<p class="info">
138-
<img src="${versionData.icon_link}" alt="Icona donazione" class="donation-icon">
155+
<img src="${versionData.icon_link}" alt="Icona donazione" class="donation-icon">
139156
${versionData.donation_message}
140157
</p>
141-
<label for="donation">Importo donazione (minimo 5€):</label>
142-
<input type="number" id="donation" name="donation" min="5" step="any" />
143-
<p>
144-
<a href="${versionData.donation_link}" target="_blank">Effettua la donazione</a>
145-
</p>
146158
`;
159+
// Imposta il link del pulsante Dona
160+
document.getElementById("donate-btn").href = versionData.donation_link;
147161
}
148162
}
149163

150-
// Inizializza il fetch dei dati
164+
// Aggiorna dinamicamente il favicon con l'icona da version.json
165+
function updateFavicon() {
166+
if (versionData && versionData.icon_link) {
167+
let favicon = document.getElementById("dynamic-favicon");
168+
if (!favicon) {
169+
favicon = document.createElement("link");
170+
favicon.id = "dynamic-favicon";
171+
favicon.rel = "icon";
172+
document.head.appendChild(favicon);
173+
}
174+
favicon.href = versionData.icon_link;
175+
}
176+
}
177+
178+
// Inizializza i fetch
151179
fetchAccounts();
152180
fetchVersionInfo();
153181

154-
// Mostra o nasconde la sezione donazione in base all'account
155-
document.getElementById("username").addEventListener("blur", function () {
156-
if (!accountsData) return;
157-
const username = this.value.trim();
158-
const donationSection = document.getElementById("donation-section");
159-
// Se l'account esiste ed è già attivo (ha proprietà "expires"), nascondiamo la sezione donazione
160-
if (username in accountsData && typeof accountsData[username] === "object") {
161-
donationSection.style.display = "none";
162-
} else {
163-
donationSection.style.display = "block";
164-
}
165-
});
166-
167-
// Gestione del submit del form con async/await
182+
// Gestione del submit per il login
168183
document.getElementById("login-form").addEventListener("submit", async (e) => {
169184
e.preventDefault();
170185
const username = document.getElementById("username").value.trim();
171186
const passwordInput = document.getElementById("password").value;
172-
const donationValue = document.getElementById("donation")
173-
? document.getElementById("donation").value
174-
: "";
175187
const errorDiv = document.getElementById("error-message");
176188

177189
if (!accountsData) {
@@ -188,12 +200,8 @@ <h2>Accedi per visualizzare i giochi</h2>
188200
const account = accountsData[username];
189201

190202
if (typeof account === "string") {
191-
// L'account è definito solo dalla password: richiede donazione
203+
// L'account è definito solo dalla password
192204
if (account === passwordInput) {
193-
if (parseFloat(donationValue) < 5) {
194-
errorDiv.innerText = "Importo donazione insufficiente (minimo 5€).";
195-
return;
196-
}
197205
valid = true;
198206
// Attiva l’abbonamento per 1 mese dalla data corrente
199207
const date = new Date();
@@ -211,10 +219,10 @@ <h2>Accedi per visualizzare i giochi</h2>
211219
if (valid) {
212220
const loggedInUser = { username, expires };
213221
localStorage.setItem("loggedInUser", JSON.stringify(loggedInUser));
214-
// Reindirizza l'utente alla pagina Bonazza.html
222+
// Reindirizza alla pagina Bonazza.html
215223
window.location.href = "Bonazza.html";
216224
} else {
217-
errorDiv.innerText = "Password errata o donazione non valida.";
225+
errorDiv.innerText = "Password errata o account non valido.";
218226
}
219227
});
220228
</script>

0 commit comments

Comments
 (0)