All pastes #989160 Raw Edit

Miscellany

public javascript v1 · immutable
#989160 ·published 2008-04-18 04:44 UTC
rendered paste body
<script type="text/javascript">function countDown(){    finished = false;    time = document.getElementById('expire').value.split(":");    d = time[0];    h = time[1];    m = time[2];    s = time[3];    if (s > 0) {        s--;    } else {        s = "59";        if (m > 0) {            m--;        } else {            m = "59";            if (h > 0) {                h--;            } else {                h = "23";                if (d > 0) {                    d--;                } else {                    finished = true;                }            }        }    }h=checkTime(h);m=checkTime(m);s=checkTime(s);    document.getElementById('expire').value = d+":"+h+":"+m+":"+s;    if (!finished)        setTimeout('countDown()', 1000);}setTimeout('countDown()', 1000);var look=new RegExp("0");function checkTime(i){if (i<10) { if(look.exec(i) == null)   {      i="0" + i;   } }return i;}function startTime(){var today=new Date();var h=today.getHours();var m=today.getMinutes();var s=today.getSeconds();// add a zero in front of numbers<10m=checkTime(m);s=checkTime(s);document.getElementById('date').innerHTML=h+":"+m+":"+s;t=setTimeout('startTime()',500);}function checkTime(i){if (i<10) { i="0" + i; }return i;}</script>