Note that there are some explanatory texts on larger screens.

plurals
  1. POA timer that won't reset on refresh
    primarykey
    data
    text
    <p>EDIT: How could I pass a parameter when I call Clock.start() so I could change the value of totalSeconds? </p> <p>I got a counter which value I concatenate with the ID of the timer display since there would be multiple lines of timers on the page but only one would be running for every user. I want to pass the value of the timer so i know which line the timer that I should fetch is on and then I'd convert that to seconds and then finally I could assign that value to totalSeconds. Then maybe I can get this working the way I pictured every thing.</p> <p>WHAT I ALREADY HAVE RUNNING: I have a timer that doesn't show that it's counting up unless I refresh. When the page loads PHP queries mySQL and calculates the elapsed time with TIMEDIFF(now(), time_log), where time_log is when the timer started.</p> <p>WHAT I'D LIKE TO ADD: What I want to do is use the js/jquery snippet below to get the my TIMEDIFF and then use that as totalSeconds, so totalSeconds wont reset and continue counting up from the TIMEDIFF value. </p> <pre><code>var Clock = { totalSeconds: 0, start: function () { var self = this; this.interval = setInterval(function () { self.totalSeconds += 1; var ctr; $(".icon-play").each(function(){ if( $(this).parent().hasClass('hide') ) ctr = ($(this).attr('id')).split('_'); }); $("#hour_" + ctr[1]).text(pad(Math.floor(self.totalSeconds/3600))); $("#min_" + ctr[1]).text(pad( Math.floor((self.totalSeconds/60)%60) )); $("#sec_" + ctr[1]).text(pad(parseInt(self.totalSeconds%60))); }, 1000); }, pause: function () { clearInterval(this.interval); delete this.interval; }, resume: function () { if (this.interval) this.start(); } }; </code></pre> <p>For this script, credits to Mr. Speransky Danil. <a href="https://stackoverflow.com/questions/12487352/how-do-i-pause-and-resume-a-timer">how do I pause and resume a timer?</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload