So, I’m doing some very involved woodworking, including glueing up these complicated pieces. The problem of course. is you only have so long to get things aligned and clamped up before the glue sets up. If you are not organized, or something doesn’t just fit right you are in trouble. Generally I always purchase slow set glue, so my working time is around eight to ten minutes. I will say, if things don’t go together by minute nine, then I rip the whole thing apart, let the glue dry on individual components, then come back and clean things up and try it again. With woodworking its pretty easy to fix woes (take one more cut, use a block plane or if necessary fill a gap with epoxy/sawdust mix and recut).

With that in mind, what I really want is a audible count up timer. When I’m in glue up mode, I don’t have time to be looking at the clock. Give me an audible and we’re good. At first glance I didn’t see anything off the shelf, that did this so I thought hey, I’d just write my own. And the easiest way to do that is in, you guessed it, Javascript in the browser. Without further ado, here is an audio timer!

Try it for yourself, click here.

Code pretty straight forward, the only real trick is the push/pop array for the setInterval calls. Without that, multiple button presses will drive you pretty crazy. Happy glueups!


script type="text/javascript"
     // global variable
     var x = []; // container for setInterval implementations
     var startDate;
 
     // functions defined here...
     function done() {
         clearInterval(x.pop());
         document.getElementById("demo").insertAdjacentHTML('beforeend',"Timer Stopped...");
         console.log("All Done x: ", x);
     }
 
     function startTimer() {
         // Set the date we're counting down to
         startDate = new Date().getTime();
         var msg = new SpeechSynthesisUtterance("Start Timer");
         window.speechSynthesis.speak(msg);
 
     // Update the count down every 1 second
     var tempX = setInterval(function() {
     // Get todays date and time
     var now = new Date().getTime();
 
     // Find the distance between now an the count down date
     var distance = now - startDate;
 
     // Time calculations for days, hours, minutes and seconds
     var days = Math.floor(distance / (1000 * 60 * 60 * 24));
     var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
     var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
     var seconds = Math.floor((distance % (1000 * 60)) / 1000);
 
     // Display the result in the element with id="demo"
     document.getElementById("demo").innerHTML = minutes + "m " + seconds + "s ";
 
     if (seconds % 15 == 0) {
         if (minutes == 0) {
             msg = new SpeechSynthesisUtterance(seconds + "seconds.");
         } else {
             msg = new SpeechSynthesisUtterance(minutes + " minute and " + seconds + "seconds.");
         }
             window.speechSynthesis.speak(msg);
         }
 
             }
         }, 1000);
         x.push(tempX);
         console.log("start timer x: ", x);
     }
end of script