Hourly Wage Timer



I whipped up this quick javascript which takes your hourly wage (for those of us still stuck in the race) and display a running countdown (countup?) of how much you've earned since clicking the button.

If you're viewing this in an RSS reader, this won't work, you'll have to actually click through to the post if you want to try it.


$

Tags: , ,



Subscribe Did you like this post? Great! Subscribe to the sparxMind RSS Feed!

19 Comments »

  1. spudart (890 comments) said,

    It's fun to type in 999999999999999999999999. I making lots of monkey, i mean money. It's also fun to type in beer. Nothing happens when I type in beer. Maybe that's a sign. You don't make much when you are paid by the beer.

    May 19, 2010 @ 10:59 pm


  2. Joe Leonard (20 comments) said,

    cool!

    May 20, 2010 @ 9:33 am


  3. vince garvie (1 comments) said,

    ok i have tryed some theories of telekinesis and nothing has ever worked i am just some ordinary 17 year old boy trying to be more than just some kid that goes to school comes home eats and then goes to bed gets up and starts the day the same way every day if you have somthing you would like me to try or if you can help me make it to do some telekinesis than please it would help.
    vince

    May 20, 2010 @ 9:45 am


  4. spudart (890 comments) said,

    I should also note that I did not have a single drop of alcohol when I wrote that previous comment.

    May 20, 2010 @ 9:58 am


  5. sparx (882 comments) said,

    @vince … what is the hourly wage for a telekinetic?
    What sort of telekinetic advice are you looking for?

    Are you upset that NBC has canceled Heroes?

    Also, punctuation dude!

    May 20, 2010 @ 2:59 pm


  6. unlikelymoose (375 comments) said,

    awesome script, sparxo

    June 18, 2010 @ 3:37 pm


  7. Sage (1 comments) said,

    Is there an App for this for a smartphone??????

    February 22, 2011 @ 9:00 am


  8. sparx (882 comments) said,

    Probably. Maybe.
    I could make you one for $20 😉

    February 22, 2011 @ 10:05 am


  9. Jon (4 comments) said,

    Hey, I'm implementing this in a tool I use at work to keep me motivated, and I'm trying to create a function to pause it for lunch breaks, etc, but I'm not too terribly skilled with JS. Any ideas?

    April 9, 2011 @ 6:32 pm


  10. sparx (882 comments) said,

    Easiest and quickest way (assuming you're modifying my existing code):
    Add a check to the click event for the button (the "figurize()" function) that checks the text value of the button, if it's "Start" or "Resume", start the timer and change the button's text to "Pause". If the text is "Pause", stop the timer and change the button's text to "Resume".

    To be able to stop the timer, it needs to be assigned to an object instead of just called the way it is. So instead of 'setInterval("d(obj)", obj.i);', that line would need to be something like 'myTimer = setInterval("d(obj)", obj.i);'
    Then to stop the timer you would do 'clearInterval(myTimer)'.

    Hope that helps.

    April 9, 2011 @ 10:06 pm


  11. Jon (4 comments) said,

    Thanks for the quick response! the pause worked like a charm. It retains the current place perfectly! How would I resume the timer from it's current place though? Honestly I'm doing this more as a way to further my knowledge in scripting, and this is certainly helping with that. What I was thinking was to set myTimer to a placeholder variable, and then recall it when I resumed the timer. Would that work or is that not a viable way to implement the resume? The myTimer = setInterval("d(obj)", obj.i); simply restarts the timer the way it is now.

    April 12, 2011 @ 10:09 am


  12. sparx (882 comments) said,

    If I'm reading this correctly, you're asking about just keeping the "Earned since *x*" from updating when you resume, right?

    You could add another "if" block in figurize() for just the "Start" text on the button, and then move the "h.innerHTML = 'Earned since ' + new Date(); " line into it.

    April 12, 2011 @ 10:17 am


  13. Jon (4 comments) said,

    Well, I actually ended up removing the "earned since" portion, as I didn't need it. I was more trying to keep the actual dollar amount from updating when I click "resume". Unfortunately, I don't think setting window.placeholder = myTimer will actually save the variables as it is an object. If I remove the constructor line to keep it from creating a new instance, it breaks the script. What I want to do is allow it to pause the wage timer, and resume it when I click the button. The way I was trying to implement it was to save the variables before i used clearInterval and then recall them when i called setInterval. Is that even possible?

    April 12, 2011 @ 10:33 am


  14. sparx (882 comments) said,

    Ah! I understand the question now.
    I've updated the script, so take a look at it now. Moving the constructor so it only fires when the button text is "Start" fixes that.
    The script on this page now has pause and resume capabilities, and keeps track of such events below the earnings display.

    April 12, 2011 @ 10:43 am


  15. sparx (882 comments) said,

    Also, trying to update javascript within a wordpress post is incredibly frustrating. I wish it wouldn't try to insert <p> and other tags inside the script. :-/
    I seem to be having difficulties with this internet thing today. Ha.

    April 12, 2011 @ 10:49 am


  16. Jon (4 comments) said,

    Perfect! I was using this:
    window.placeholder = obj.i and then the clearinterval, then setting obj.i = window.placeholder before calling the setInterval. It worked, but for some reason only on the first pause/resume. Your method is much cleaner, Well done!

    April 12, 2011 @ 11:06 am


  17. sparx (882 comments) said,

    I like clean code… I also like code that's incredibly difficult to read. 😛
    Check out my Javascript sudoku solver post from a few years ago. That was a fun one!

    April 12, 2011 @ 11:12 am


  18. Paul (1 comments) said,

    It seems like this only works if I type in how many cents I make per minute.

    October 8, 2011 @ 3:15 pm


  19. sparx (882 comments) said,

    Paul… you put in how much you would "earn" in an hour.
    If you put in "60", after one hour, it will (correctly) tell you that you've earned $60. Easy.

    October 8, 2011 @ 5:08 pm


RSS feed for comments on this post

Leave a Comment