Spaces:
Sleeping
Sleeping
Update index.html
Browse files- index.html +91 -232
index.html
CHANGED
@@ -1,232 +1,91 @@
|
|
1 |
-
<!DOCTYPE html>
|
2 |
-
<html lang="en">
|
3 |
-
<head>
|
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 |
-
</style>
|
94 |
-
</head>
|
95 |
-
<body>
|
96 |
-
<h1>Benvenuto al Gioco dell'Impiccato!</h1>
|
97 |
-
|
98 |
-
<span id="myMessage" style="font-size: medium; white-space: pre;">Questo gioco lo potrai giocare solo in locale con un tuo amico e familiare</span>
|
99 |
-
|
100 |
-
<div id="game-container">
|
101 |
-
<div id="word-entry">
|
102 |
-
<label for="word-input">Inserisci una parola:</label>
|
103 |
-
<input type="password" id="word-input" autocomplete="off" autocorrect="off" autocapitalize="none" spellcheck="false">
|
104 |
-
<button id="submit-word-btn" onclick="startGame()">Inizia il gioco</button>
|
105 |
-
</div>
|
106 |
-
|
107 |
-
<div id="word-display"></div>
|
108 |
-
|
109 |
-
<div id="guess-input-container">
|
110 |
-
<label for="guess-input">Inserisci una lettera o la risposta completa:</label>
|
111 |
-
<input type="text" id="guess-input" autocomplete="off" autocorrect="off" autocapitalize="none" spellcheck="false">
|
112 |
-
<button id="submit-btn" onclick="checkGuess()">Indovina</button>
|
113 |
-
</div>
|
114 |
-
|
115 |
-
<div id="result"></div>
|
116 |
-
|
117 |
-
<button id="reset-btn" onclick="resetGame()">Ricomincia</button>
|
118 |
-
</div>
|
119 |
-
|
120 |
-
<div id="cast-section" style="margin-top: 20px;">
|
121 |
-
<button onclick="generateCastLink()">Genera Link per Visualizzare il Gioco</button>
|
122 |
-
<p id="cast-link"></p>
|
123 |
-
</div>
|
124 |
-
|
125 |
-
<script>
|
126 |
-
document.getElementById('word-input').addEventListener('keyup', function(event) {
|
127 |
-
if (event.key === 'Enter') {
|
128 |
-
startGame();
|
129 |
-
}
|
130 |
-
});
|
131 |
-
|
132 |
-
document.getElementById('guess-input').addEventListener('keyup', function(event) {
|
133 |
-
if (event.key === 'Enter') {
|
134 |
-
checkGuess();
|
135 |
-
}
|
136 |
-
});
|
137 |
-
|
138 |
-
var parolaDaIndovinare = '';
|
139 |
-
var lettereIndovinate = [];
|
140 |
-
var tentativiRimasti = 6;
|
141 |
-
|
142 |
-
function startGame() {
|
143 |
-
parolaDaIndovinare = document.getElementById('word-input').value.toUpperCase();
|
144 |
-
|
145 |
-
if (/^[a-zA-Z]+$/.test(parolaDaIndovinare) && parolaDaIndovinare.length > 0) {
|
146 |
-
lettereIndovinate = new Array(parolaDaIndovinare.length).fill('_');
|
147 |
-
displayWord();
|
148 |
-
document.getElementById('word-entry').style.display = 'none';
|
149 |
-
} else {
|
150 |
-
alert('Inserisci una parola valida (almeno un carattere).');
|
151 |
-
}
|
152 |
-
}
|
153 |
-
|
154 |
-
function displayWord() {
|
155 |
-
document.getElementById('word-display').innerHTML = lettereIndovinate.join(' ');
|
156 |
-
}
|
157 |
-
|
158 |
-
function checkGuess() {
|
159 |
-
var inputElement = document.getElementById('guess-input');
|
160 |
-
var guess = inputElement.value.toUpperCase();
|
161 |
-
|
162 |
-
inputElement.value = '';
|
163 |
-
|
164 |
-
if (guess.length > 1) {
|
165 |
-
if (guess === parolaDaIndovinare) {
|
166 |
-
lettereIndovinate = parolaDaIndovinare.split('');
|
167 |
-
displayWord();
|
168 |
-
document.getElementById('result').textContent = 'Complimenti! Hai indovinato la parola!';
|
169 |
-
disableGuessing();
|
170 |
-
} else {
|
171 |
-
tentativiRimasti -= 2;
|
172 |
-
updateGameStatus();
|
173 |
-
}
|
174 |
-
} else {
|
175 |
-
var letteraTrovata = false;
|
176 |
-
|
177 |
-
for (var i = 0; i < parolaDaIndovinare.length; i++) {
|
178 |
-
if (parolaDaIndovinare[i] === guess) {
|
179 |
-
lettereIndovinate[i] = guess;
|
180 |
-
letteraTrovata = true;
|
181 |
-
}
|
182 |
-
}
|
183 |
-
|
184 |
-
displayWord();
|
185 |
-
|
186 |
-
if (!letteraTrovata) {
|
187 |
-
tentativiRimasti--;
|
188 |
-
}
|
189 |
-
|
190 |
-
updateGameStatus();
|
191 |
-
}
|
192 |
-
}
|
193 |
-
|
194 |
-
function updateGameStatus() {
|
195 |
-
document.getElementById('result').textContent = tentativiRimasti > 0 ?
|
196 |
-
'Tentativi rimasti: ' + tentativiRimasti :
|
197 |
-
'Mi dispiace, hai esaurito i tentativi. La parola era: ' + parolaDaIndovinare;
|
198 |
-
|
199 |
-
if (lettereIndovinate.join('') === parolaDaIndovinare || tentativiRimasti <= 0) {
|
200 |
-
disableGuessing();
|
201 |
-
}
|
202 |
-
}
|
203 |
-
|
204 |
-
function disableGuessing() {
|
205 |
-
document.getElementById('guess-input').disabled = true;
|
206 |
-
document.getElementById('submit-btn').disabled = true;
|
207 |
-
}
|
208 |
-
|
209 |
-
function resetGame() {
|
210 |
-
parolaDaIndovinare = '';
|
211 |
-
lettereIndovinate = [];
|
212 |
-
tentativiRimasti = 6;
|
213 |
-
|
214 |
-
document.getElementById('word-entry').style.display = 'block';
|
215 |
-
document.getElementById('word-input').value = '';
|
216 |
-
document.getElementById('guess-input').disabled = false;
|
217 |
-
document.getElementById('submit-btn').disabled = false;
|
218 |
-
document.getElementById('word-display').innerHTML = '';
|
219 |
-
document.getElementById('result').textContent = '';
|
220 |
-
}
|
221 |
-
|
222 |
-
// Funzione per generare un link che può essere usato in una rete locale
|
223 |
-
function generateCastLink() {
|
224 |
-
var ipAddress = window.location.hostname; // Ottieni l'IP locale
|
225 |
-
var port = 8080; // Puoi cambiarlo con una porta disponibile
|
226 |
-
|
227 |
-
var link = 'http://' + ipAddress + ':' + port + '/index.html'; // Aggiungi il percorso del gioco
|
228 |
-
document.getElementById('cast-link').textContent = 'Link per visualizzare il gioco: ' + link;
|
229 |
-
}
|
230 |
-
</script>
|
231 |
-
</body>
|
232 |
-
</html>
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
7 |
+
<meta name="description" content="Hangman Game - Gradio Interface">
|
8 |
+
<title>Hangman Game - Gradio Interface</title>
|
9 |
+
|
10 |
+
<!-- Caricamento ottimizzato del CSS -->
|
11 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
|
12 |
+
|
13 |
+
<!-- Ottimizzazione delle risorse (favicon) -->
|
14 |
+
<link rel="icon" href="images/favicon.ico" type="image/x-icon">
|
15 |
+
|
16 |
+
<!-- Preload dei font per migliorare la velocità di rendering -->
|
17 |
+
<link rel="preload" href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" as="font" type="font/woff2" crossorigin="anonymous">
|
18 |
+
|
19 |
+
<!-- Ottimizzazione SEO per migliorare l'indicizzazione -->
|
20 |
+
<meta name="robots" content="index, follow">
|
21 |
+
<meta name="author" content="ServerX">
|
22 |
+
</head>
|
23 |
+
<body>
|
24 |
+
<header class="container mt-4">
|
25 |
+
<h1 class="text-center">Welcome to Hangman Game</h1>
|
26 |
+
</header>
|
27 |
+
|
28 |
+
<main class="container">
|
29 |
+
<section id="game-container" class="mt-5">
|
30 |
+
<!-- Display della parola da indovinare -->
|
31 |
+
<div id="word-display" class="text-center mb-3">____</div>
|
32 |
+
|
33 |
+
<!-- Input per la lettera -->
|
34 |
+
<div class="d-flex justify-content-center mb-3">
|
35 |
+
<input type="text" id="guess-input" class="form-control w-25" placeholder="Enter a letter" aria-label="Enter a letter for the game">
|
36 |
+
</div>
|
37 |
+
|
38 |
+
<!-- Bottone per fare la guess -->
|
39 |
+
<div class="d-flex justify-content-center">
|
40 |
+
<button id="guess-button" class="btn btn-primary" onclick="makeGuess()">Guess</button>
|
41 |
+
</div>
|
42 |
+
|
43 |
+
<!-- Status del gioco -->
|
44 |
+
<div id="game-status" class="text-center mt-3">Status: Playing</div>
|
45 |
+
</section>
|
46 |
+
|
47 |
+
<!-- Modal Game Over -->
|
48 |
+
<div id="game-over-modal" class="text-center mt-5" style="display:none;">
|
49 |
+
<p>Game Over! Would you like to play again?</p>
|
50 |
+
<button class="btn btn-success" onclick="restartGame()">Play Again</button>
|
51 |
+
</div>
|
52 |
+
</main>
|
53 |
+
|
54 |
+
<footer class="container mt-5 text-center">
|
55 |
+
<p>© 2025 ServerX. All rights reserved.</p>
|
56 |
+
</footer>
|
57 |
+
|
58 |
+
<!-- Caricamento asincrono di JavaScript -->
|
59 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" async defer></script>
|
60 |
+
|
61 |
+
<!-- Script di gioco -->
|
62 |
+
<script>
|
63 |
+
let gameStatus = "playing";
|
64 |
+
|
65 |
+
// Funzione per fare la guess
|
66 |
+
function makeGuess() {
|
67 |
+
let guess = document.getElementById('guess-input').value.toLowerCase();
|
68 |
+
if (guess.length === 1) {
|
69 |
+
console.log(`User guessed: ${guess}`);
|
70 |
+
// Logica di gioco per indovinare la lettera
|
71 |
+
// Implementa qui la logica per aggiornare la parola o il numero di tentativi
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
// Funzione per riavviare il gioco
|
76 |
+
function restartGame() {
|
77 |
+
document.getElementById('game-status').innerText = 'Status: Playing';
|
78 |
+
document.getElementById('game-over-modal').style.display = 'none';
|
79 |
+
// Logica per resettare il gioco
|
80 |
+
gameStatus = "playing";
|
81 |
+
}
|
82 |
+
|
83 |
+
// Abilita l'interazione tramite tasto invio
|
84 |
+
document.getElementById('guess-input').addEventListener('keypress', function(event) {
|
85 |
+
if (event.key === "Enter") {
|
86 |
+
makeGuess();
|
87 |
+
}
|
88 |
+
});
|
89 |
+
</script>
|
90 |
+
</body>
|
91 |
+
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|