-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
132 lines (124 loc) · 5.32 KB
/
index.html
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
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Timer Bollitore</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
margin: 0;
background-color: #f0f0f0;
}
.container {
text-align: center;
background-color: white;
padding: 2rem;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.timer {
font-size: 3rem;
margin: 1rem 0;
}
.message {
font-size: 1.5rem;
margin: 1rem 0;
color: #333;
}
button {
font-size: 1.2rem;
padding: 0.5rem 2rem;
margin: 0.5rem;
border: none;
border-radius: 5px;
background-color: #4CAF50;
color: white;
cursor: pointer;
transition: background-color 0.3s;
}
button:disabled {
background-color: #cccccc;
cursor: not-allowed;
}
button:hover:not(:disabled) {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="container">
<h1>Timer Bollitore</h1>
<div class="timer" id="timer">06:00</div>
<div class="message" id="message">Premi Start per iniziare</div>
<button id="startBtn">Start</button>
<button id="coolBtn" disabled>Raffreddamento</button>
<audio id="boilingSound">
<source src="data:audio/mpeg;base64,SUQzBAAAAAAAI1RTU0UAAAAPAAADTGF2ZjU4LjI5LjEwMAAAAAAAAAAAAAAA//OEAAAAAAAAAAAAAAAAAAAAAAAASW5mbwAAAA8AAAAUAAAfkAAG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>
let timer;
let timeLeft;
let phase = 'idle'; // idle, boiling, cooling
const startBtn = document.getElementById('startBtn');
const coolBtn = document.getElementById('coolBtn');
const timerDisplay = document.getElementById('timer');
const messageDisplay = document.getElementById('message');
const boilingSound = document.getElementById('boilingSound');
function startTimer(seconds, phase) {
timeLeft = seconds;
updateDisplay();
timer = setInterval(() => {
timeLeft--;
updateDisplay();
if (timeLeft === 0) {
clearInterval(timer);
handlePhaseComplete(phase);
}
}, 1000);
}
function updateDisplay() {
const minutes = Math.floor(timeLeft / 60);
const seconds = timeLeft % 60;
timerDisplay.textContent = `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
}
function handlePhaseComplete(currentPhase) {
if (currentPhase === 'boiling') {
boilingSound.play();
messageDisplay.textContent = "L'acqua bolle! Inizia il raffreddamento";
startBtn.disabled = true;
coolBtn.disabled = false;
phase = 'idle';
} else if (currentPhase === 'cooling') {
messageDisplay.textContent = "Controlla la temperatura!";
startBtn.disabled = false;
coolBtn.disabled = true;
phase = 'idle';
}
}
startBtn.addEventListener('click', () => {
if (phase === 'idle') {
phase = 'boiling';
messageDisplay.textContent = "Bollimento in corso...";
startBtn.disabled = true;
coolBtn.disabled = true;
startTimer(360, 'boiling'); // 6 minuti = 360 secondi
}
});
coolBtn.addEventListener('click', () => {
if (phase === 'idle') {
phase = 'cooling';
messageDisplay.textContent = "Raffreddamento in corso...";
startBtn.disabled = true;
coolBtn.disabled = true;
startTimer(360, 'cooling'); // 6 minuti = 360 secondi
}
});
</script>
</body>
</html>