Check out my other project, Scribbletune, it helps you create music with JavaScript and Node.js directly from the terminal OR in the browser.
Download the jQuery timer plugin and put it in a SCRIPT tag in your HTML page after jQuery itself.
$('#divId').timer(); //Same as $('#divId').timer('start')
$('#divId').timer({ seconds: 100 //Specify start time in seconds });
$('#divId').timer('pause');
$('#divId').timer('resume');
$('#divId').timer('remove');
$('#divId').data('seconds');
//start a timer & execute a function in 5 minutes & 30 seconds $('#divId').timer({ duration: '5m30s', callback: function() { alert('Time up!'); } });
//start a timer & execute a function every 2 minutes $('#divId').timer({ duration: '2m', callback: function() { alert('Why, Hello there'); }, repeat: true //repeatedly calls the callback you specify });
//start a timer & execute a function every 30 seconds and then reset the timer at the end of 30 seconds. $('#divId').timer({ duration: '30s', callback: function() { $('#divId').timer('reset'); }, repeat: true //repeatedly call the callback });
// Show a digital timer instead of pretty timer: $('#divId').timer({ format: '%H:%M:%S' Display time as 00:00:00 }); // OR $('#divId').timer({ format: '%h:%m:%s' Display time as 0:0:0 }); // OR $('#divId').timer({ format: '%M minutes %s seconds' Display time as 3 minutes 45 seconds });
$('#divId').timer({ duration: '61s', //since 3599 is divisible by 59 or 61 seconds: 3590, //simulation purposes format: '%M:%S', callback: function() { var total = timerWithCallDuration.data('seconds'); if(total === 3599) { //change to hour format (3600 - 1 to prevent display bug) this.format = '%H:%M:%S'; } } });
$('#divId').timer({ updateFrequency: 2000 // Update the timer display every 2 seconds. });
$('#divId').timer({ countdown: true, duration: '25m' // Set the duration to 25 minutes });