-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
31 lines (27 loc) · 1.41 KB
/
main.js
File metadata and controls
31 lines (27 loc) · 1.41 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
// This file serves as the entry point for the JavaScript functionality of the mobile webpage project.
// It initializes the components and handles screen orientation changes to display the appropriate functions.
import Alarm from './components/Alarm.js';
import Timer from './components/Timer.js';
import Stopwatch from './components/Stopwatch.js';
import Weather from './components/Weather.js';
const alarm = new Alarm();
const timer = new Timer();
const stopwatch = new Stopwatch();
const weather = new Weather();
function handleOrientationChange() {
if (window.innerHeight > window.innerWidth) {
// Portrait mode: Show Alarm and Timer
document.getElementById('alarm-section').style.display = 'block';
document.getElementById('timer-section').style.display = 'block';
document.getElementById('stopwatch-section').style.display = 'none';
document.getElementById('weather-section').style.display = 'none';
} else {
// Landscape mode: Show Stopwatch and Weather
document.getElementById('alarm-section').style.display = 'none';
document.getElementById('timer-section').style.display = 'none';
document.getElementById('stopwatch-section').style.display = 'block';
document.getElementById('weather-section').style.display = 'block';
}
}
window.addEventListener('resize', handleOrientationChange);
window.addEventListener('load', handleOrientationChange);