File size: 15,445 Bytes
799d2f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14a4b11
799d2f8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ZenFocus - Lofi Study Timer</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
        
        body {
            font-family: 'Inter', sans-serif;
            background-color: #0f172a;
            color: #f8fafc;
            transition: background-color 0.5s ease;
        }
        
        .timer-container {
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
        }
        
        .progress-ring__circle {
            transition: stroke-dashoffset 0.5s;
            transform: rotate(-90deg);
            transform-origin: 50% 50%;
        }
        
        .music-controls {
            backdrop-filter: blur(10px);
            background-color: rgba(15, 23, 42, 0.7);
        }
        
        .time-option:hover {
            transform: scale(1.05);
            transition: transform 0.2s ease;
        }
        
        .time-option.active {
            background-color: #3b82f6;
            color: white;
        }
        
        .glow {
            animation: glow 2s infinite alternate;
        }
        
        @keyframes glow {
            from {
                box-shadow: 0 0 5px rgba(59, 130, 246, 0.5);
            }
            to {
                box-shadow: 0 0 20px rgba(59, 130, 246, 0.8);
            }
        }
    </style>
</head>
<body class="min-h-screen flex flex-col items-center justify-center p-4">
    <div class="max-w-md w-full space-y-8">
        <div class="text-center">
            <h1 class="text-4xl font-bold mb-2 text-blue-400">ZenFocus</h1>
            <p class="text-slate-300">Stay focused, stay productive</p>
        </div>
        
        <div class="timer-container bg-slate-800 rounded-2xl p-8 relative overflow-hidden">
            <div class="absolute inset-0 bg-gradient-to-br from-blue-900/20 to-slate-900/50"></div>
            
            <div class="relative z-10 flex flex-col items-center">
                <div class="relative w-64 h-64 mb-8">
                    <svg class="w-full h-full" viewBox="0 0 100 100">
                        <circle
                            class="text-slate-700"
                            stroke-width="8"
                            stroke="currentColor"
                            fill="transparent"
                            r="40"
                            cx="50"
                            cy="50"
                        />
                        <circle
                            class="progress-ring__circle text-blue-500"
                            stroke-width="8"
                            stroke-linecap="round"
                            stroke="currentColor"
                            fill="transparent"
                            r="40"
                            cx="50"
                            cy="50"
                        />
                    </svg>
                    <div class="absolute inset-0 flex items-center justify-center flex-col">
                        <div id="time-display" class="text-5xl font-bold">25:00</div>
                        <div id="timer-state" class="text-blue-400 font-medium mt-2">Ready</div>
                    </div>
                </div>
                
                <div class="flex space-x-4 mb-8">
                    <button id="start-btn" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-full font-medium flex items-center glow">
                        <i class="fas fa-play mr-2"></i> Start
                    </button>
                    <button id="reset-btn" class="bg-slate-700 hover:bg-slate-600 text-white px-6 py-3 rounded-full font-medium flex items-center">
                        <i class="fas fa-redo mr-2"></i> Reset
                    </button>
                </div>
                
                <div class="w-full">
                    <h3 class="text-lg font-medium mb-4 text-center">Select Duration</h3>
                    <div class="grid grid-cols-3 gap-3">
                        <button class="time-option py-2 px-4 rounded-lg bg-slate-700 hover:bg-slate-600" data-minutes="15">15 min</button>
                        <button class="time-option py-2 px-4 rounded-lg bg-slate-700 hover:bg-slate-600 active" data-minutes="25">25 min</button>
                        <button class="time-option py-2 px-4 rounded-lg bg-slate-700 hover:bg-slate-600" data-minutes="45">45 min</button>
                        <button class="time-option py-2 px-4 rounded-lg bg-slate-700 hover:bg-slate-600" data-minutes="60">60 min</button>
                        <button class="time-option py-2 px-4 rounded-lg bg-slate-700 hover:bg-slate-600" data-minutes="90">90 min</button>
                        <button class="time-option py-2 px-4 rounded-lg bg-slate-700 hover:bg-slate-600" data-minutes="120">120 min</button>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="music-controls rounded-xl p-4 border border-slate-700">
            <div class="flex items-center justify-between">
                <div class="flex items-center">
                    <i class="fas fa-music text-blue-400 mr-3 text-xl"></i>
                    <div>
                        <h3 class="font-medium">Lofi Study Beats</h3>
                        <p class="text-sm text-slate-400">Chill focus music</p>
                    </div>
                </div>
                <div class="flex items-center space-x-2">
                    <button id="volume-down" class="p-2 text-slate-300 hover:text-white">
                        <i class="fas fa-volume-down"></i>
                    </button>
                    <button id="play-music" class="p-2 text-slate-300 hover:text-white">
                        <i class="fas fa-play"></i>
                    </button>
                    <button id="volume-up" class="p-2 text-slate-300 hover:text-white">
                        <i class="fas fa-volume-up"></i>
                    </button>
                </div>
            </div>
            <audio id="lofi-audio" loop>
                <source src="https://lofi.stream.laut.fm/zwei" type="audio/mpeg">
                Your browser does not support the audio element.
            </audio>
        </div>
        
        <div class="text-center text-slate-500 text-sm mt-8">
            <p>Take breaks between sessions for maximum productivity</p>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // Timer elements
            const timeDisplay = document.getElementById('time-display');
            const timerState = document.getElementById('timer-state');
            const startBtn = document.getElementById('start-btn');
            const resetBtn = document.getElementById('reset-btn');
            const timeOptions = document.querySelectorAll('.time-option');
            
            // Music elements
            const playMusicBtn = document.getElementById('play-music');
            const volumeUpBtn = document.getElementById('volume-up');
            const volumeDownBtn = document.getElementById('volume-down');
            const lofiAudio = document.getElementById('lofi-audio');
            
            // Timer variables
            let timer;
            let totalSeconds = 25 * 60; // Default 25 minutes
            let remainingSeconds = totalSeconds;
            let isRunning = false;
            let isMusicPlaying = false;
            
            // Progress ring
            const circle = document.querySelector('.progress-ring__circle');
            const radius = circle.r.baseVal.value;
            const circumference = 2 * Math.PI * radius;
            circle.style.strokeDasharray = circumference;
            circle.style.strokeDashoffset = circumference;
            
            // Initialize timer display
            updateTimerDisplay();
            
            // Time selection
            timeOptions.forEach(option => {
                option.addEventListener('click', function() {
                    timeOptions.forEach(opt => opt.classList.remove('active'));
                    this.classList.add('active');
                    
                    const minutes = parseInt(this.dataset.minutes);
                    totalSeconds = minutes * 60;
                    remainingSeconds = totalSeconds;
                    updateTimerDisplay();
                    updateProgressRing();
                    
                    // Reset timer state
                    if (isRunning) {
                        clearInterval(timer);
                        isRunning = false;
                        startBtn.innerHTML = '<i class="fas fa-play mr-2"></i> Start';
                        timerState.textContent = 'Ready';
                    }
                });
            });
            
            // Start/Pause timer
            startBtn.addEventListener('click', function() {
                if (isRunning) {
                    // Pause timer
                    clearInterval(timer);
                    isRunning = false;
                    this.innerHTML = '<i class="fas fa-play mr-2"></i> Resume';
                    timerState.textContent = 'Paused';
                    
                    // Pause music if playing
                    if (isMusicPlaying) {
                        lofiAudio.pause();
                        playMusicBtn.innerHTML = '<i class="fas fa-play"></i>';
                        isMusicPlaying = false;
                    }
                } else {
                    // Start timer
                    isRunning = true;
                    this.innerHTML = '<i class="fas fa-pause mr-2"></i> Pause';
                    timerState.textContent = 'Focusing...';
                    
                    // Start music if not already playing
                    if (!isMusicPlaying) {
                        lofiAudio.play().catch(e => console.log("Autoplay prevented:", e));
                        playMusicBtn.innerHTML = '<i class="fas fa-pause"></i>';
                        isMusicPlaying = true;
                    }
                    
                    timer = setInterval(() => {
                        if (remainingSeconds > 0) {
                            remainingSeconds--;
                            updateTimerDisplay();
                            updateProgressRing();
                        } else {
                            // Timer completed
                            clearInterval(timer);
                            isRunning = false;
                            startBtn.innerHTML = '<i class="fas fa-play mr-2"></i> Start';
                            timerState.textContent = 'Completed!';
                            document.querySelector('.timer-container').classList.add('animate-pulse');
                            
                            // Play completion sound
                            const audio = new Audio('https://assets.mixkit.co/sfx/preview/mixkit-alarm-digital-clock-beep-989.mp3');
                            audio.play();
                            
                            // Stop music
                            lofiAudio.pause();
                            playMusicBtn.innerHTML = '<i class="fas fa-play"></i>';
                            isMusicPlaying = false;
                        }
                    }, 1000);
                }
            });
            
            // Reset timer
            resetBtn.addEventListener('click', function() {
                clearInterval(timer);
                isRunning = false;
                remainingSeconds = totalSeconds;
                updateTimerDisplay();
                updateProgressRing();
                startBtn.innerHTML = '<i class="fas fa-play mr-2"></i> Start';
                timerState.textContent = 'Ready';
                document.querySelector('.timer-container').classList.remove('animate-pulse');
                
                // Stop music
                lofiAudio.pause();
                playMusicBtn.innerHTML = '<i class="fas fa-play"></i>';
                isMusicPlaying = false;
            });
            
            // Music controls
            playMusicBtn.addEventListener('click', function() {
                if (isMusicPlaying) {
                    lofiAudio.pause();
                    this.innerHTML = '<i class="fas fa-play"></i>';
                    isMusicPlaying = false;
                } else {
                    lofiAudio.play().catch(e => console.log("Play prevented:", e));
                    this.innerHTML = '<i class="fas fa-pause"></i>';
                    isMusicPlaying = true;
                }
            });
            
            volumeUpBtn.addEventListener('click', function() {
                if (lofiAudio.volume < 0.9) {
                    lofiAudio.volume += 0.1;
                }
            });
            
            volumeDownBtn.addEventListener('click', function() {
                if (lofiAudio.volume > 0.1) {
                    lofiAudio.volume -= 0.1;
                }
            });
            
            // Helper functions
            function updateTimerDisplay() {
                const minutes = Math.floor(remainingSeconds / 60);
                const seconds = remainingSeconds % 60;
                timeDisplay.textContent = `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
            }
            
            function updateProgressRing() {
                const offset = circumference - (remainingSeconds / totalSeconds) * circumference;
                circle.style.strokeDashoffset = offset;
            }
            
            // Try to autoplay music (may be blocked by browser)
            lofiAudio.volume = 0.5;
            document.addEventListener('click', function initAudio() {
                // This is needed to unlock audio on mobile devices
                lofiAudio.play().then(() => {
                    lofiAudio.pause();
                    playMusicBtn.innerHTML = '<i class="fas fa-play"></i>';
                    isMusicPlaying = false;
                }).catch(e => {
                    console.log("Audio initialization failed:", e);
                });
                document.removeEventListener('click', initAudio);
            }, { once: true });
        });
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=PyQuarX/studyfocus" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>