SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist WebMachine's Avatar
    Join Date
    Jun 2007
    Location
    Ontario, Canada
    Posts
    412
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Automatically stop my timer

    A few years ago I made myself a PHP/mySQL project timer that I use with the bits and pieces of web development that I charge hourly rates for. (My major jobs are charged by the project). I love it and use it all the time but I have one issue with it that is bugging me.

    BTW, before you start berating me with "Why re-invent the wheel? There are dozens of timers out there already.", I did it because it was fun, and it does what I want it to do and only what I want it to do. Except ...

    Sometimes when I'm in a hurry I forget to stop the timer and just shut down my browser and head off. As a result, the end-time does not get recorded and I have to go into the database and insert it by hand.

    Is there any way this value can be automatically inserted into the "end_time" variable in the database if the browser is shut down before I remember to stop the timer?

  2. #2
    SitePoint Addict bronze trophy vectorialpx's Avatar
    Join Date
    Dec 2012
    Location
    Bucharest
    Posts
    247
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Unfortunately, after the browser/tab is closed you cannot send an Ajax to the server so,
    you cannot mark into your database; the onunload event will not work.

    The only way to do this into a browser is to be annoying with yourself Simple JavaScript:
    Code:
    <script>window.onbeforeunload = function(){ return true; }</script>
    Else, create a desktop application (in C) that cannot be closed OR will be able to control the "close" action.
    Be nice to nerds. Chances are you'll end up working for one - Bill Gates
    > photos | admin panel

  3. #3
    SitePoint Evangelist WebMachine's Avatar
    Join Date
    Jun 2007
    Location
    Ontario, Canada
    Posts
    412
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's a great idea. Thank you. All I need is a reminder to myself to stop and shut it down before I leave. Thank you.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •