window.onload = function (){
var time_$ = $('.time_s');
for(var i = 0 ;i<time_$.length;i++){
var s = parseInt($('.time_s').eq(i).attr("times"));
settimes($('.time_s').eq(i),s);
}
}
function countTime(t,s) {
var leftTime = s;
var d,h,m,s;
if (leftTime>=0) {
d = Math.floor(leftTime/60/60/24);
h = Math.floor(leftTime/60/60%24);
m = Math.floor(leftTime/60%60);
s = Math.floor(leftTime%60);
}
d = checkTime(d);
h = checkTime(h);
m = checkTime(m);
s = checkTime(s);
function checkTime(i){
if(i == 0){
return false;
}
if (i<10) {
i = "0"+i;
}
return i;
}
if(d){
if(!h){
h='00';
}
if(!m){
m='00';
}
if(!s){
s='00';
}
$(t).html(d+":"+h+":"+m+":"+s);
return;
}
if(h){
if(!m){
m='00';
}
if(!s){
s='00';
}
$(t).html(h+":"+m+":"+s);
return;
}
if(m){
if(!s){
s='00';
}
$(t).html(m+":"+s);
return;
}
if(s){
$(t).html(s+"秒");
return;
}
if(!d && !h && !m && !s){
var sp = '<span οnclick="history.go(0);" style="color:blue">请刷新</span>';
$(t).parent("p").attr("onclick","return;");
$(t).html(sp);
return;
}
}
function settimes(t,s){
var t1 = t;
var s1 = s;
var timeSetTMIO = setInterval(function (){
if(s1 <=0){
var sp = '<span οnclick="history.go(0);" style="font-size:16px;color:blue">请刷新</span>';
$(t1).parent("p").attr("onclick","return;");
$(t1).html(sp);
clearInterval(timeSetTMIO);
}
countTime(t1,s1);
--s1;
},1000);
}