4umi.com/web/javascript/alarm

Alarm

Timing Javascript

What time would you like to be alerted?



The code

var tid = null;

function tim() {
 var d = new Date(), f = document.forms.f.elements,
  wake = new Date( f.when.value );
 if( wake && d>wake ) {
  tid = null;
  window.open( '/juke?' + f.tune[f.tune.selectedIndex].value, '_search' ); 
 } else {
  f.wait.value = Math.floor( ( wake - d ) / ( 24 * 60 * 60 ) * 100 ) + ' sec.';
  tid = window.setTimeout( tim, 1000 );
 }
}

(function() {
 var d = new Date();
 d.setMinutes( d.getMinutes() + 1 );
 document.forms.f.elements.when.value =
  d.toString().replace( /^.*(\w\w\w) (\d+) (\d\d:\d\d:\d\d).*(\d{4}).*$/, '$3 $2 $1 $4' )
 tim();
})();