I am using a countdown timer I've found in google, I just modify some line of codes to make the timer to count up instead of counting down and I want it to not reset if the page is refresh or the browser is restart. From what I know I need to use cookies for this but I don't know how to incorporate it to my code.
Here's the code.
<html>
<html>
<head>
<title>Timer</title>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
</head>
<body>
<span id="countup">00:00:00</span>
</body>
</html>
<script type="text/javascript">
(function(){
$(document).ready(function() {
var time = "00:00:00",
parts = time.split(':'),
hours = +parts[0],
minutes = +parts[1],
seconds = +parts[2],
span = $('#countup');
function correctNum(num) {
return (num<10)? ("0"+num):num;
}
var timer = setInterval(function(){
seconds++;
if(seconds > 59) {
minutes++;
seconds = 0;
if(minutes > 59) {
hours++;
seconds = 0;
minutes = 0;
if(hours >= 24) {
alert("timer finished");
}
}
}
span.text(correctNum(hours) + ":" + correctNum(minutes) + ":" + correctNum(seconds));
}, 1000);
});
})()
</script>