睡前做一些工作,无法想象出问题所在。我确定某些东西超出范围或者其他东西:/做了一个小提琴。
https://jsfiddle.net/Luauabzg/
$("button").click(function(){
var input = $(this).text();
if(input === "Pause")
{
clearInterval(myVar);
clearInterval(myVar2);
}
if(input === "Reset")
{
clearInterval(myVar);
clearInterval(myVar2);
display = "00:00";
$(".session-time-clock").text(display);
$(".break-time-clock").text(display);
breakTimer = "00:00";
sessionTimer = "00:00";
}
});
myVar = setInterval(myTimer, 1000);
function myTimer() {
sessionSeconds--;
var minutes = Math.floor(sessionSeconds/60);
if(minutes < 10)
{
minutes = "0" + minutes;
}
if(minutes < 1)
{
minutes = "00";
}
var seconds = sessionSeconds - minutes *60;
if(seconds < 10)
{
seconds = "0" + seconds;
}
var time = minutes + ":" + seconds;
$(".session-time-clock").text(time);
if(minutes === "00" && seconds === "00")
{
clearInterval(myVar);
$(".session-time-clock").text(sessionTimer);
myVar2 = setInterval(myTimer2, 1000);
}
}
function myTimer2() {
breakSeconds--;
var minutes = Math.floor(breakSeconds/60);
if(minutes < 10)
{
minutes = "0" + minutes;
}
if(minutes < 1)
{
minutes = "00";
}
var seconds = breakSeconds - minutes *60;
if(seconds < 10)
{
seconds = "0" + seconds;
}
var time = minutes + ":" + seconds;
$(".break-time-clock").text(time);
if(minutes === "00" && seconds === "00")
{
clearInterval(myVar2);
$(".break-time-clock").text(breakTimer);
myVar = setInterval(myTimer, 1000);
}
}
}
});
我希望将会话计时器倒计时设置为0,然后重置为输入的值,然后在没有用户输入的情况下,break计时器执行相同的操作并切换回来。最终我希望绿色圆圈缩小,百分比随着时间的推移而减少。如果需要澄清任何需要澄清的话我会发出通知,我会在早上回复。