WAIT-AN OCD MANAGER
- 2 Devlogs
- 2 Total hours
An OCD manager
An OCD manager
Devlog #2: Taming JavaScript Timers and Cleaning Up the CodeHey everyone, welcome back! If you have been following along with WAIT, I wanted to share a quick update on what I have been hacking away at recently, mostly focusing on the JavaScript side of things.If you want to see it live in action while you read, you can check it out on my GitHub Pages profile.The Plan for the JS
When I started writing the JS for this, I wanted to keep it pure vanilla, with no heavy frameworks, just clean code running directly in the browser. Right now, it is structured around a simple state object that handles what is going on, paired with a few helper files to keep my main script from turning into a massive wall of spaghetti code.The Biggest Headache: Browser Tab Throttling
I ran into a super annoying issue this week with JavaScript timers.If you have ever built anything with time or countdowns, you probably know that modern browsers like Chrome and Safari are notorious for throttling setInterval when you switch to a different tab or minimize your window. They do it to save battery, but for an app like this, it means your timer completely falls apart or freezes the second you look away.How I fixed it:
Instead of trusting setInterval to accurately count every single second, I switched over to using timestamps with Date.now and performance.now.
Instead of asking the code if a second passed every tick, it now checks what the exact math difference is between the start time and right now.
Even if the browser puts the tab to sleep for 30 seconds, the second you switch back, the script instantly calculates the real elapsed time and snaps the UI right where it needs to be. Total game changer.What Is Next
Now that the core timing logic is solid and does not break when you tab away, next on my JS checklist is hooking up localStorage so your settings and preferences actually save when you refresh the page.As always, if you want to look at the code, break it, or suggest a cleaner way I could have written something, the repo is wide open over on GitHub.
so i was trying to make a little website for my fellow neurodivergents and i tried to make a website that might help to manage the OCD….i am trying my best to make the website more usefull i add a wall poster type style and ig i need to add more features to manage the intrusive thoughts overall i have made the HTML and CSS and now i have to work on the animations……….see you all in the next if anyone is reading ts