Spaces:
Running
Running
loic.ledreck
commited on
Commit
·
b8390b4
1
Parent(s):
1144c5d
feat: popup part1
Browse files- static/index.html +143 -13
- static/styles.css +168 -18
static/index.html
CHANGED
@@ -16,11 +16,9 @@
|
|
16 |
<div class="profile-text">
|
17 |
<h2>Donald J. Trump</h2>
|
18 |
<span>@realDonaldTrump</span>
|
19 |
-
<p>
|
20 |
-
|
21 |
-
|
22 |
-
A rejoint X en mars 2009
|
23 |
-
</p>
|
24 |
</div>
|
25 |
<div class="divider"></div>
|
26 |
</div>
|
@@ -31,11 +29,40 @@
|
|
31 |
</div>
|
32 |
</div>
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
<!-- Ajout : container pour la carte SVG à droite -->
|
35 |
<div class="map-container">
|
36 |
-
<svg
|
37 |
-
id="worldMap"
|
38 |
-
xmlns="http://www.w3.org/2000/svg"
|
39 |
viewBox="0 0 2000 1200"
|
40 |
>
|
41 |
<!-- Les paths seront injectés en JavaScript -->
|
@@ -50,18 +77,18 @@
|
|
50 |
const chatWindow = document.getElementById('chatWindow');
|
51 |
const messageDiv = document.createElement('div');
|
52 |
messageDiv.className = `message ${isUser ? 'user' : 'trump'}`;
|
53 |
-
|
54 |
if (!isUser) {
|
55 |
const img = document.createElement('img');
|
56 |
img.src = '/images/donald_trump.jpg';
|
57 |
img.alt = 'Trump';
|
58 |
messageDiv.appendChild(img);
|
59 |
}
|
60 |
-
|
61 |
const contentDiv = document.createElement('div');
|
62 |
contentDiv.className = 'message-content';
|
63 |
contentDiv.textContent = message;
|
64 |
-
|
65 |
messageDiv.appendChild(contentDiv);
|
66 |
chatWindow.appendChild(messageDiv);
|
67 |
chatWindow.scrollTop = chatWindow.scrollHeight;
|
@@ -143,6 +170,109 @@
|
|
143 |
});
|
144 |
|
145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
// ============================
|
147 |
// AJOUT : GESTION DE LA CARTE SVG
|
148 |
// ============================
|
@@ -815,12 +945,12 @@
|
|
815 |
} else {
|
816 |
path.setAttribute('fill', 'red');
|
817 |
}
|
818 |
-
|
819 |
// Optionnel : ajout d'un survol ou d'un clic pour modifier l'attribut
|
820 |
// path.addEventListener('click', () => {
|
821 |
// // Ex: toggler la valeur Yes/No puis changer la couleur
|
822 |
// });
|
823 |
-
|
824 |
svgContainer.appendChild(path);
|
825 |
}
|
826 |
});
|
|
|
16 |
<div class="profile-text">
|
17 |
<h2>Donald J. Trump</h2>
|
18 |
<span>@realDonaldTrump</span>
|
19 |
+
<p>45th & 47th President 🇺🇸<br/>
|
20 |
+
DonaldJTrump.com<br/>
|
21 |
+
A rejoint X en mars 2009</p>
|
|
|
|
|
22 |
</div>
|
23 |
<div class="divider"></div>
|
24 |
</div>
|
|
|
29 |
</div>
|
30 |
</div>
|
31 |
|
32 |
+
|
33 |
+
<div class="popup" id="gamePopup">
|
34 |
+
<div class="popup-header">
|
35 |
+
<span class="popup-title">Game Intro</span>
|
36 |
+
<div class="popup-controls">
|
37 |
+
<button class="control-btn minimize">−</button>
|
38 |
+
<button class="control-btn maximize">□</button>
|
39 |
+
<button class="control-btn close">×</button>
|
40 |
+
</div>
|
41 |
+
</div>
|
42 |
+
<div class="popup-content">
|
43 |
+
<iframe src="intro.html" class="intro-frame"></iframe>
|
44 |
+
<button class="popup-ok">Start Game</button>
|
45 |
+
</div>
|
46 |
+
</div>
|
47 |
+
|
48 |
+
<div class="popup" id="gameOverPopup">
|
49 |
+
<div class="popup-header">
|
50 |
+
<span class="popup-title">Game Over</span>
|
51 |
+
<div class="popup-controls">
|
52 |
+
<button class="control-btn close">×</button>
|
53 |
+
</div>
|
54 |
+
</div>
|
55 |
+
<div class="popup-content">
|
56 |
+
<img src="/images/game_over.png" alt="Game Over" class="popup-gif">
|
57 |
+
<button class="popup-ok">Try Again</button>
|
58 |
+
</div>
|
59 |
+
</div>
|
60 |
+
|
61 |
<!-- Ajout : container pour la carte SVG à droite -->
|
62 |
<div class="map-container">
|
63 |
+
<svg
|
64 |
+
id="worldMap"
|
65 |
+
xmlns="http://www.w3.org/2000/svg"
|
66 |
viewBox="0 0 2000 1200"
|
67 |
>
|
68 |
<!-- Les paths seront injectés en JavaScript -->
|
|
|
77 |
const chatWindow = document.getElementById('chatWindow');
|
78 |
const messageDiv = document.createElement('div');
|
79 |
messageDiv.className = `message ${isUser ? 'user' : 'trump'}`;
|
80 |
+
|
81 |
if (!isUser) {
|
82 |
const img = document.createElement('img');
|
83 |
img.src = '/images/donald_trump.jpg';
|
84 |
img.alt = 'Trump';
|
85 |
messageDiv.appendChild(img);
|
86 |
}
|
87 |
+
|
88 |
const contentDiv = document.createElement('div');
|
89 |
contentDiv.className = 'message-content';
|
90 |
contentDiv.textContent = message;
|
91 |
+
|
92 |
messageDiv.appendChild(contentDiv);
|
93 |
chatWindow.appendChild(messageDiv);
|
94 |
chatWindow.scrollTop = chatWindow.scrollHeight;
|
|
|
170 |
});
|
171 |
|
172 |
|
173 |
+
document.addEventListener('DOMContentLoaded', function() {
|
174 |
+
// Load the intro content
|
175 |
+
fetch('./intro.html')
|
176 |
+
.then(response => response.text())
|
177 |
+
.then(html => {
|
178 |
+
document.getElementById('introContent').innerHTML = html;
|
179 |
+
});
|
180 |
+
|
181 |
+
// Show popup after content is loaded
|
182 |
+
setTimeout(() => {
|
183 |
+
const popup = document.getElementById('gamePopup');
|
184 |
+
popup.style.display = 'block';
|
185 |
+
}, 2000);
|
186 |
+
|
187 |
+
// Show game over popup after 5 seconds
|
188 |
+
//setTimeout(() => {
|
189 |
+
// const gameOverPopup = document.getElementById('gameOverPopup');
|
190 |
+
// gameOverPopup.style.display = 'block';
|
191 |
+
// }, 5000);
|
192 |
+
|
193 |
+
// Initialize game popup controls
|
194 |
+
const popup = document.getElementById('gamePopup');
|
195 |
+
const minimizeBtn = popup.querySelector('.minimize');
|
196 |
+
const maximizeBtn = popup.querySelector('.maximize');
|
197 |
+
const closeBtn = popup.querySelector('.close');
|
198 |
+
const okBtn = popup.querySelector('.popup-ok');
|
199 |
+
|
200 |
+
minimizeBtn.addEventListener('click', () => {
|
201 |
+
popup.classList.add('minimized');
|
202 |
+
});
|
203 |
+
|
204 |
+
maximizeBtn.addEventListener('click', () => {
|
205 |
+
popup.classList.remove('minimized');
|
206 |
+
});
|
207 |
+
|
208 |
+
closeBtn.addEventListener('click', () => {
|
209 |
+
popup.style.display = 'none';
|
210 |
+
});
|
211 |
+
|
212 |
+
okBtn.addEventListener('click', () => {
|
213 |
+
popup.classList.add('minimized');
|
214 |
+
});
|
215 |
+
|
216 |
+
// Make the popup draggable
|
217 |
+
const header = popup.querySelector('.popup-header');
|
218 |
+
let isDragging = false;
|
219 |
+
let currentX;
|
220 |
+
let currentY;
|
221 |
+
let initialX;
|
222 |
+
let initialY;
|
223 |
+
let xOffset = 0;
|
224 |
+
let yOffset = 0;
|
225 |
+
|
226 |
+
header.addEventListener('mousedown', dragStart);
|
227 |
+
document.addEventListener('mousemove', drag);
|
228 |
+
document.addEventListener('mouseup', dragEnd);
|
229 |
+
|
230 |
+
function dragStart(e) {
|
231 |
+
initialX = e.clientX - xOffset;
|
232 |
+
initialY = e.clientY - yOffset;
|
233 |
+
|
234 |
+
if (e.target === header) {
|
235 |
+
isDragging = true;
|
236 |
+
}
|
237 |
+
}
|
238 |
+
|
239 |
+
function drag(e) {
|
240 |
+
if (isDragging) {
|
241 |
+
e.preventDefault();
|
242 |
+
currentX = e.clientX - initialX;
|
243 |
+
currentY = e.clientY - initialY;
|
244 |
+
xOffset = currentX;
|
245 |
+
yOffset = currentY;
|
246 |
+
|
247 |
+
setTranslate(currentX, currentY, popup);
|
248 |
+
}
|
249 |
+
}
|
250 |
+
|
251 |
+
function setTranslate(xPos, yPos, el) {
|
252 |
+
el.style.transform = `translate(${xPos}px, ${yPos}px)`;
|
253 |
+
}
|
254 |
+
|
255 |
+
function dragEnd() {
|
256 |
+
initialX = currentX;
|
257 |
+
initialY = currentY;
|
258 |
+
isDragging = false;
|
259 |
+
}
|
260 |
+
|
261 |
+
// Initialize game over popup controls
|
262 |
+
const gameOverPopup = document.getElementById('gameOverPopup');
|
263 |
+
const gameOverCloseBtn = gameOverPopup.querySelector('.close');
|
264 |
+
const gameOverOkBtn = gameOverPopup.querySelector('.popup-ok');
|
265 |
+
|
266 |
+
gameOverCloseBtn.addEventListener('click', () => {
|
267 |
+
location.reload(); // Reload page on close
|
268 |
+
});
|
269 |
+
|
270 |
+
gameOverOkBtn.addEventListener('click', () => {
|
271 |
+
location.reload(); // Reload page on Try Again
|
272 |
+
});
|
273 |
+
});
|
274 |
+
|
275 |
+
|
276 |
// ============================
|
277 |
// AJOUT : GESTION DE LA CARTE SVG
|
278 |
// ============================
|
|
|
945 |
} else {
|
946 |
path.setAttribute('fill', 'red');
|
947 |
}
|
948 |
+
|
949 |
// Optionnel : ajout d'un survol ou d'un clic pour modifier l'attribut
|
950 |
// path.addEventListener('click', () => {
|
951 |
// // Ex: toggler la valeur Yes/No puis changer la couleur
|
952 |
// });
|
953 |
+
|
954 |
svgContainer.appendChild(path);
|
955 |
}
|
956 |
});
|
static/styles.css
CHANGED
@@ -11,24 +11,6 @@ body {
|
|
11 |
color: #fff;
|
12 |
}
|
13 |
|
14 |
-
/* ====================================
|
15 |
-
NOUVEAU : la colonne de droite (carte)
|
16 |
-
==================================== */
|
17 |
-
.map-container {
|
18 |
-
width: 50%;
|
19 |
-
height: 100vh;
|
20 |
-
background-color: #fff; /* fond blanc */
|
21 |
-
overflow: auto; /* permet de scroller si besoin */
|
22 |
-
}
|
23 |
-
|
24 |
-
.map-container svg {
|
25 |
-
width: 100%;
|
26 |
-
height: 100%;
|
27 |
-
}
|
28 |
-
|
29 |
-
/* ====================================
|
30 |
-
Colonne de gauche : Chatbot (inchangé)
|
31 |
-
==================================== */
|
32 |
.content {
|
33 |
flex: 1;
|
34 |
background-color: #fff;
|
@@ -71,6 +53,18 @@ body {
|
|
71 |
display: none;
|
72 |
}
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
.message {
|
75 |
display: flex;
|
76 |
margin-bottom: 15px;
|
@@ -210,3 +204,159 @@ body {
|
|
210 |
background-color: #2f3336;
|
211 |
margin-top: 16px;
|
212 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
color: #fff;
|
12 |
}
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
.content {
|
15 |
flex: 1;
|
16 |
background-color: #fff;
|
|
|
53 |
display: none;
|
54 |
}
|
55 |
|
56 |
+
.map-container {
|
57 |
+
width: 50%;
|
58 |
+
height: 100vh;
|
59 |
+
background-color: #fff; /* fond blanc */
|
60 |
+
overflow: auto; /* permet de scroller si besoin */
|
61 |
+
}
|
62 |
+
|
63 |
+
.map-container svg {
|
64 |
+
width: 100%;
|
65 |
+
height: 100%;
|
66 |
+
}
|
67 |
+
|
68 |
.message {
|
69 |
display: flex;
|
70 |
margin-bottom: 15px;
|
|
|
204 |
background-color: #2f3336;
|
205 |
margin-top: 16px;
|
206 |
}
|
207 |
+
|
208 |
+
.popup {
|
209 |
+
display: none;
|
210 |
+
position: fixed;
|
211 |
+
top: 50%;
|
212 |
+
left: 50%;
|
213 |
+
transform: translate(-50%, -50%);
|
214 |
+
width: 400px;
|
215 |
+
background-color: #fff3e0;
|
216 |
+
border-radius: 8px;
|
217 |
+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
|
218 |
+
z-index: 1000;
|
219 |
+
transition: all 0.3s ease;
|
220 |
+
}
|
221 |
+
|
222 |
+
.popup.minimized {
|
223 |
+
top: unset;
|
224 |
+
bottom: 20px;
|
225 |
+
right: 20px;
|
226 |
+
left: unset;
|
227 |
+
transform: none;
|
228 |
+
width: 200px;
|
229 |
+
height: 32px;
|
230 |
+
overflow: hidden;
|
231 |
+
background-color: #1da1f2;
|
232 |
+
}
|
233 |
+
|
234 |
+
.popup.minimized .popup-content {
|
235 |
+
display: none;
|
236 |
+
}
|
237 |
+
|
238 |
+
.popup.minimized .popup-header {
|
239 |
+
padding: 4px 8px;
|
240 |
+
height: 32px;
|
241 |
+
}
|
242 |
+
|
243 |
+
.popup-header {
|
244 |
+
background-color: #1da1f2;
|
245 |
+
color: white;
|
246 |
+
padding: 8px 12px;
|
247 |
+
display: flex;
|
248 |
+
justify-content: space-between;
|
249 |
+
align-items: center;
|
250 |
+
border-radius: 8px 8px 0 0;
|
251 |
+
cursor: move;
|
252 |
+
}
|
253 |
+
|
254 |
+
.popup-controls {
|
255 |
+
display: flex;
|
256 |
+
gap: 5px;
|
257 |
+
}
|
258 |
+
|
259 |
+
.control-btn {
|
260 |
+
background: none;
|
261 |
+
border: none;
|
262 |
+
color: white;
|
263 |
+
cursor: pointer;
|
264 |
+
width: 24px;
|
265 |
+
height: 24px;
|
266 |
+
display: flex;
|
267 |
+
align-items: center;
|
268 |
+
justify-content: center;
|
269 |
+
border-radius: 4px;
|
270 |
+
}
|
271 |
+
|
272 |
+
.control-btn:hover {
|
273 |
+
background-color: rgba(255, 255, 255, 0.2);
|
274 |
+
}
|
275 |
+
|
276 |
+
.popup-content {
|
277 |
+
padding: 20px;
|
278 |
+
display: flex;
|
279 |
+
flex-direction: column;
|
280 |
+
align-items: center;
|
281 |
+
gap: 15px;
|
282 |
+
color: #000;
|
283 |
+
}
|
284 |
+
|
285 |
+
.popup-gif {
|
286 |
+
max-width: 100%;
|
287 |
+
height: auto;
|
288 |
+
}
|
289 |
+
|
290 |
+
.popup-ok {
|
291 |
+
background-color: #1da1f2;
|
292 |
+
color: white;
|
293 |
+
border: none;
|
294 |
+
padding: 8px 24px;
|
295 |
+
border-radius: 20px;
|
296 |
+
cursor: pointer;
|
297 |
+
font-size: 14px;
|
298 |
+
}
|
299 |
+
|
300 |
+
.popup-ok:hover {
|
301 |
+
background-color: #1a91da;
|
302 |
+
}
|
303 |
+
|
304 |
+
#gameOverPopup {
|
305 |
+
width: fit-content;
|
306 |
+
}
|
307 |
+
|
308 |
+
#gameOverPopup .popup-content {
|
309 |
+
padding: 0;
|
310 |
+
gap: 5px;
|
311 |
+
}
|
312 |
+
|
313 |
+
#gameOverPopup .popup-gif {
|
314 |
+
display: block;
|
315 |
+
width: 600px;
|
316 |
+
height: 300px;
|
317 |
+
margin: 0;
|
318 |
+
}
|
319 |
+
|
320 |
+
#gameOverPopup .popup-header {
|
321 |
+
padding: 5px 10px;
|
322 |
+
}
|
323 |
+
|
324 |
+
#gameOverPopup .popup-ok {
|
325 |
+
margin: 5px 0;
|
326 |
+
}
|
327 |
+
|
328 |
+
.intro-frame {
|
329 |
+
width: 800px;
|
330 |
+
height: 650px;
|
331 |
+
border: none;
|
332 |
+
overflow: hidden;
|
333 |
+
background-color: transparent;
|
334 |
+
margin: 0;
|
335 |
+
padding: 0;
|
336 |
+
}
|
337 |
+
|
338 |
+
#gamePopup {
|
339 |
+
width: auto;
|
340 |
+
background-color: transparent;
|
341 |
+
padding: 0;
|
342 |
+
}
|
343 |
+
|
344 |
+
#gamePopup .popup-content {
|
345 |
+
padding: 0;
|
346 |
+
position: relative;
|
347 |
+
}
|
348 |
+
|
349 |
+
#gamePopup .popup-ok {
|
350 |
+
position: absolute;
|
351 |
+
bottom: 200px;
|
352 |
+
left: 50%;
|
353 |
+
transform: translateX(-50%);
|
354 |
+
z-index: 1000;
|
355 |
+
background-color: rgba(29, 161, 242, 0.8);
|
356 |
+
padding: 12px 30px;
|
357 |
+
font-size: 16px;
|
358 |
+
}
|
359 |
+
|
360 |
+
#gamePopup .popup-ok:hover {
|
361 |
+
background-color: rgba(29, 161, 242, 1);
|
362 |
+
}
|