• We just upgraded the platform on which this website runs! Please inform @Jaxel of any issues.

Timeclock is not pausing

Brimstone

New member
Loving this Scoreboard Assistant so far!! Very versatile application! And not to terribly hard to figure out, even for me with zero coding experience.

I am having a slight issue though with a countdown timer I have created. I followed the YouTube tutorial exactly and get a strange problem.

When I start the timer the webpage displays the timer running. When I pause the timer, the webpage doesn't pause. The timer continues to run. When I restart the timer again, the webpage appears to be running both timers at the same time, one from where it left off when paused and the other the one that didn't pause.

Using Chrome. I triple checked that I used the exact code from your YouTube tutorial and just can't find why this is not working right...

Any help would be much appreciated!

Page Javascript:

Code:
clearInterval(timeclock);

$('.timeclock').text(calcTimer(docData['Timeclock_o']));

if (docData['Timeclock_s'] > 0)
{
    countdown = setInterval(function()
    {
        time = parseInt(docData['Timeclock_e']) + parseInt(docData['Timeclock_o']) - new Date().getTime();
        $('.timeclock').text(calcTimer(time));
    }, 100);
}

function calcTimer(time)
{
    let neg = (time < 0) ? '- ' : '';
    time = Math.abs(time / 1000);
    
    hours = (Math.floor(time / 3600));
    minutes = (Math.floor(time % 3600 / 60)).toString().padStart(2, '0');
    seconds = (time % 60).toFixed().toString().padStart(2, '0');
    
    return neg + minutes + ' : ' + seconds;
}



Lee J
 

Brimstone

New member
Did some inspecting and found the following:

When I inspect the webpage and look at the console, I see the following values in docData:

Timeclock_e
Timeclock_o
Timeclock_s
Timer_e
Timer_o
Timer_s

I have no idea where those last three are coming from, as I only have the one Timeclock defined...
 

Jaxel

Administrator
You named your timer as countdown. Yet you have at the top: clearInterval(timeclock);
 

Brimstone

New member
Hey! Thanks for the reply! Yes! I just figured this out a few minutes ago. Was doing a screen share with a programming buddy. A second set of eyes fixed it right up!

Thanks for the awesome application!