ServerX commited on
Commit
8254820
·
verified ·
1 Parent(s): a1c8378

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +91 -232
index.html CHANGED
@@ -1,232 +1,91 @@
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, maximum-scale=1.0, user-scalable=no">
6
- <title>Gioco dell'Impiccato</title>
7
- <style>
8
- * {
9
- box-sizing: border-box;
10
- touch-action: manipulation;
11
- }
12
- body {
13
- font-family: 'Arial', sans-serif;
14
- text-align: center;
15
- margin: 0;
16
- padding: 15px;
17
- background-color: #f5f5f5;
18
- line-height: 1.6;
19
- }
20
- h1 {
21
- color: #333;
22
- font-size: 1.5rem;
23
- margin-bottom: 20px;
24
- }
25
- #game-container {
26
- background-color: #fff;
27
- padding: 20px;
28
- border-radius: 10px;
29
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
30
- max-width: 100%;
31
- width: 100%;
32
- margin: 0 auto;
33
- }
34
- #word-display {
35
- font-size: 1.8rem;
36
- margin-bottom: 20px;
37
- font-weight: bold;
38
- letter-spacing: 5px;
39
- }
40
- #word-entry, #guess-input-container {
41
- display: flex;
42
- flex-direction: column;
43
- align-items: center;
44
- gap: 10px;
45
- margin-bottom: 20px;
46
- }
47
- #word-input, #guess-input {
48
- width: 100%;
49
- padding: 10px;
50
- font-size: 16px;
51
- border: 1px solid #ddd;
52
- border-radius: 5px;
53
- text-align: center;
54
- }
55
- #submit-word-btn, #submit-btn, #reset-btn {
56
- width: 100%;
57
- padding: 12px;
58
- font-size: 16px;
59
- cursor: pointer;
60
- background-color: #4caf50;
61
- color: #fff;
62
- border: none;
63
- border-radius: 5px;
64
- transition: background-color 0.3s;
65
- text-transform: uppercase;
66
- font-weight: bold;
67
- }
68
- #submit-word-btn:active, #submit-btn:active, #reset-btn:active {
69
- background-color: #45a049;
70
- }
71
- #result {
72
- font-size: 1rem;
73
- margin-top: 15px;
74
- color: #e74c3c;
75
- font-weight: bold;
76
- }
77
- label {
78
- margin-bottom: 10px;
79
- font-weight: bold;
80
- }
81
- @media (max-height: 600px) {
82
- body {
83
- padding: 10px;
84
- }
85
- h1 {
86
- font-size: 1.2rem;
87
- margin-bottom: 10px;
88
- }
89
- #game-container {
90
- padding: 15px;
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>&copy; 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>