Spaces:
Running
Running
this is big and i don't want to it to stay big and make the small size whenever i want and only if i touch it..it will open those note button (fix this) and pause resume and again button will pop up otherwise only timer will show...and if i type note in note button then then it will show note
Browse files- index.html +82 -13
index.html
CHANGED
|
@@ -10,8 +10,31 @@
|
|
| 10 |
<style>
|
| 11 |
#timer-widget {
|
| 12 |
user-select: none;
|
|
|
|
| 13 |
}
|
| 14 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
font-family: 'Arial', sans-serif;
|
| 16 |
color: #ffffff;
|
| 17 |
font-weight: 800;
|
|
@@ -38,11 +61,12 @@ font-family: 'Arial', sans-serif;
|
|
| 38 |
<!-- Draggable Time Widget -->
|
| 39 |
<div id="timer-widget" class="fixed bottom-4 right-4 z-50 cursor-move" style="width: 300px;">
|
| 40 |
<div class="bg-black bg-opacity-80 rounded-xl shadow-xl p-6 text-white">
|
| 41 |
-
<div class="flex flex-col items-center">
|
| 42 |
-
<div id="live-clock">00:00:00</div>
|
| 43 |
<div class="text-sm opacity-80 mt-1" id="live-date">Loading...</div>
|
| 44 |
-
<div
|
| 45 |
-
|
|
|
|
| 46 |
<i class="fas fa-play"></i>
|
| 47 |
</button>
|
| 48 |
<button id="stop-btn" class="bg-red-500 hover:bg-red-600 px-4 py-2 rounded-full">
|
|
@@ -53,11 +77,11 @@ font-family: 'Arial', sans-serif;
|
|
| 53 |
</button>
|
| 54 |
</div>
|
| 55 |
</div>
|
| 56 |
-
<div class="mt-4">
|
| 57 |
<input type="text" id="time-note" class="bg-gray-700 bg-opacity-50 text-white text-sm rounded px-3 py-2 w-full"
|
| 58 |
placeholder="Add note...">
|
| 59 |
</div>
|
| 60 |
-
|
| 61 |
</div>
|
| 62 |
<script>
|
| 63 |
let timerInterval;
|
|
@@ -146,12 +170,33 @@ font-family: 'Arial', sans-serif;
|
|
| 146 |
widget.style.left = `${left}px`;
|
| 147 |
widget.style.top = `${top}px`;
|
| 148 |
}
|
| 149 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
document.getElementById('start-btn').addEventListener('click', startTimer);
|
| 151 |
document.getElementById('stop-btn').addEventListener('click', stopTimer);
|
| 152 |
document.getElementById('reset-btn').addEventListener('click', resetTimer);
|
| 153 |
-
|
| 154 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
const now = new Date();
|
| 156 |
const dateStr = now.toLocaleDateString('en-US', {
|
| 157 |
weekday: 'short',
|
|
@@ -162,23 +207,47 @@ font-family: 'Arial', sans-serif;
|
|
| 162 |
// Save notes to localStorage
|
| 163 |
const noteInput = document.getElementById('time-note');
|
| 164 |
noteInput.addEventListener('change', () => {
|
| 165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
});
|
| 167 |
|
| 168 |
-
// Load
|
| 169 |
const savedNote = localStorage.getItem('timeNote');
|
| 170 |
if (savedNote) {
|
| 171 |
noteInput.value = savedNote;
|
|
|
|
|
|
|
| 172 |
}
|
| 173 |
// Initialize with stopped state
|
| 174 |
resetTimer();
|
| 175 |
-
|
|
|
|
|
|
|
|
|
|
| 176 |
// Prevent text selection while dragging
|
| 177 |
document.addEventListener('selectstart', (e) => {
|
| 178 |
if (isDragging) {
|
| 179 |
e.preventDefault();
|
| 180 |
}
|
| 181 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
</script>
|
| 183 |
</body>
|
| 184 |
</html>
|
|
|
|
| 10 |
<style>
|
| 11 |
#timer-widget {
|
| 12 |
user-select: none;
|
| 13 |
+
transition: all 0.3s ease;
|
| 14 |
}
|
| 15 |
+
#timer-widget.minimized {
|
| 16 |
+
width: 150px !important;
|
| 17 |
+
height: 70px !important;
|
| 18 |
+
}
|
| 19 |
+
#timer-widget.minimized #controls-container,
|
| 20 |
+
#timer-widget.minimized #note-container {
|
| 21 |
+
display: none;
|
| 22 |
+
}
|
| 23 |
+
#timer-widget.minimized #live-clock {
|
| 24 |
+
font-size: 1.5rem;
|
| 25 |
+
letter-spacing: normal;
|
| 26 |
+
}
|
| 27 |
+
#note-text {
|
| 28 |
+
display: none;
|
| 29 |
+
font-size: 0.8rem;
|
| 30 |
+
margin-top: 4px;
|
| 31 |
+
color: #ccc;
|
| 32 |
+
word-break: break-word;
|
| 33 |
+
}
|
| 34 |
+
#timer-widget.has-note #note-text {
|
| 35 |
+
display: block;
|
| 36 |
+
}
|
| 37 |
+
#live-clock {
|
| 38 |
font-family: 'Arial', sans-serif;
|
| 39 |
color: #ffffff;
|
| 40 |
font-weight: 800;
|
|
|
|
| 61 |
<!-- Draggable Time Widget -->
|
| 62 |
<div id="timer-widget" class="fixed bottom-4 right-4 z-50 cursor-move" style="width: 300px;">
|
| 63 |
<div class="bg-black bg-opacity-80 rounded-xl shadow-xl p-6 text-white">
|
| 64 |
+
<div class="flex flex-col items-center" id="timer-content">
|
| 65 |
+
<div id="live-clock" class="cursor-pointer">00:00:00</div>
|
| 66 |
<div class="text-sm opacity-80 mt-1" id="live-date">Loading...</div>
|
| 67 |
+
<div id="note-text"></div>
|
| 68 |
+
<div class="flex space-x-4 mt-4" id="controls-container">
|
| 69 |
+
<button id="start-btn" class="bg-green-500 hover:bg-green-600 px-4 py-2 rounded-full">
|
| 70 |
<i class="fas fa-play"></i>
|
| 71 |
</button>
|
| 72 |
<button id="stop-btn" class="bg-red-500 hover:bg-red-600 px-4 py-2 rounded-full">
|
|
|
|
| 77 |
</button>
|
| 78 |
</div>
|
| 79 |
</div>
|
| 80 |
+
<div class="mt-4" id="note-container">
|
| 81 |
<input type="text" id="time-note" class="bg-gray-700 bg-opacity-50 text-white text-sm rounded px-3 py-2 w-full"
|
| 82 |
placeholder="Add note...">
|
| 83 |
</div>
|
| 84 |
+
</div>
|
| 85 |
</div>
|
| 86 |
<script>
|
| 87 |
let timerInterval;
|
|
|
|
| 170 |
widget.style.left = `${left}px`;
|
| 171 |
widget.style.top = `${top}px`;
|
| 172 |
}
|
| 173 |
+
// Toggle minimized state
|
| 174 |
+
const timerContent = document.getElementById('timer-content');
|
| 175 |
+
const liveClock = document.getElementById('live-clock');
|
| 176 |
+
const widget = document.getElementById('timer-widget');
|
| 177 |
+
|
| 178 |
+
let isMinimized = false;
|
| 179 |
+
|
| 180 |
+
liveClock.addEventListener('click', () => {
|
| 181 |
+
isMinimized = !isMinimized;
|
| 182 |
+
widget.classList.toggle('minimized', isMinimized);
|
| 183 |
+
|
| 184 |
+
// Save minimized state
|
| 185 |
+
localStorage.setItem('timerMinimized', isMinimized);
|
| 186 |
+
});
|
| 187 |
+
|
| 188 |
+
// Button event listeners
|
| 189 |
document.getElementById('start-btn').addEventListener('click', startTimer);
|
| 190 |
document.getElementById('stop-btn').addEventListener('click', stopTimer);
|
| 191 |
document.getElementById('reset-btn').addEventListener('click', resetTimer);
|
| 192 |
+
|
| 193 |
+
// Load minimized state
|
| 194 |
+
const savedMinimized = localStorage.getItem('timerMinimized') === 'true';
|
| 195 |
+
if (savedMinimized) {
|
| 196 |
+
isMinimized = true;
|
| 197 |
+
widget.classList.add('minimized');
|
| 198 |
+
}
|
| 199 |
+
// Initialize with current time
|
| 200 |
const now = new Date();
|
| 201 |
const dateStr = now.toLocaleDateString('en-US', {
|
| 202 |
weekday: 'short',
|
|
|
|
| 207 |
// Save notes to localStorage
|
| 208 |
const noteInput = document.getElementById('time-note');
|
| 209 |
noteInput.addEventListener('change', () => {
|
| 210 |
+
const note = noteInput.value.trim();
|
| 211 |
+
localStorage.setItem('timeNote', note);
|
| 212 |
+
|
| 213 |
+
if (note) {
|
| 214 |
+
document.getElementById('note-text').textContent = note;
|
| 215 |
+
widget.classList.add('has-note');
|
| 216 |
+
} else {
|
| 217 |
+
widget.classList.remove('has-note');
|
| 218 |
+
}
|
| 219 |
});
|
| 220 |
|
| 221 |
+
// Load and show note if exists
|
| 222 |
const savedNote = localStorage.getItem('timeNote');
|
| 223 |
if (savedNote) {
|
| 224 |
noteInput.value = savedNote;
|
| 225 |
+
document.getElementById('note-text').textContent = savedNote;
|
| 226 |
+
widget.classList.add('has-note');
|
| 227 |
}
|
| 228 |
// Initialize with stopped state
|
| 229 |
resetTimer();
|
| 230 |
+
|
| 231 |
+
// Make sure widget stays visible when minimized
|
| 232 |
+
widget.style.minWidth = '150px';
|
| 233 |
+
widget.style.minHeight = '70px';
|
| 234 |
// Prevent text selection while dragging
|
| 235 |
document.addEventListener('selectstart', (e) => {
|
| 236 |
if (isDragging) {
|
| 237 |
e.preventDefault();
|
| 238 |
}
|
| 239 |
});
|
| 240 |
+
|
| 241 |
+
// Make whole widget draggable when minimized
|
| 242 |
+
widget.addEventListener('mousedown', (e) => {
|
| 243 |
+
if (isMinimized || e.target === widget || e.target.closest('.cursor-move')) {
|
| 244 |
+
isDragging = true;
|
| 245 |
+
offsetX = e.clientX - widget.getBoundingClientRect().left;
|
| 246 |
+
offsetY = e.clientY - widget.getBoundingClientRect().top;
|
| 247 |
+
widget.style.transition = 'none';
|
| 248 |
+
e.preventDefault();
|
| 249 |
+
}
|
| 250 |
+
});
|
| 251 |
</script>
|
| 252 |
</body>
|
| 253 |
</html>
|