All pastes #2045445 Raw Edit

Miscellany

public text v1 · immutable
#2045445 ·published 2011-04-12 13:05 UTC
rendered paste body
function counttoShow(){
    var A= [], B= [], x, d,  diff,cd=document.getElementById('countdown'),
    cdimg=document.getElementById('onair'),
    onair= new Date(Date.UTC(2011, 2, 18, 11)), now= new Date();
    while(onair<now){ onair.setDate(onair.getDate()+14); }
    diff= (onair-now);
    if(diff<3600000){
        cdimg.style.display='inline';
        cd.style.display='none';
		document.getElementById("liveshow").style.borderColor = "red";
    }
    else{
		document.getElementById("liveshow").style.borderColor = "blue";
        x= Math.abs(diff);
        d= Math.floor(x/86400000);
        if(d> 1){
            A.push( "<td id='days'>" + d + "</td>");
			B.push( "<td>days</td>" );
            x%= 86400000;
        }
        x= Math.floor(x/1000);
        if(x>= 0){
            d= Math.floor(x/3600);
            A.push( "<td id='hours'>" + d + "</td>" );
			B.push( "<td>hour" +(d== 1? "</td>": "s</td>") );
            x%= 3600;
        }
        if(x>= 0){
            d= Math.floor(x/60);
            A.push( "<td id='minutes'>" + d + "</td>" );
			B.push( "<td>minute" +(d== 1? "</td>": "s</td>") );
            x%= 60;
        }
        if(x>= 0){
			A.push( "<td id='seconds'>" + x + "</td>" );
			B.push( "<td>second" +(x== 1? "</td>": "s</td>") );
		}
        cdimg.style.display='none';
        //cd.value= A.join(" ");
document.getElementById("numbers").innerHTML=A.join('');
document.getElementById("labels").innerHTML=B.join('');
    }
}
window.onload=function(){
    var cdtimer=setInterval(counttoShow,1000);
    document.body.ondblclick=function(){
        if(cd.timer){
            clearInterval(cdtimer);
            cdtimer=null;
        }
        else cdtimer=setInterval(counttoShow,1000);    
    }
}