novice here, working through a project i'm trying to build for a piece of educational multimedia in science.
I has a scenario where students are asked to record the temperature on a scale very minute for ten minutes.
i don't want them to waste ten minutes watching so i wish to display a clock on screen that will go slow for the first 5 seconds of every minute, speed up for 50 seconds then a normal rate again for the last 5 seconds.....
What I have achieved with very basic code is as follows
<div class="timer">
<span class="minute">00</span>:<span class="second">00</span>
</div>
and the script
function gotimer()
{
var time = 0;
var timer_id;
var rate = 1000;
function check(){
if ( secondcount <= 5) {
console.log("under")
rate = 1000;
console.log("rate" + rate)
}
else if ( secondcount >= 6 && secondcount <= 54 ) {
console.log("between")
rate = 300;
console.log("rate" + rate)
}
else if ( secondcount >= 55 ) {
console.log("between")
rate = 1000;
console.log("rate" + rate)
}
}
timer_id = setInterval(function()
{
//console.log($('.second').text())
secondcount = parseInt($('.second').text());
console.log(secondcount)
time++;
generateTime();
check();
}, rate);
this.getTime = function()
{
return time;
}
function generateTime()
{
var second = time % 60;
var minute = Math.floor(time / 60) % 60;
second = (second < 10) ? '0'+second : second;
minute = (minute < 10) ? '0'+minute : minute;
$('div.timer span.second').html(second);
$('div.timer span.minute').html(minute);
}
}
var timer;
$(document).ready(function(e)
{
timer = new gotimer
});
I have worked at it a few days and I get a changing console log but no change in rate. I know my coding is far from good any any suggestions would be greatly appreciated.