I have NaN error with following code.
I have timer of 10 seconds to reload page.
When Page reloads first jquery knob gives NaN value and then starts countdown of 10 seconds.
There is problem when seconds are 60. It shows NaN, 0 and then counts from 59.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://anthonyterrien.com/js/jquery.knob.js"></script>
<script>
var seconds = 10;
function secondPassed() {
var minutes = Math.round((seconds - 30) / 60);
var remainingSeconds = seconds % 60;
if (remainingSeconds < 10) {
remainingSeconds = "0" + remainingSeconds;
}
var elem = document.getElementById("countdown");
elem.value = remainingSeconds;
$("#countdown").val(remainingSeconds).trigger("change");
if (seconds == 0) {
clearInterval(countdownTimer);
location.reload();
} else {
seconds--;
}
}
var countdownTimer = setInterval('secondPassed()', 1000);
</script>
<script>
$(function() {
$('.dial').knob({
});
});
</script>
<input type="text" class="dial timer" id="countdown" data-min="0" data-max="60" data-fgColor="#ffec03"data-width="100" data-height="100" data-thickness=".3" />