-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
212 lines (182 loc) · 5.93 KB
/
index.html
File metadata and controls
212 lines (182 loc) · 5.93 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
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Focus Color Timer</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
transition: background-color 0.5s ease;
}
body {
font-family: Arial, sans-serif;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
min-height: 100vh;
padding: 20px;
}
.controls {
text-align: center;
margin-bottom: 30px;
background: rgba(255, 255, 255, 0.9);
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
transition: opacity 0.3s ease;
}
.hidden {
display: none !important;
}
input {
padding: 12px;
margin: 10px;
width: 220px;
border: 2px solid #ddd;
border-radius: 8px;
font-size: 16px;
}
button {
padding: 12px 30px;
background: #2ecc71;
color: white;
border: none;
border-radius: 8px;
cursor: pointer;
font-size: 18px;
transition: transform 0.2s ease;
}
button:hover {
background: #27ae60;
transform: scale(1.05);
}
.timer {
font-size: 10em;
font-weight: bold;
color: white;
text-shadow: 3px 3px 6px rgba(0,0,0,0.3);
cursor: pointer;
user-select: none;
}
@media (max-width: 768px) {
.timer {
font-size: 6em;
}
.controls {
width: 90%;
padding: 15px;
}
input {
width: 100%;
margin: 8px 0;
}
button {
width: 100%;
margin-top: 10px;
}
}
@media (max-width: 480px) {
.timer {
font-size: 4em;
}
}
</style>
</head>
<body>
<div id="controls" class="controls">
<input type="number" id="blocks" placeholder="Bloques de estudio" min="1">
<input type="number" id="minutes" placeholder="Minutos por bloque" min="1">
<button onclick="startSession()">Iniciar Sesión</button>
</div>
<div class="timer" id="timer" onclick="toggleFullscreen()">00:00</div>
<script>
let currentBlock = 0;
let totalBlocks = 0;
let studyMinutes = 0;
let colors = [];
let isBreak = false;
let timerInterval = null;
function generateRandomColor() {
const hue = Math.floor(Math.random() * 360);
return `hsl(${hue}, 70%, 40%)`;
}
function updateTimerDisplay(seconds) {
const minutes = Math.floor(seconds / 60);
const remainingSeconds = seconds % 60;
document.getElementById('timer').textContent =
`${String(minutes).padStart(2, '0')}:${String(remainingSeconds).padStart(2, '0')}`;
}
function startSession() {
// Ocultar controles
document.getElementById('controls').classList.add('hidden');
// Obtener valores
totalBlocks = parseInt(document.getElementById('blocks').value);
studyMinutes = parseInt(document.getElementById('minutes').value);
// Validación
if (!totalBlocks || !studyMinutes || totalBlocks < 1 || studyMinutes < 1) {
alert('Por favor ingresa valores válidos');
document.getElementById('controls').classList.remove('hidden');
return;
}
// Generar colores
colors = Array.from({length: totalBlocks}, generateRandomColor);
currentBlock = 0;
isBreak = false;
startNextPeriod();
}
function startNextPeriod() {
if (currentBlock >= totalBlocks) {
endSession();
return;
}
let duration;
if (isBreak) {
duration = 3 * 60; // 3 minutos de descanso
document.body.style.backgroundColor = '#ffffff';
} else {
duration = studyMinutes * 60;
document.body.style.backgroundColor = colors[currentBlock];
}
startCountdown(duration);
}
function startCountdown(seconds) {
if (timerInterval) clearInterval(timerInterval);
let remaining = seconds;
updateTimerDisplay(remaining);
timerInterval = setInterval(() => {
remaining--;
updateTimerDisplay(remaining);
if (remaining <= 0) {
clearInterval(timerInterval);
handlePeriodEnd();
}
}, 1000);
}
function handlePeriodEnd() {
if (!isBreak) {
currentBlock++;
}
isBreak = !isBreak;
startNextPeriod();
}
function endSession() {
clearInterval(timerInterval);
document.body.style.backgroundColor = '';
document.getElementById('controls').classList.remove('hidden');
updateTimerDisplay(0);
alert('¡Sesión completada con éxito! 🎉');
}
function toggleFullscreen() {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen();
} else {
document.exitFullscreen();
}
}
</script>
</body>
</html>