Good day! Could somebody suggest please.. I am using for record time easytimer.js plugin.
I have a button on the page where there is timer starts when I click it. But the problem is if
someone reloads the page or open new window the timer restarts. I dont know how to use local
storage to make sure my timer does not reset upon reload.
initTimer: function (){
$(".timer").draggable({
containment: "window",
scroll: false,
cursor: "move"
});
var timer = new easytimer.Timer();
$('.timerDetails .startButton').click(function () {
timer.start();
//localStorage.setItem('timer', timer);
$(".timer").css("display", "flex");
$(".startButton").parent().children().removeClass("active");
$(".startButton").addClass("active");*/
});
$('.timerDetails .pauseButton').click(function () {
timer.pause();
$(".pauseButton").parent().children().removeClass("active");
$(".pauseButton").addClass("active");
});
$('.timerDetails .stopButton').click(function () {
timer.pause();
$(".stopButton").parent().children().removeClass("active");
$(".stopButton").addClass("active");
});
timer.addEventListener('secondsUpdated', function (e) {
$('.timerDetails .timer-values').html(timer.getTimeValues().toString());
});
timer.addEventListener('started', function (e) {
$('.timerDetails .timer-values').html(timer.getTimeValues().toString());
});
timer.addEventListener('reset', function (e) {
$('.timerDetails timer-values').html(timer.getTimeValues().toString());
});
},