Breaks countdown timer.

I’ve been playing around with Javascript quite a bit lately and am steadily getting more familiar with its syntax and coding. I’ve been coming up with ideas for new scripts and have been having lots of fun coding them. Truly, this is the best way to learn.

Recently I was cleaning up my script that counts down to my job’s quitting time of 6pm when I came up with a very cool idea. Why not have the script count down to my breaks as well? A short time later I had just the script to do the trick.

<!DOCTYPE html>
<p id=”break1″>Morning Break:</p>
<p id=”lunch”>Lunch:</p>
<p id=”break2″>Afternoon Break:</p>
<p id=”outtahere”>Quitting Time:</p>
<button onclick=”myFunction()”>Count down!</button>

function myFunction()
var now = new Date();
var mhrs = 10-now.getHours();
var lhrs = 12-now.getHours();
var lmins = 15-now.getMinutes();
if (lmins < 0) { lmins += 60; }
var ahrs = 15-now.getHours();
var qhrs = 17-now.getHours();
if (mhrs < 0) { mhrs += 24; }
if (lhrs < 0) { lhrs += 24; }
if (ahrs < 0) { ahrs += 24; }
if (qhrs < 0) { qhrs += 24; }
var mins = 60-now.getMinutes();
document.getElementById(‘break1’).innerHTML=’Morning Break: ‘ + mhrs+’ hours, ‘+mins+’ minutes.’;
document.getElementById(‘lunch’).innerHTML=’Lunch: ‘ +lhrs+’ hours, ‘+lmins+’ minutes.’;
document.getElementById(‘break2’).innerHTML=’Afternoon Break: ‘ + ahrs+’ hours, ‘+mins+’ minutes.’;
document.getElementById(‘outtahere’).innerHTML=’Quitting Time: ‘ +qhrs+’ hours, ‘+mins+’ minutes.’;

At my job, my morning break is at 11:00am, my lunch break is at 1:15pm, my afternoon break is at 4:00pm and quitting time is 6pm. The script calculates the time remaining until each of those breaks when I click on the “Count Down” button. I didn’t want to have the script run continuously as I wanted to save it as a note in Simplenote, which supports Markdown text and HTML. The script works really well and helps make my job more tolerable as I approach those lifesaving breaks.

Keeping it simple with Simplenote.

While searching for another place to store my online notes after dumping Evernote, I came across a possible replacement called Simplenote. I briefly gave it a try but decided to dump it when I realized it only saved simple text notes and not HTML-rendered notes with clickable links.

Then it dawned on me that perhaps my notes don’t really need to be fancy or clickable, so I decided to give Simplenote another try and before I knew it, it started growing on me. I saved plain-text versions of my notes there and marveled at how quickly I can switch from one note to the next through the simplistic, speedy interface. I can assign keywords to each note and make the notes accessible through a public link. That’s all you really need to know to use Simplenote. I like it and am already looking for other uses for it. I can only hope that it stays simple and fast no matter what pending features are forthcoming as the service continues to evolve.

UPDATE: When I discovered that Simplenote supports Markdown-formatted text to format my text and create tables and embedded links, its usefulness increased exponentially.  Now I’m more convinced than ever that I have found a decent notebook service that works well enough to replace Evernote.