|
4 | 4 | <meta charset="UTF-8" /> |
5 | 5 | <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
6 | 6 |
|
7 | | - <!-- Font Awesome --> |
| 7 | + <-- Font Awesome --> |
8 | 8 | <link |
9 | 9 | rel="stylesheet" |
10 | 10 | href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" |
11 | 11 | /> |
12 | 12 |
|
13 | | - <!-- Favicons --> |
| 13 | + <-- Favicons --> |
14 | 14 | <link |
15 | 15 | rel="icon" type="image/png" |
16 | 16 | href="{{ '/assets/favicon-96x96.png' | relative_url }}" |
|
45 | 45 | /> |
46 | 46 |
|
47 | 47 | <script> |
48 | | - // Current timezone tracker |
| 48 | + |
| 49 | + // TimeZone |
49 | 50 | let currentZone = 'IST'; |
50 | 51 | let tapCount = 0; |
51 | 52 | let tapTimer = null; |
52 | | - const TAP_TIMEOUT = 300; // ms for double-tap detection |
53 | | - const SCROLL_THRESHOLD = 100; // px to hide theme/time container |
54 | 53 |
|
55 | | - // Update active link based on URL |
| 54 | + const TAP_TIMEOUT = 200; //double-tap detection |
| 55 | + const SCROLL_THRESHOLD = 100; // after Scroll hide theme/time container |
| 56 | + |
| 57 | + |
56 | 58 | function updateActiveLink() { |
57 | 59 | const currentPath = window.location.pathname; |
58 | 60 | const baseUrl = '{{ site.baseurl }}' || ''; |
59 | | - console.log('Current Path:', currentPath, 'Base URL:', baseUrl); // Debug |
| 61 | + console.log('Current Path:', currentPath, 'Base URL:', baseUrl); |
60 | 62 | document.querySelectorAll('.sidebar-link').forEach(link => { |
61 | 63 | link.classList.remove('active'); |
62 | | - const href = link.getAttribute('href').replace(baseUrl, ''); // Normalize href |
| 64 | + const href = link.getAttribute('href').replace(baseUrl, ''); |
63 | 65 | if (href === currentPath || (currentPath === '/' && href === '/')) { |
64 | 66 | link.classList.add('active'); |
65 | | - console.log('Active Link Set:', href); // Debug |
| 67 | + console.log('Active Link Set:', href); |
66 | 68 | } |
67 | 69 | }); |
68 | 70 | } |
69 | 71 |
|
70 | | - // Sidebar toggle |
71 | 72 | function toggleSidebar(isHidden) { |
72 | 73 | const sidebar = document.getElementById('sidebar'); |
73 | 74 | const toggleBtn = document.querySelector('.toggle-btn'); |
|
77 | 78 | return; |
78 | 79 | } |
79 | 80 | sidebar.classList.toggle('hidden', isHidden); |
80 | | - content.style.marginLeft = isHidden ? '0' : '210px'; // Force margin update |
| 81 | + content.style.marginLeft = isHidden ? '0' : '210px'; |
81 | 82 | localStorage.setItem('sidebar-hidden', isHidden); |
82 | 83 | if (window.innerWidth > 768) { |
83 | 84 | toggleBtn.style.display = isHidden ? 'block' : 'none'; |
|
87 | 88 | updateActiveLink(); |
88 | 89 | } |
89 | 90 |
|
90 | | - // Handle tap/click events |
| 91 | + // Handle tap or click events |
91 | 92 | function handleTap(event) { |
92 | 93 | const sidebar = document.getElementById('sidebar'); |
93 | 94 | const target = event.target; |
|
96 | 97 | return; |
97 | 98 | } |
98 | 99 |
|
99 | | - // Allow taps outside interactive elements to trigger hide/show |
| 100 | + // Allow taps outside interactive elements to trigger hide and show |
100 | 101 | if ( |
101 | 102 | target.closest('#sidebar') || |
102 | 103 | target.closest('#theme-time-container') || |
|
123 | 124 | } |
124 | 125 | } |
125 | 126 |
|
126 | | - // Dark mode toggle |
| 127 | + // Dark mode |
127 | 128 | function toggleDarkMode() { |
128 | 129 | const body = document.body; |
129 | 130 | body.classList.toggle('dark-mode'); |
|
147 | 148 | }, 0); |
148 | 149 | } |
149 | 150 |
|
150 | | - // Timezone toggle |
| 151 | + // Timezone |
151 | 152 | function toggleTimezone() { |
152 | 153 | currentZone = currentZone === 'IST' ? 'GMT' : 'IST'; |
153 | 154 | const tzButton = document.getElementById('tz-toggle-btn'); |
|
182 | 183 | liveTime.textContent = `Time (${currentZone}): ${h}:${m}:${s} ${ampm}`; |
183 | 184 | } |
184 | 185 |
|
185 | | - // Handle scroll for theme/time container |
| 186 | + |
| 187 | + // Handle scroll for theme and time container |
186 | 188 | function handleScroll() { |
187 | 189 | const themeTimeContainer = document.getElementById('theme-time-container'); |
188 | 190 | if (themeTimeContainer) { |
|
196 | 198 | } |
197 | 199 | } |
198 | 200 |
|
199 | | - // On load: init dark mode, sidebar state, listeners, time, SW |
| 201 | + |
| 202 | + // On load: init dark mode, sidebar state, listeners, time, SW. |
200 | 203 | window.onload = () => { |
201 | 204 | // Initialize dark mode |
202 | 205 | const isDark = localStorage.getItem('dark-mode') === 'true'; |
|
211 | 214 | console.error('Body element not found'); |
212 | 215 | } |
213 | 216 |
|
214 | | - // Initialize sidebar state |
| 217 | + |
| 218 | + // Initialize sidebar |
215 | 219 | const sidebar = document.getElementById('sidebar'); |
216 | 220 | const toggleBtn = document.querySelector('.toggle-btn'); |
217 | 221 | const content = document.querySelector('.content'); |
|
228 | 232 | console.error('Sidebar, toggle button, or content not found'); |
229 | 233 | } |
230 | 234 |
|
231 | | - // Show tooltip on first visit or force for testing |
| 235 | + |
| 236 | + // Show tooltip on first visit |
232 | 237 | const tooltip = document.getElementById('tooltip'); |
233 | 238 | if (tooltip) { |
234 | 239 | const tooltipShown = localStorage.getItem('tooltip-shown'); |
235 | 240 | if (!tooltipShown) { |
236 | | - console.log('Showing tooltip for first visit'); // Debug |
| 241 | + console.log('Showing tooltip for first visit'); |
237 | 242 | setTimeout(() => { |
238 | 243 | tooltip.classList.add('visible'); |
239 | 244 | setTimeout(() => { |
|
242 | 247 | }, 5000); |
243 | 248 | }, 1000); |
244 | 249 | } else { |
245 | | - console.log('Tooltip already shown, skipping'); // Debug |
| 250 | + console.log('Tooltip already shown, skipping'); |
246 | 251 | } |
247 | 252 | } else { |
248 | 253 | console.error('Tooltip element not found'); |
249 | 254 | } |
250 | 255 |
|
251 | | - // Add tap/click and scroll listeners |
| 256 | + // Add tap and click and scroll listeners |
252 | 257 | document.addEventListener('click', handleTap); |
253 | 258 | document.addEventListener('touchstart', handleTap, { passive: true }); |
254 | 259 | window.addEventListener('scroll', handleScroll, { passive: true }); |
|
271 | 276 |
|
272 | 277 | <body> |
273 | 278 |
|
274 | | -<!-- Dark Mode & Timezone Controls --> |
| 279 | + |
| 280 | +<-- Dark Mode & Timezone Controls --> |
275 | 281 | <div id="theme-time-container"> |
276 | 282 | <button class="dark-toggle" onclick="toggleDarkMode()" aria-label="Toggle Dark Mode"> |
277 | 283 | <i class="fas fa-moon"></i> |
|
282 | 288 | </div> |
283 | 289 | </div> |
284 | 290 |
|
285 | | -<!-- Onboarding Tooltip --> |
| 291 | + |
| 292 | +<-- Onboarding Tooltip --> |
286 | 293 | <div id="tooltip" class="tooltip"> |
287 | 294 | Single tap to hide sidebar, double tap to show |
288 | 295 | </div> |
289 | 296 |
|
290 | | -<!-- Collapsible Sidebar --> |
| 297 | +<-- Collapsible Sidebar --> |
291 | 298 | <div id="sidebar" class="sidebar"> |
292 | 299 | <a href="{{ site.baseurl }}/" class="sidebar-link"> |
293 | 300 | <i class="fas fa-home"></i> Home |
|
300 | 307 | </a> |
301 | 308 | </div> |
302 | 309 |
|
303 | | -<!-- Toggle Button (Fallback) --> |
| 310 | +<-- Toggle Button (Fallback) --> |
304 | 311 | <button class="toggle-btn" onclick="toggleSidebar(!document.getElementById('sidebar').classList.contains('hidden'))" aria-label="Toggle Sidebar"> |
305 | 312 | <i class="fas fa-bars"></i> |
306 | 313 | </button> |
307 | 314 |
|
308 | | -<!-- Main Content --> |
| 315 | +<-- Main Content --> |
309 | 316 | <div class="wrapper"> |
310 | 317 | <div class="content"> |
311 | 318 | <div class="fade-in"> |
|
0 commit comments