function recordTimeObj(){ var s = null, t1 = null, t2 = null; function recordTime(str, callBack){ var time = 15; function start(){ var i = 0; var j = 0; var count = 0; var MM = 0; var SS = time - 1; var MS = 9; var totle = (MM + 1) * time * 10; var d = 180*(MM+1); MM = "0" + MM; function showTime(){ totle = totle - 1; if(totle==0){ clearInterval(s); clearInterval(t1); clearInterval(t2); $(".pie2").css("-o-transform","rotate(" + d + "deg)"); $(".pie2").css("-moz-transform","rotate(" + d + "deg)"); $(".pie2").css("-webkit-transform","rotate(" + d + "deg)"); callBack && callBack(); }else{ if(totle>0 && MS>0){ MS = MS - 1; if(MS < 10){MS = "0" + MS}; }; if(MS == 0 && SS>0){ MS = 10; SS = SS - 1; if(SS < 10){SS = "0" + SS}; }; if(SS==0 && MM>0){ SS = 60; MM = MM - 1; if(MM < 10){MM = "0" + MM}; }; }; $(".time span").html( SS + "." + MS); }; function start1(){ i = i + 360/((time)*10); // count = count + 1; if(count >= (time/2*10)){ // count = 0; clearInterval(t1); t2 = setInterval(function(){ start2() },100); }; $(".pie1").css("-o-transform","rotate(" + i + "deg)"); $(".pie1").css("-moz-transform","rotate(" + i + "deg)"); $(".pie1").css("-webkit-transform","rotate(" + i + "deg)"); }; function start2(){ j = j + 360/((time)*10); // count = count + 1; if(count >= (time/2*10)){ // count = 0; clearInterval(t2); t1 = setInterval("start1()",100); }; $(".pie2").css("-o-transform","rotate(" + j + "deg)"); $(".pie2").css("-moz-transform","rotate(" + j + "deg)"); $(".pie2").css("-webkit-transform","rotate(" + j + "deg)"); }; s = setInterval(function(){ showTime() },100); t1 = setInterval(function(){ start1() },100); } if(str == 'start'){ start(); }else if(str == 'stop'){ clearInterval(s); clearInterval(t1); s = null; t1 = null; if(t2 != null){ clearInterval(t2); t2 = null; } } } return { recordTime: recordTime } }