-
-
Notifications
You must be signed in to change notification settings - Fork 202
Expand file tree
/
Copy pathindex.html
More file actions
772 lines (636 loc) · 30.2 KB
/
Copy pathindex.html
File metadata and controls
772 lines (636 loc) · 30.2 KB
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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description"
content="A Beautiful weather app displaying a weekly weather forecast for the selected location" />
<title id="dynamic">Weather-App</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@100;200;300;400;500;600;700;800;900&family=Work+Sans:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
<!-- favicon -->
<link rel="shortcut icon" type="image/jpg" href="./assets/weather-icon.png" />
<link rel="icon" href="assets/favicon.ico">
<!-- Stylesheets -->
<link rel="stylesheet" href="./assets/css/bootstrap.min.css">
<link rel="stylesheet" href="./assets/css/style.css">
<link rel="stylesheet" href="./assets/css/styles.css">
<link rel="stylesheet" href="./assets/css/theme.css">
<link rel="stylesheet" href="./assets/css/globe-styles.css">
<!-- Font Awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<!-- Leaflet CSS -->
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin=""/>
</head>
<body id="body">
<nav class="navbar top-nav">
<div class="logo" style="display: flex; align-items: center; gap: 10px;">
<img src="./assets/icons/logo.png" alt="Logo" class="img-fluid logo-img">
<span class="logo-title">Weather Dashboard</span>
</div>
<div class="nav-controls">
<div class="control theme-control">
<div class="theme-toggle-wrapper">
<button id="theme-toggle" class="theme-toggle-btn"
aria-label="Toggle dark/light mode"
title="Toggle dark/light mode"
role="switch"
aria-pressed="false">
<div class="theme-indicator" aria-hidden="true"></div>
</button>
<div class="theme-toggle-label">Light</div>
</div>
</div>
<div class="control whatsapp-control">
<i class="whatsapp" id="whatsapp-button">
<img src="assets/Whatsapp-logo.svg" alt="whatsapp">
</i>
</div>
<div class="control unit-control">
<div class="nav-component__celcius-block col-auto">
<input type="checkbox" id="unit" class="checkbox" checked>
<label for="unit" class="label" title="Toggle temperature unit">
<span class="farenheit">°F</span>
<span class="celcius">°C</span>
<div class='ball'></div>
</label>
<div class="unit-toggle-label">°C</div>
</div>
</div>
</div>
</nav>
<div id="background"></div>
<h2 class="header-component">
<div id="date-time-container">
<span id='date-time'></span>
<span id='date-time2'></span>
</div>
</h2>
<section>
<div class="container">
<div class="row g-4">
<div class="col">
</div>
<div class="col">
</div>
</section>
<section class="pt-4 card-grid">
<div class="container">
<div class="row justify-content-center">
<div class="col-12 col-md-10 col-lg-8">
<div class="weather-component container d-flex justify-content-center align-items-center flex-column">
<div class="weather-component__card text-white rounded-5" style="padding-top: 50px;">
<div class="weather-component__search" style="margin-left: 1rem;">
<input type="text" class="weather-component__search-bar" name="search-bar" list="place"
placeholder="Search for a city, e.g., London" autocomplete="address-level2" />
<datalist id="place" class="weather-component__datalist">
<!-- Content will be generated By Javascript -->
</datalist>
<div class="button_container" style="margin-left: 1rem;">
<button class="weather-component__button text-white rounded-circl"
aria-label="click here to search class" style="margin-top: 0.5rem; margin-right: -0.1rem;">
<svg stroke="currentColor" fill="#ffffff" stroke-width="0" viewBox="0 0 1024 1024" height="1.5em"
width="1.5em" xmlns="http://www.w3.org/2000/svg">
<path
d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0 0 11.6 0l43.6-43.5a8.2 8.2 0 0 0 0-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z">
</path>
</svg>
</button>
<button class="weather-component__button-microphone voice-command-btn" aria-label="speak" id="microphone-button" title="Ask me about weather!">
<svg style="color: white" xmlns="http://www.w3.org/2000/svg" width="20" height="20"
fill="#ffffff" class="bi bi-mic" viewBox="0 0 16 16">
<path
d="M3.5 6.5A.5.5 0 0 1 4 7v1a4 4 0 0 0 8 0V7a.5.5 0 0 1 1 0v1a5 5 0 0 1-4.5 4.975V15h3a.5.5 0 0 1 0 1h-7a.5.5 0 0 1 0-1h3v-2.025A5 5 0 0 1 3 8V7a.5.5 0 0 1 .5-.5z"
fill="#ffffff"></path>
<path d="M10 8a2 2 0 1 1-4 0V3a2 2 0 1 1 4 0v5zM8 0a3 3 0 0 0-3 3v5a3 3 0 0 0 6 0V3a3 3 0 0 0-3-3z"
fill="#ffffff"></path>
</svg>
</button>
<div class="voice-status" id="voice-status"></div>
</div>
<div id="error-message" class="error-message" role="alert" aria-live="polite" hidden></div>
</div>
<!-- Interactive Map (Leaflet + Esri World Imagery) -->
<div class="map-box">
<div class="map-city-label" id="map-city-label"></div>
<div id="weather-map"></div>
</div>
<div id="weather" class="weather-component__data loading">
<h1 id="city" class="weather-component__city-name fw-bold">___</h1>
<h2 id="temp" class="weather-component__city-temperature fw-bold display-1">32°C</h2>
<div class="weather-component__data-wrapper">
<!-- weather icon + description -->
<figure class="weather-component__icn">
<i id="icon" class="fas fa-cloud fa-3x"></i>
<figcaption class="text-capitalize text-wrap" id="description">___</figcaption>
</figure>
<!-- 2x2 grid -->
<div class="weather-component__grid" id="weather-details-grid">
<!-- Humidity -->
<div class="grid-item">
<div class="heading">
<h6>Humidity</h6>
<i class="fa-solid fa-droplet"></i>
</div>
<div class="data">
<span id="humidity" class="data-value">60%</span>
</div>
</div>
<!-- Wind -->
<div class="grid-item">
<div class="heading">
<h6>Wind Speed</h6>
<i class="fa-solid fa-flag"></i>
</div>
<div class="data">
<span id="wind" class="data-value">6.2 km/h</span>
</div>
</div>
<!-- UV Index -->
<div class="grid-item grid-item-uvi">
<div class="heading">
<h6>UV Index</h6>
<i class="fa-solid fa-shield-sun"></i>
</div>
<div class="data">
<span id="uvi" class="data-value">0</span>
<p id="uvi-text" class="uvi-description">Low</p>
</div>
</div>
<!-- Air Quality -->
<div class="grid-item-air-quality">
<div class="heading">
<h6>Air Quality</h6>
<i class="fa-solid fa-wind"></i>
</div>
<span id="AirQuality" class="data-value">75</span>
<span class="air-quality-label"></span>
</div>
<!-- Sunrise & Sunset -->
<div class="grid-item-sun">
<div class="sunrise">
<div class="heading">
<h6>Sunrise</h6>
<i class="fa-solid fa-sun"></i>
</div>
<span id="sunrise" class="data-value">5:00 AM</span>
</div>
<div class="sunset">
<div class="heading">
<h6>Sunset</h6>
<i class="fa-solid fa-moon"></i>
</div>
<span id="sunset" class="data-value">6:00 PM</span>
</div>
</div>
</div>
</div>
<div class="last-updated" id="last-updated">
<!-- Last updated time will be inserted here -->
</div>
<!-- <div class="weather-component__data-wrapper">
<div class="weather-component__desc-primary">
<div class="weather-component__desc-secondary d-flex ">
<div class="d-flex flex-1 flex-column" style="margin-top: 10px;">
<figure class="d-flex flex-1 flex-row humidity ms-0">
<img src="./assets/icons/humidity.png" alt="Humidity" class="humidity-img">
<figcaption id="humidity"><a href="https://en.wikipedia.org/wiki/Humidity">Humidity</a>: 60%
</figcaption>
</figure>
<div class="d-flex flex-1 flex-row wind ms-0"><img src="./assets/icons/wind.png" alt="Wind Speed"
class="wind-img">
<div id="wind"><a href="https://en.wikipedia.org/wiki/Wind_speed">Wind speed</a>: 6.2 km/h
</div>
</div>
</div>
<div class="d-flex flex-1 flex-column">
<div class="class 1">
<div class="weather-component__AQI" style="display: flex; flex-direction: column;">
<div id="AirQuality">Air Quality: 75
</div>
<div class="air-quality-label ml-0">Satisfactory</div>
</div>
</div>
</div>
<div class="class2">
<figure class="d-flex flex-1 flex-row sunrise me-0 justify-content-end">
<img src="./assets/icons/sunrise (2).png" alt="Sunrise" class="sunrise-img">
<figcaption id="sunrise"><a href="https://en.wikipedia.org/wiki/Sunrise">Sunrise</a>:5:00AM
</figcaption>
</figure>
<figure class="d-flex flex-1 flex-row sunset me-0 justify-content-end"><img
src="./assets/icons/sunset (1).png" alt="Sunset" class="sunset-img">
<figcaption id="sunset" style="margin-right: 0.65rem;"><a href="https://en.wikipedia.org/wiki/Sunset">Sunset</a>:6:00AM
</figcaption>
</figure>
</div>
</div>
</div>
</div> -->
</div>
</div>
</div>
</div>
<!-- Commenting out the Forecast cards since they were not visible in the final site as well. will incorporate them seperately in future builds -->
<!-- <div class="col" style="margin-top: 3.5rem;">
<div class="forecast-component p-2 overflow-hidden text-white w-100">
<div class="forecast-component__items-wrapper transition overflow-hidden " id="weather-forecast">
<div class="forecast-component__item rounded text-center" id="weather-forecast-item">
<div>Mon</div>
<figure class="forecast-img">
<img src="http://openweathermap.org/img/wn/10d@2x.png" alt="weather icon">
</figure>
<div>Day - 35.6° C</div>
<div>Night - 25.6° C</div>
<div>view more</div>
</div>
</div>
</div>
</div> -->
</section>
<!-- Weather Mood Recommendations Section -->
<section class="mood-section pt-4">
<div class="container">
<div class="row justify-content-center">
<div class="col-12 col-md-10 col-lg-8">
<div class="mood-recommendations-card text-white rounded-5">
<h3 class="text-center mb-3">🌟 Weather Mood & Activity Suggestions</h3>
<div id="mood-recommendations" class="mood-content">
<div class="mood-loading">Analyzing weather conditions for personalized suggestions...</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Weather Time Machine Section -->
<section class="time-machine-section pt-4">
<div class="container">
<div class="row justify-content-center">
<div class="col-12 col-md-10 col-lg-8">
<div class="time-machine-card text-white rounded-5">
<h3 class="text-center mb-3">⏰ Weather Time Machine</h3>
<div class="time-machine-controls text-center mb-3">
<button id="time-machine-btn" class="btn btn-primary me-2">View This Day in History</button>
<select id="year-selector" class="form-select d-inline-block w-auto">
<option value="2024">2024</option>
<option value="2023">2023</option>
<option value="2022">2022</option>
<option value="2021">2021</option>
<option value="2020">2020</option>
<option value="2019">2019</option>
<option value="2018">2018</option>
<option value="2017">2017</option>
<option value="2016">2016</option>
<option value="2015">2015</option>
</select>
</div>
<div id="historical-weather" class="historical-content">
<div class="historical-placeholder">Select a year to explore weather history!</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Interactive 3D Weather Globe Section -->
<section class="globe-section pt-4">
<div class="container">
<div class="row justify-content-center">
<div class="col-12 col-md-10 col-lg-8">
<div class="globe-card text-white rounded-5">
<h3 class="text-center mb-3">🌍 Interactive 3D Weather Globe</h3>
<div id="globe-container" class="globe-container">
<div id="globeViz" class="globe-visualization"></div>
<!-- Globe Controls -->
<div class="controls-card mt-4">
<div class="globe-controls">
<button class="globe-btn active" data-region="americas">🌎 Americas</button>
<button class="globe-btn" data-region="europe">🌍 Europe</button>
<button class="globe-btn" data-region="asia">🌏 Asia</button>
<button class="globe-btn" data-region="africa">🌍 Africa</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Scripts for 3D Globe -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script>
// Load OrbitControls dynamically
function loadOrbitControls() {
return new Promise((resolve, reject) => {
const script = document.createElement('script');
script.src = 'https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/controls/OrbitControls.js';
script.onload = () => {
// Check if OrbitControls is available
if (window.THREE && window.THREE.OrbitControls) {
resolve(window.THREE.OrbitControls);
} else {
reject(new Error('OrbitControls not found'));
}
};
script.onerror = reject;
document.head.appendChild(script);
});
}
document.addEventListener('DOMContentLoaded', async function() {
const container = document.getElementById('globeViz');
if (!container) return;
// Set up Three.js scene
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, container.clientWidth / container.clientHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
renderer.setSize(container.clientWidth, container.clientHeight);
container.innerHTML = ''; // Clear previous content
container.appendChild(renderer.domElement);
// Create the Earth
const earthGeometry = new THREE.SphereGeometry(1, 64, 64);
// Handle texture loading with error fallback
const textureLoader = new THREE.TextureLoader();
// Load Earth textures with error handling
let earthTexture, earthBump;
try {
earthTexture = textureLoader.load('https://cdn.jsdelivr.net/npm/three-globe/example/img/earth-blue-marble.jpg');
} catch (e) {
console.warn('Failed to load earth texture, using default material');
earthTexture = null;
}
try {
earthBump = textureLoader.load('https://cdn.jsdelivr.net/npm/three-globe/example/img/earth-topology.png');
} catch (e) {
console.warn('Failed to load bump map, using default material');
earthBump = null;
}
const earthMaterial = new THREE.MeshPhongMaterial({
map: earthTexture || new THREE.Color(0x2233ff),
bumpMap: earthBump,
bumpScale: 0.05
});
const earthMesh = new THREE.Mesh(earthGeometry, earthMaterial);
scene.add(earthMesh);
// Add clouds layer with rotation effect
const CLOUDS_IMG_URL = 'https://cdn.jsdelivr.net/npm/three-globe/example/img/earth-clouds.png';
const CLOUDS_ALT = 0.004;
const CLOUDS_ROTATION_SPEED = -0.006; // deg/frame
textureLoader.load(CLOUDS_IMG_URL,
// onLoad callback
(cloudsTexture) => {
const clouds = new THREE.Mesh(
new THREE.SphereGeometry(earthGeometry.parameters.radius * (1 + CLOUDS_ALT), 75, 75),
new THREE.MeshPhongMaterial({ map: cloudsTexture, transparent: true })
);
scene.add(clouds);
// Add rotation animation for clouds
(function rotateClouds() {
clouds.rotation.y += CLOUDS_ROTATION_SPEED * Math.PI / 180;
requestAnimationFrame(rotateClouds);
})();
},
// onProgress callback
undefined,
// onError callback
(err) => {
console.warn('Failed to load clouds texture:', err);
}
);
// Add atmosphere effect
const atmosphereGeometry = new THREE.SphereGeometry(1.02, 64, 64);
const atmosphereMaterial = new THREE.MeshPhongMaterial({
color: 0x3399ff,
transparent: true,
opacity: 0.1
});
const atmosphereMesh = new THREE.Mesh(atmosphereGeometry, atmosphereMaterial);
scene.add(atmosphereMesh);
// Add lighting
const ambientLight = new THREE.AmbientLight(0x333333);
scene.add(ambientLight);
const sunLight = new THREE.DirectionalLight(0xffffff, 1);
sunLight.position.set(5, 3, 5);
scene.add(sunLight);
// Position camera
camera.position.z = 2.5;
// Add orbit controls
let controls;
try {
const OrbitControls = await loadOrbitControls();
controls = new OrbitControls(camera, renderer.domElement);
controls.enableDamping = true;
controls.dampingFactor = 0.05;
controls.autoRotate = true;
controls.autoRotateSpeed = 0.35; // Match the requested speed
} catch (error) {
console.warn('Failed to load OrbitControls, using basic rotation only:', error);
}
// Add weather markers
const markersGroup = new THREE.Group();
scene.add(markersGroup);
// Create initial markers for major cities
const cities = [
{ name: 'New York', lat: 40.7128, lng: -74.0060, color: 0x00ff7f },
{ name: 'London', lat: 51.5074, lng: -0.1278, color: 0xff9900 },
{ name: 'Tokyo', lat: 35.6762, lng: 139.6503, color: 0xff4444 },
{ name: 'Sydney', lat: -33.8688, lng: 151.2093, color: 0x4488ff },
{ name: 'São Paulo', lat: -23.5505, lng: -46.6333, color: 0xff44ff },
{ name: 'Cairo', lat: 30.0444, lng: 31.2357, color: 0xffff00 }
];
cities.forEach(city => {
const markerGeometry = new THREE.SphereGeometry(0.02, 16, 16);
const markerMaterial = new THREE.MeshBasicMaterial({ color: city.color });
const marker = new THREE.Mesh(markerGeometry, markerMaterial);
// Convert lat/lng to 3D position
const phi = (90 - city.lat) * Math.PI / 180;
const theta = (city.lng + 180) * Math.PI / 180;
marker.position.set(
-Math.sin(phi) * Math.cos(theta),
Math.cos(phi),
Math.sin(phi) * Math.sin(theta)
);
marker.userData = { name: city.name };
markersGroup.add(marker);
});
// Animation loop
function animate() {
requestAnimationFrame(animate);
// Rotate earth
earthMesh.rotation.y += 0.0003;
if (controls) {
controls.update();
}
renderer.render(scene, camera);
}
// Handle window resize
window.addEventListener('resize', function() {
camera.aspect = container.clientWidth / container.clientHeight;
camera.updateProjectionMatrix();
renderer.setSize(container.clientWidth, container.clientHeight);
});
// Start animation
animate();
// Function to update globe with weather data
function updateGlobeWithWeatherData(event) {
if (!event.detail || !event.detail.lat || !event.detail.lon) return;
const weatherData = event.detail;
// Create a new marker for the current city
const markerGeometry = new THREE.SphereGeometry(0.03, 16, 16);
// Temperature-based color
let color = 0x00aaff; // Default blue
if (weatherData.temp > 30) color = 0xff4444; // Hot - Red
else if (weatherData.temp > 20) color = 0xff9900; // Warm - Orange
else if (weatherData.temp > 10) color = 0x00ff7f; // Mild - Green
else if (weatherData.temp > 0) color = 0x4488ff; // Cool - Blue
const markerMaterial = new THREE.MeshBasicMaterial({ color: color });
const marker = new THREE.Mesh(markerGeometry, markerMaterial);
// Convert lat/lng to 3D position
const phi = (90 - weatherData.lat) * Math.PI / 180;
const theta = (weatherData.lon + 180) * Math.PI / 180;
marker.position.set(
-Math.sin(phi) * Math.cos(theta),
Math.cos(phi),
Math.sin(phi) * Math.sin(theta)
);
marker.userData = {
name: weatherData.city,
temp: weatherData.temp,
description: weatherData.description
};
// Remove any existing marker for this city
let existingIndex = -1;
for (let i = 0; i < markersGroup.children.length; i++) {
if (markersGroup.children[i].userData.name === weatherData.city) {
existingIndex = i;
break;
}
}
if (existingIndex >= 0) {
markersGroup.remove(markersGroup.children[existingIndex]);
}
markersGroup.add(marker);
}
// Listen for weather updates
document.addEventListener('weatherUpdate', updateGlobeWithWeatherData);
// Region focus functions
function focusOnRegion(region) {
let targetLat = 0, targetLng = 0;
switch(region) {
case 'americas':
targetLat = 20;
targetLng = -100;
break;
case 'europe':
targetLat = 50;
targetLng = 10;
break;
case 'asia':
targetLat = 30;
targetLng = 100;
break;
case 'africa':
targetLat = 0;
targetLng = 20;
break;
default:
return;
}
// Convert lat/lng to 3D position for camera
const phi = (90 - targetLat) * Math.PI / 180;
const theta = (targetLng + 180) * Math.PI / 180;
const targetX = -Math.sin(phi) * Math.cos(theta) * 2.5;
const targetY = Math.cos(phi) * 2.5;
const targetZ = Math.sin(phi) * Math.sin(theta) * 2.5;
// Animate camera to new position (simplified animation)
camera.position.set(targetX, targetY, targetZ);
camera.lookAt(0, 0, 0);
}
// Add event listeners to region buttons
document.querySelectorAll('.globe-btn').forEach(btn => {
btn.addEventListener('click', function() {
const region = this.getAttribute('data-region');
focusOnRegion(region);
// Update active button
document.querySelectorAll('.globe-btn').forEach(b => b.classList.remove('active'));
this.classList.add('active');
});
});
});
</script>
</section>
<!-- Toast Notification -->
<div id="toast" class="toast" role="status" aria-live="polite" aria-atomic="true" aria-hidden="true">
<div class="toast-content" role="group" aria-label="Notification">
<div class="toast-icon" aria-hidden="true">🔔</div>
<div id="toast-message" class="toast-message"></div>
<button id="toast-close" class="toast-close" aria-label="Close notification">
<span aria-hidden="true">×</span>
</button>
</div>
</div>
<!-- Weather Alerts Section -->
<div class="weather-alerts-container" id="weather-alerts">
<!-- Dynamic weather alerts will be inserted here -->
</div>
<!-- Weather Safety Tips Modal -->
<div class="modal-overlay" id="safety-modal-overlay" style="display: none;">
<div class="safety-modal">
<div class="modal-header">
<h3>⚠️ Weather Safety Tips</h3>
<button class="close-modal" id="close-safety-modal">×</button>
</div>
<div class="modal-content" id="safety-modal-content">
<!-- Dynamic safety tips will be inserted here -->
</div>
</div>
</div>
<footer>
<!-- <a href="#top" class="smoothscroll scroll-top">
<span class="icon-keyboard_arrow_up"></span>
</a> -->
<a href="#top" class="smoothscroll scroll-top">
<span class="icon-keyboard_arrow_up">⇧</span>
</a>
<div>
<h2 class="textfooter">
Made with 💝 Avinash Singh
</h2>
<div class="footerSection">
<ul style="list-style: none;margin:0;padding:0;color: white; display: inline-flex;">
<li>
<a href="https://github.com/avinash201199" target="_blank">
<i class="socialIcons fab fa-github fa-3x link1"></i>
</li>
<li>
<a href="https://www.linkedin.com/in/avinash-singh-bb0b8a371/" target="_blank">
<i class="fab fa-linkedin-in fa-3x link2"></i>
</li>
<li>
<a href="https://www.instagram.com/lets__code/" target="_blank">
<i class="fab fa-instagram fa-3x link3"></i>
</li>
<li>
<a href="https://twitter.com/Lets__Code/" target="_blank">
<i class="fa-brands fa-x-twitter fa-3x link4"></i>
</li>
</ul>
</div>
</div>
</footer>
<!-- jquery CDN -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.slim.min.js"
integrity="sha512-yBpuflZmP5lwMzZ03hiCLzA94N0K2vgBtJgqQ2E1meJzmIBfjbb7k4Y23k2i2c/rIeSUGc7jojyIY5waK3ZxCQ=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<!-- popper CDN -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"></script>
<!-- moment CDN -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"
integrity="sha512-qTXRIMyZIFb8iQjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<!-- Leaflet JS -->
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script>
<script type="module" src="./assets/js/script.js"></script>
</body>
</html>