Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

Repository files navigation

runner: jQuery plugin

A simple runner/stopwatch jQuery plugin for counting time up and down.

Project Status

Dependency StatusdevDependency StatusBuild Status

Installation

Grab the latest version from the build/ folder.

There's several different versions of the file, but you only need one.

  • In case you want to develop against the Runner, you can pick the non-minified version jquery.runner.js.
  • If you want to deploy Runner with your site/app, pick either jquery.runner-min.js.
  • Or if you develop with CoffeeScript and really want to know what's happening there, grab the jquery.runner.coffee. (Disclaimer: no support provided for the CoffeeScript file. If you don't know what it is, don't use it.)

Include script after the jQuery library:

<scriptsrc="jquery.js" type="text/javascript"></script><scriptsrc="jquery.runner.js" type="text/javascript"></script>

Usage

First you need a container element where we can input the value of the runner:

<spanid="runner"></span>

Note that this allows you to use any kind of element (h1, div, span, td, li, input, etc), and gives you an easy way to style it any way you want. Just remember that everything inside the container will be replaced with the formatted time.

Then you initialize the runner to that element:

$('#runner').runner();

After that you can start the runner from a button click or some other event:

$('#myButton').click(function(){$('#runner').runner('start');});

More examples below

Methods

By default, when the runner method is invoked, the script will initialize itself to the selected element. If no options are given, the default values are used.

$('#runner').runner();

start - Start the runner. If runner is not already initialized, it will first initialize and then start itself. Fires runnerStart event.

$('#runner').runner('start');

stop - Stop the runner. Fires runnerStop event.

$('#runner').runner('stop');

lap - Take a lap time (time between the current time and time from the last checkpoint) and return it as a formatted string. Fires runnerLap event.

alert("Current lap time: "+$('#runner').runner('lap'));

toggle - Toggle between start and stop.

$('#runner').runner('toggle');

reset - Resets the time and settings to the original (initial) values. Fires runnerReset event. Note that if the runner is running when invoking this method, this does not stop the runner, it just resets the time back to where it started and continues from there.

$('#runner').runner('reset');

To stop the runner along with the reset, you can provide an additional boolean true parameter for the command.

$('#runner').runner('reset',true);

version - Returns the current version string of the runner plugin

$('#runner').runner('version');

info - Returns a JavaScript object with information about the current status of the runner.

$('#runner').runner('info');

Options

You can alter the behavior by passing options object to the initialization.

Here's a list of options you can use:

  • autostart - (boolean) If set to true, the runner will be started automatically after the initialization. Defaults to false. If set to true, will trigger runnerStart event once the runner starts.

  • countdown - (boolean) If set to true, the time will run down instead of up (default). Note that if you set this to true, you should also set startAt option, otherwise the time goes to negative.

  • startAt - (integer) Time in milliseconds from which the runner should start running. Defaults to 0.

  • stopAt - (integer) Time in milliseconds at which the runner should stop running and invoke the runnerStop and runnerFinish events. Default is null (don't stop). This works with both counting up and down, as long as the value is within the current run direction.

  • milliseconds - (boolean) If set to false, the default formatter will omit the milliseconds from displaying. Defaults to true (show milliseconds). Note that if you use a custom formatter, this option will not affect the first value of that custom formatter function. This property, however, is passed in the object as second argument.

  • format - (function) A custom format function to replace the default time formatting. By default this is not set. Takes in two arguments: first one is the current time value in milliseconds, second one is the settings object. This function should return a string or a number.

Events

There are 5 events that gets fired:

  • runnerStart - This event gets fired when the start method is invoked, or if autostart option is set to true. Basically when ever the runner starts (duh!).

  • runnerStop - This event gets fired when the stop method is invoked. Note that this event is also fired when the runner reaches the stopAt value.

  • runnerLap - This event gets fired when the lap method is invoked.

  • runnerReset - This event gets fired when the reset method is invoked.

  • runnerFinish - This event gets fired when the runner reaches the stopAt value.

Each of these events will pass the result of the info method as an argument in the event call. See examples for usage.

Examples

Initialize a count down runner that starts from 60 seconds, and start it automatically:

$('#runner').runner({autostart: true,countdown: true,startAt: 60000// alternatively you could just write: 60*1000});

Initialize a count up runner that stops after 2 minutes:

$('#runner').runner({stopAt: 120000// 2(min) * 60(sec) * 1000(ms) = 120000});

Initialize a count down runner that starts from 30 seconds, updates the value once every second and doesn't show milliseconds:

$('#runner').runner({countdown: true,startAt: 30000,milliseconds: false,});

Initialize a normal count up runner with a custom formatter function that displays the time in minutes (with decimals):

$('#runner').runner({format: function(value){return(value/1000)/60;}});

Initialize a count down runner that starts from 12 minutes and stops at 0, and alerts when the runner finishes:

$('#runner').runner({countdown: true,startAt: 12*60*1000,stopAt: 0}).on('runnerFinish',function(eventObject,info){alert('The eggs are now hard-boiled!');});

Changelog

v2.3.3 - 2014-08-06 - Small improvement

  • Made the non-vendor specific requestAnimationFrame the primary one to suppress deprecation error messages.

v2.3.2 - 2014-05-28 - Bug fix

  • Another jQuery noConflict related fix. Hopefully the last.

v2.3.1 - 2014-05-24 - Improvements and fixes

  • Fixed a bug when running jQuery in noConflict mode.

v2.3.0 - 2013-07-14 - Improvements and fixes

  • Runner now utilizes requestAnimationFrame if applicable and falls back to setTimeout
  • Fixed a small bug with dependency checks
  • Removed ability to tweak the runner interval due to requestAnimationFrame change

v2.2.0 - 2013-05-24 - Feature improvements and fixes

  • Fixed a couple of small underlying bugs
  • The first lap-time value now takes under consideration if the startAt time was something else than 0
  • Lap-time now returns negative value if we are counting down

v2.1.3 - 2013-05-22 - Yet another bug fix release

  • I make a lot of bugs apparently
  • Runner lap wasn't returning the correct lap time, it's fixed now, I swear!

v2.1.2 - 2013-03-22 - Bug fix release

  • Fixed another woopsie.

v2.1.1 - 2013-02-07 - Bug fixes

  • Fixed a couple of woopsies.

v2.1.0 - 2013-01-18 - Changes to the API and bug fixes

  • The custom format function no longer gets the inbuilt formatter as a second parameter. You can access the runner's inbuilt formatter through $().runner.format.
  • The custom format function now gets the settings object as second parameter, which has the milliseconds -property that was given as 3rd parameter in the old version.
  • Added a way to stop the runner when calling reset method with a boolean true parameter.
  • Runner now fires a runnerFinish event after it reaches the stopAt value.
  • We now also fire a runnerReset event after the reset method is called.
  • Streamlined the other events to be more consistent.
    • runnerStarted is now runnerStart.
    • runnerStopped is now runnerStop.

v2.0.0 - 2013-01-17 - Rewrote the runner plugin with CoffeeScript

  • Backwards compatible with the 1.x release

v1.0.0 - eons ago - First version of the runner plugin

Development

Author

Jyrki Laurila

License (MIT)

WWWWWW||WWWWWW
W W W||W W W
||
( OO )__________
/ | \
/o o| MIT \
\___/||_||__||_|| *
|| || || ||
_||_|| _||_||
(__|__|(__|__|

Copyright © 2013 Jyrki Laurila

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Bitdeli Badge

About

A runner/stopwatch plugin for jQuery

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
GitHub - innovationsforlearning/jquery-runner: A runner/stopwatch plugin for jQuery · GitHub
Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

Repository files navigation

runner: jQuery plugin

A simple runner/stopwatch jQuery plugin for counting time up and down.

Project Status

Dependency StatusdevDependency StatusBuild Status

Installation

Grab the latest version from the build/ folder.

There's several different versions of the file, but you only need one.

  • In case you want to develop against the Runner, you can pick the non-minified version jquery.runner.js.
  • If you want to deploy Runner with your site/app, pick either jquery.runner-min.js.
  • Or if you develop with CoffeeScript and really want to know what's happening there, grab the jquery.runner.coffee. (Disclaimer: no support provided for the CoffeeScript file. If you don't know what it is, don't use it.)

Include script after the jQuery library:

<scriptsrc="jquery.js" type="text/javascript"></script><scriptsrc="jquery.runner.js" type="text/javascript"></script>

Usage

First you need a container element where we can input the value of the runner:

<spanid="runner"></span>

Note that this allows you to use any kind of element (h1, div, span, td, li, input, etc), and gives you an easy way to style it any way you want. Just remember that everything inside the container will be replaced with the formatted time.

Then you initialize the runner to that element:

$('#runner').runner();

After that you can start the runner from a button click or some other event:

$('#myButton').click(function(){$('#runner').runner('start');});

More examples below

Methods

By default, when the runner method is invoked, the script will initialize itself to the selected element. If no options are given, the default values are used.

$('#runner').runner();

start - Start the runner. If runner is not already initialized, it will first initialize and then start itself. Fires runnerStart event.

$('#runner').runner('start');

stop - Stop the runner. Fires runnerStop event.

$('#runner').runner('stop');

lap - Take a lap time (time between the current time and time from the last checkpoint) and return it as a formatted string. Fires runnerLap event.

alert("Current lap time: "+$('#runner').runner('lap'));

toggle - Toggle between start and stop.

$('#runner').runner('toggle');

reset - Resets the time and settings to the original (initial) values. Fires runnerReset event. Note that if the runner is running when invoking this method, this does not stop the runner, it just resets the time back to where it started and continues from there.

$('#runner').runner('reset');

To stop the runner along with the reset, you can provide an additional boolean true parameter for the command.

$('#runner').runner('reset',true);

version - Returns the current version string of the runner plugin

$('#runner').runner('version');

info - Returns a JavaScript object with information about the current status of the runner.

$('#runner').runner('info');

Options

You can alter the behavior by passing options object to the initialization.

Here's a list of options you can use:

  • autostart - (boolean) If set to true, the runner will be started automatically after the initialization. Defaults to false. If set to true, will trigger runnerStart event once the runner starts.

  • countdown - (boolean) If set to true, the time will run down instead of up (default). Note that if you set this to true, you should also set startAt option, otherwise the time goes to negative.

  • startAt - (integer) Time in milliseconds from which the runner should start running. Defaults to 0.

  • stopAt - (integer) Time in milliseconds at which the runner should stop running and invoke the runnerStop and runnerFinish events. Default is null (don't stop). This works with both counting up and down, as long as the value is within the current run direction.

  • milliseconds - (boolean) If set to false, the default formatter will omit the milliseconds from displaying. Defaults to true (show milliseconds). Note that if you use a custom formatter, this option will not affect the first value of that custom formatter function. This property, however, is passed in the object as second argument.

  • format - (function) A custom format function to replace the default time formatting. By default this is not set. Takes in two arguments: first one is the current time value in milliseconds, second one is the settings object. This function should return a string or a number.

Events

There are 5 events that gets fired:

  • runnerStart - This event gets fired when the start method is invoked, or if autostart option is set to true. Basically when ever the runner starts (duh!).

  • runnerStop - This event gets fired when the stop method is invoked. Note that this event is also fired when the runner reaches the stopAt value.

  • runnerLap - This event gets fired when the lap method is invoked.

  • runnerReset - This event gets fired when the reset method is invoked.

  • runnerFinish - This event gets fired when the runner reaches the stopAt value.

Each of these events will pass the result of the info method as an argument in the event call. See examples for usage.

Examples

Initialize a count down runner that starts from 60 seconds, and start it automatically:

$('#runner').runner({autostart: true,countdown: true,startAt: 60000// alternatively you could just write: 60*1000});

Initialize a count up runner that stops after 2 minutes:

$('#runner').runner({stopAt: 120000// 2(min) * 60(sec) * 1000(ms) = 120000});

Initialize a count down runner that starts from 30 seconds, updates the value once every second and doesn't show milliseconds:

$('#runner').runner({countdown: true,startAt: 30000,milliseconds: false,});

Initialize a normal count up runner with a custom formatter function that displays the time in minutes (with decimals):

$('#runner').runner({format: function(value){return(value/1000)/60;}});

Initialize a count down runner that starts from 12 minutes and stops at 0, and alerts when the runner finishes:

$('#runner').runner({countdown: true,startAt: 12*60*1000,stopAt: 0}).on('runnerFinish',function(eventObject,info){alert('The eggs are now hard-boiled!');});

Changelog

v2.3.3 - 2014-08-06 - Small improvement

  • Made the non-vendor specific requestAnimationFrame the primary one to suppress deprecation error messages.

v2.3.2 - 2014-05-28 - Bug fix

  • Another jQuery noConflict related fix. Hopefully the last.

v2.3.1 - 2014-05-24 - Improvements and fixes

  • Fixed a bug when running jQuery in noConflict mode.

v2.3.0 - 2013-07-14 - Improvements and fixes

  • Runner now utilizes requestAnimationFrame if applicable and falls back to setTimeout
  • Fixed a small bug with dependency checks
  • Removed ability to tweak the runner interval due to requestAnimationFrame change

v2.2.0 - 2013-05-24 - Feature improvements and fixes

  • Fixed a couple of small underlying bugs
  • The first lap-time value now takes under consideration if the startAt time was something else than 0
  • Lap-time now returns negative value if we are counting down

v2.1.3 - 2013-05-22 - Yet another bug fix release

  • I make a lot of bugs apparently
  • Runner lap wasn't returning the correct lap time, it's fixed now, I swear!

v2.1.2 - 2013-03-22 - Bug fix release

  • Fixed another woopsie.

v2.1.1 - 2013-02-07 - Bug fixes

  • Fixed a couple of woopsies.

v2.1.0 - 2013-01-18 - Changes to the API and bug fixes

  • The custom format function no longer gets the inbuilt formatter as a second parameter. You can access the runner's inbuilt formatter through $().runner.format.
  • The custom format function now gets the settings object as second parameter, which has the milliseconds -property that was given as 3rd parameter in the old version.
  • Added a way to stop the runner when calling reset method with a boolean true parameter.
  • Runner now fires a runnerFinish event after it reaches the stopAt value.
  • We now also fire a runnerReset event after the reset method is called.
  • Streamlined the other events to be more consistent.
    • runnerStarted is now runnerStart.
    • runnerStopped is now runnerStop.

v2.0.0 - 2013-01-17 - Rewrote the runner plugin with CoffeeScript

  • Backwards compatible with the 1.x release

v1.0.0 - eons ago - First version of the runner plugin

Development

Author

Jyrki Laurila

License (MIT)

WWWWWW||WWWWWW
W W W||W W W
||
( OO )__________
/ | \
/o o| MIT \
\___/||_||__||_|| *
|| || || ||
_||_|| _||_||
(__|__|(__|__|

Copyright © 2013 Jyrki Laurila

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Bitdeli Badge

About

A runner/stopwatch plugin for jQuery

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - innovationsforlearning/jquery-runner: A runner/stopwatch plugin for jQuery · GitHub
Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

Repository files navigation

runner: jQuery plugin

A simple runner/stopwatch jQuery plugin for counting time up and down.

Project Status

Dependency StatusdevDependency StatusBuild Status

Installation

Grab the latest version from the build/ folder.

There's several different versions of the file, but you only need one.

  • In case you want to develop against the Runner, you can pick the non-minified version jquery.runner.js.
  • If you want to deploy Runner with your site/app, pick either jquery.runner-min.js.
  • Or if you develop with CoffeeScript and really want to know what's happening there, grab the jquery.runner.coffee. (Disclaimer: no support provided for the CoffeeScript file. If you don't know what it is, don't use it.)

Include script after the jQuery library:

<scriptsrc="jquery.js" type="text/javascript"></script><scriptsrc="jquery.runner.js" type="text/javascript"></script>

Usage

First you need a container element where we can input the value of the runner:

<spanid="runner"></span>

Note that this allows you to use any kind of element (h1, div, span, td, li, input, etc), and gives you an easy way to style it any way you want. Just remember that everything inside the container will be replaced with the formatted time.

Then you initialize the runner to that element:

$('#runner').runner();

After that you can start the runner from a button click or some other event:

$('#myButton').click(function(){$('#runner').runner('start');});

More examples below

Methods

By default, when the runner method is invoked, the script will initialize itself to the selected element. If no options are given, the default values are used.

$('#runner').runner();

start - Start the runner. If runner is not already initialized, it will first initialize and then start itself. Fires runnerStart event.

$('#runner').runner('start');

stop - Stop the runner. Fires runnerStop event.

$('#runner').runner('stop');

lap - Take a lap time (time between the current time and time from the last checkpoint) and return it as a formatted string. Fires runnerLap event.

alert("Current lap time: "+$('#runner').runner('lap'));

toggle - Toggle between start and stop.

$('#runner').runner('toggle');

reset - Resets the time and settings to the original (initial) values. Fires runnerReset event. Note that if the runner is running when invoking this method, this does not stop the runner, it just resets the time back to where it started and continues from there.

$('#runner').runner('reset');

To stop the runner along with the reset, you can provide an additional boolean true parameter for the command.

$('#runner').runner('reset',true);

version - Returns the current version string of the runner plugin

$('#runner').runner('version');

info - Returns a JavaScript object with information about the current status of the runner.

$('#runner').runner('info');

Options

You can alter the behavior by passing options object to the initialization.

Here's a list of options you can use:

  • autostart - (boolean) If set to true, the runner will be started automatically after the initialization. Defaults to false. If set to true, will trigger runnerStart event once the runner starts.

  • countdown - (boolean) If set to true, the time will run down instead of up (default). Note that if you set this to true, you should also set startAt option, otherwise the time goes to negative.

  • startAt - (integer) Time in milliseconds from which the runner should start running. Defaults to 0.

  • stopAt - (integer) Time in milliseconds at which the runner should stop running and invoke the runnerStop and runnerFinish events. Default is null (don't stop). This works with both counting up and down, as long as the value is within the current run direction.

  • milliseconds - (boolean) If set to false, the default formatter will omit the milliseconds from displaying. Defaults to true (show milliseconds). Note that if you use a custom formatter, this option will not affect the first value of that custom formatter function. This property, however, is passed in the object as second argument.

  • format - (function) A custom format function to replace the default time formatting. By default this is not set. Takes in two arguments: first one is the current time value in milliseconds, second one is the settings object. This function should return a string or a number.

Events

There are 5 events that gets fired:

  • runnerStart - This event gets fired when the start method is invoked, or if autostart option is set to true. Basically when ever the runner starts (duh!).

  • runnerStop - This event gets fired when the stop method is invoked. Note that this event is also fired when the runner reaches the stopAt value.

  • runnerLap - This event gets fired when the lap method is invoked.

  • runnerReset - This event gets fired when the reset method is invoked.

  • runnerFinish - This event gets fired when the runner reaches the stopAt value.

Each of these events will pass the result of the info method as an argument in the event call. See examples for usage.

Examples

Initialize a count down runner that starts from 60 seconds, and start it automatically:

$('#runner').runner({autostart: true,countdown: true,startAt: 60000// alternatively you could just write: 60*1000});

Initialize a count up runner that stops after 2 minutes:

$('#runner').runner({stopAt: 120000// 2(min) * 60(sec) * 1000(ms) = 120000});

Initialize a count down runner that starts from 30 seconds, updates the value once every second and doesn't show milliseconds:

$('#runner').runner({countdown: true,startAt: 30000,milliseconds: false,});

Initialize a normal count up runner with a custom formatter function that displays the time in minutes (with decimals):

$('#runner').runner({format: function(value){return(value/1000)/60;}});

Initialize a count down runner that starts from 12 minutes and stops at 0, and alerts when the runner finishes:

$('#runner').runner({countdown: true,startAt: 12*60*1000,stopAt: 0}).on('runnerFinish',function(eventObject,info){alert('The eggs are now hard-boiled!');});

Changelog

v2.3.3 - 2014-08-06 - Small improvement

  • Made the non-vendor specific requestAnimationFrame the primary one to suppress deprecation error messages.

v2.3.2 - 2014-05-28 - Bug fix

  • Another jQuery noConflict related fix. Hopefully the last.

v2.3.1 - 2014-05-24 - Improvements and fixes

  • Fixed a bug when running jQuery in noConflict mode.

v2.3.0 - 2013-07-14 - Improvements and fixes

  • Runner now utilizes requestAnimationFrame if applicable and falls back to setTimeout
  • Fixed a small bug with dependency checks
  • Removed ability to tweak the runner interval due to requestAnimationFrame change

v2.2.0 - 2013-05-24 - Feature improvements and fixes

  • Fixed a couple of small underlying bugs
  • The first lap-time value now takes under consideration if the startAt time was something else than 0
  • Lap-time now returns negative value if we are counting down

v2.1.3 - 2013-05-22 - Yet another bug fix release

  • I make a lot of bugs apparently
  • Runner lap wasn't returning the correct lap time, it's fixed now, I swear!

v2.1.2 - 2013-03-22 - Bug fix release

  • Fixed another woopsie.

v2.1.1 - 2013-02-07 - Bug fixes

  • Fixed a couple of woopsies.

v2.1.0 - 2013-01-18 - Changes to the API and bug fixes

  • The custom format function no longer gets the inbuilt formatter as a second parameter. You can access the runner's inbuilt formatter through $().runner.format.
  • The custom format function now gets the settings object as second parameter, which has the milliseconds -property that was given as 3rd parameter in the old version.
  • Added a way to stop the runner when calling reset method with a boolean true parameter.
  • Runner now fires a runnerFinish event after it reaches the stopAt value.
  • We now also fire a runnerReset event after the reset method is called.
  • Streamlined the other events to be more consistent.
    • runnerStarted is now runnerStart.
    • runnerStopped is now runnerStop.

v2.0.0 - 2013-01-17 - Rewrote the runner plugin with CoffeeScript

  • Backwards compatible with the 1.x release

v1.0.0 - eons ago - First version of the runner plugin

Development

Author

Jyrki Laurila

License (MIT)

WWWWWW||WWWWWW
W W W||W W W
||
( OO )__________
/ | \
/o o| MIT \
\___/||_||__||_|| *
|| || || ||
_||_|| _||_||
(__|__|(__|__|

Copyright © 2013 Jyrki Laurila

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Bitdeli Badge

About

A runner/stopwatch plugin for jQuery

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - innovationsforlearning/jquery-runner: A runner/stopwatch plugin for jQuery · GitHub
Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

Repository files navigation

runner: jQuery plugin

A simple runner/stopwatch jQuery plugin for counting time up and down.

Project Status

Dependency StatusdevDependency StatusBuild Status

Installation

Grab the latest version from the build/ folder.

There's several different versions of the file, but you only need one.

  • In case you want to develop against the Runner, you can pick the non-minified version jquery.runner.js.
  • If you want to deploy Runner with your site/app, pick either jquery.runner-min.js.
  • Or if you develop with CoffeeScript and really want to know what's happening there, grab the jquery.runner.coffee. (Disclaimer: no support provided for the CoffeeScript file. If you don't know what it is, don't use it.)

Include script after the jQuery library:

<scriptsrc="jquery.js" type="text/javascript"></script><scriptsrc="jquery.runner.js" type="text/javascript"></script>

Usage

First you need a container element where we can input the value of the runner:

<spanid="runner"></span>

Note that this allows you to use any kind of element (h1, div, span, td, li, input, etc), and gives you an easy way to style it any way you want. Just remember that everything inside the container will be replaced with the formatted time.

Then you initialize the runner to that element:

$('#runner').runner();

After that you can start the runner from a button click or some other event:

$('#myButton').click(function(){$('#runner').runner('start');});

More examples below

Methods

By default, when the runner method is invoked, the script will initialize itself to the selected element. If no options are given, the default values are used.

$('#runner').runner();

start - Start the runner. If runner is not already initialized, it will first initialize and then start itself. Fires runnerStart event.

$('#runner').runner('start');

stop - Stop the runner. Fires runnerStop event.

$('#runner').runner('stop');

lap - Take a lap time (time between the current time and time from the last checkpoint) and return it as a formatted string. Fires runnerLap event.

alert("Current lap time: "+$('#runner').runner('lap'));

toggle - Toggle between start and stop.

$('#runner').runner('toggle');

reset - Resets the time and settings to the original (initial) values. Fires runnerReset event. Note that if the runner is running when invoking this method, this does not stop the runner, it just resets the time back to where it started and continues from there.

$('#runner').runner('reset');

To stop the runner along with the reset, you can provide an additional boolean true parameter for the command.

$('#runner').runner('reset',true);

version - Returns the current version string of the runner plugin

$('#runner').runner('version');

info - Returns a JavaScript object with information about the current status of the runner.

$('#runner').runner('info');

Options

You can alter the behavior by passing options object to the initialization.

Here's a list of options you can use:

  • autostart - (boolean) If set to true, the runner will be started automatically after the initialization. Defaults to false. If set to true, will trigger runnerStart event once the runner starts.

  • countdown - (boolean) If set to true, the time will run down instead of up (default). Note that if you set this to true, you should also set startAt option, otherwise the time goes to negative.

  • startAt - (integer) Time in milliseconds from which the runner should start running. Defaults to 0.

  • stopAt - (integer) Time in milliseconds at which the runner should stop running and invoke the runnerStop and runnerFinish events. Default is null (don't stop). This works with both counting up and down, as long as the value is within the current run direction.

  • milliseconds - (boolean) If set to false, the default formatter will omit the milliseconds from displaying. Defaults to true (show milliseconds). Note that if you use a custom formatter, this option will not affect the first value of that custom formatter function. This property, however, is passed in the object as second argument.

  • format - (function) A custom format function to replace the default time formatting. By default this is not set. Takes in two arguments: first one is the current time value in milliseconds, second one is the settings object. This function should return a string or a number.

Events

There are 5 events that gets fired:

  • runnerStart - This event gets fired when the start method is invoked, or if autostart option is set to true. Basically when ever the runner starts (duh!).

  • runnerStop - This event gets fired when the stop method is invoked. Note that this event is also fired when the runner reaches the stopAt value.

  • runnerLap - This event gets fired when the lap method is invoked.

  • runnerReset - This event gets fired when the reset method is invoked.

  • runnerFinish - This event gets fired when the runner reaches the stopAt value.

Each of these events will pass the result of the info method as an argument in the event call. See examples for usage.

Examples

Initialize a count down runner that starts from 60 seconds, and start it automatically:

$('#runner').runner({autostart: true,countdown: true,startAt: 60000// alternatively you could just write: 60*1000});

Initialize a count up runner that stops after 2 minutes:

$('#runner').runner({stopAt: 120000// 2(min) * 60(sec) * 1000(ms) = 120000});

Initialize a count down runner that starts from 30 seconds, updates the value once every second and doesn't show milliseconds:

$('#runner').runner({countdown: true,startAt: 30000,milliseconds: false,});

Initialize a normal count up runner with a custom formatter function that displays the time in minutes (with decimals):

$('#runner').runner({format: function(value){return(value/1000)/60;}});

Initialize a count down runner that starts from 12 minutes and stops at 0, and alerts when the runner finishes:

$('#runner').runner({countdown: true,startAt: 12*60*1000,stopAt: 0}).on('runnerFinish',function(eventObject,info){alert('The eggs are now hard-boiled!');});

Changelog

v2.3.3 - 2014-08-06 - Small improvement

  • Made the non-vendor specific requestAnimationFrame the primary one to suppress deprecation error messages.

v2.3.2 - 2014-05-28 - Bug fix

  • Another jQuery noConflict related fix. Hopefully the last.

v2.3.1 - 2014-05-24 - Improvements and fixes

  • Fixed a bug when running jQuery in noConflict mode.

v2.3.0 - 2013-07-14 - Improvements and fixes

  • Runner now utilizes requestAnimationFrame if applicable and falls back to setTimeout
  • Fixed a small bug with dependency checks
  • Removed ability to tweak the runner interval due to requestAnimationFrame change

v2.2.0 - 2013-05-24 - Feature improvements and fixes

  • Fixed a couple of small underlying bugs
  • The first lap-time value now takes under consideration if the startAt time was something else than 0
  • Lap-time now returns negative value if we are counting down

v2.1.3 - 2013-05-22 - Yet another bug fix release

  • I make a lot of bugs apparently
  • Runner lap wasn't returning the correct lap time, it's fixed now, I swear!

v2.1.2 - 2013-03-22 - Bug fix release

  • Fixed another woopsie.

v2.1.1 - 2013-02-07 - Bug fixes

  • Fixed a couple of woopsies.

v2.1.0 - 2013-01-18 - Changes to the API and bug fixes

  • The custom format function no longer gets the inbuilt formatter as a second parameter. You can access the runner's inbuilt formatter through $().runner.format.
  • The custom format function now gets the settings object as second parameter, which has the milliseconds -property that was given as 3rd parameter in the old version.
  • Added a way to stop the runner when calling reset method with a boolean true parameter.
  • Runner now fires a runnerFinish event after it reaches the stopAt value.
  • We now also fire a runnerReset event after the reset method is called.
  • Streamlined the other events to be more consistent.
    • runnerStarted is now runnerStart.
    • runnerStopped is now runnerStop.

v2.0.0 - 2013-01-17 - Rewrote the runner plugin with CoffeeScript

  • Backwards compatible with the 1.x release

v1.0.0 - eons ago - First version of the runner plugin

Development

Author

Jyrki Laurila

License (MIT)

WWWWWW||WWWWWW
W W W||W W W
||
( OO )__________
/ | \
/o o| MIT \
\___/||_||__||_|| *
|| || || ||
_||_|| _||_||
(__|__|(__|__|

Copyright © 2013 Jyrki Laurila

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Bitdeli Badge

About

A runner/stopwatch plugin for jQuery

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' GitHub - innovationsforlearning/jquery-runner: A runner/stopwatch plugin for jQuery · GitHub
Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

Repository files navigation

runner: jQuery plugin

A simple runner/stopwatch jQuery plugin for counting time up and down.

Project Status

Dependency StatusdevDependency StatusBuild Status

Installation

Grab the latest version from the build/ folder.

There's several different versions of the file, but you only need one.

  • In case you want to develop against the Runner, you can pick the non-minified version jquery.runner.js.
  • If you want to deploy Runner with your site/app, pick either jquery.runner-min.js.
  • Or if you develop with CoffeeScript and really want to know what's happening there, grab the jquery.runner.coffee. (Disclaimer: no support provided for the CoffeeScript file. If you don't know what it is, don't use it.)

Include script after the jQuery library:

<scriptsrc="jquery.js" type="text/javascript"></script><scriptsrc="jquery.runner.js" type="text/javascript"></script>

Usage

First you need a container element where we can input the value of the runner:

<spanid="runner"></span>

Note that this allows you to use any kind of element (h1, div, span, td, li, input, etc), and gives you an easy way to style it any way you want. Just remember that everything inside the container will be replaced with the formatted time.

Then you initialize the runner to that element:

$('#runner').runner();

After that you can start the runner from a button click or some other event:

$('#myButton').click(function(){$('#runner').runner('start');});

More examples below

Methods

By default, when the runner method is invoked, the script will initialize itself to the selected element. If no options are given, the default values are used.

$('#runner').runner();

start - Start the runner. If runner is not already initialized, it will first initialize and then start itself. Fires runnerStart event.

$('#runner').runner('start');

stop - Stop the runner. Fires runnerStop event.

$('#runner').runner('stop');

lap - Take a lap time (time between the current time and time from the last checkpoint) and return it as a formatted string. Fires runnerLap event.

alert("Current lap time: "+$('#runner').runner('lap'));

toggle - Toggle between start and stop.

$('#runner').runner('toggle');

reset - Resets the time and settings to the original (initial) values. Fires runnerReset event. Note that if the runner is running when invoking this method, this does not stop the runner, it just resets the time back to where it started and continues from there.

$('#runner').runner('reset');

To stop the runner along with the reset, you can provide an additional boolean true parameter for the command.

$('#runner').runner('reset',true);

version - Returns the current version string of the runner plugin

$('#runner').runner('version');

info - Returns a JavaScript object with information about the current status of the runner.

$('#runner').runner('info');

Options

You can alter the behavior by passing options object to the initialization.

Here's a list of options you can use:

  • autostart - (boolean) If set to true, the runner will be started automatically after the initialization. Defaults to false. If set to true, will trigger runnerStart event once the runner starts.

  • countdown - (boolean) If set to true, the time will run down instead of up (default). Note that if you set this to true, you should also set startAt option, otherwise the time goes to negative.

  • startAt - (integer) Time in milliseconds from which the runner should start running. Defaults to 0.

  • stopAt - (integer) Time in milliseconds at which the runner should stop running and invoke the runnerStop and runnerFinish events. Default is null (don't stop). This works with both counting up and down, as long as the value is within the current run direction.

  • milliseconds - (boolean) If set to false, the default formatter will omit the milliseconds from displaying. Defaults to true (show milliseconds). Note that if you use a custom formatter, this option will not affect the first value of that custom formatter function. This property, however, is passed in the object as second argument.

  • format - (function) A custom format function to replace the default time formatting. By default this is not set. Takes in two arguments: first one is the current time value in milliseconds, second one is the settings object. This function should return a string or a number.

Events

There are 5 events that gets fired:

  • runnerStart - This event gets fired when the start method is invoked, or if autostart option is set to true. Basically when ever the runner starts (duh!).

  • runnerStop - This event gets fired when the stop method is invoked. Note that this event is also fired when the runner reaches the stopAt value.

  • runnerLap - This event gets fired when the lap method is invoked.

  • runnerReset - This event gets fired when the reset method is invoked.

  • runnerFinish - This event gets fired when the runner reaches the stopAt value.

Each of these events will pass the result of the info method as an argument in the event call. See examples for usage.

Examples

Initialize a count down runner that starts from 60 seconds, and start it automatically:

$('#runner').runner({autostart: true,countdown: true,startAt: 60000// alternatively you could just write: 60*1000});

Initialize a count up runner that stops after 2 minutes:

$('#runner').runner({stopAt: 120000// 2(min) * 60(sec) * 1000(ms) = 120000});

Initialize a count down runner that starts from 30 seconds, updates the value once every second and doesn't show milliseconds:

$('#runner').runner({countdown: true,startAt: 30000,milliseconds: false,});

Initialize a normal count up runner with a custom formatter function that displays the time in minutes (with decimals):

$('#runner').runner({format: function(value){return(value/1000)/60;}});

Initialize a count down runner that starts from 12 minutes and stops at 0, and alerts when the runner finishes:

$('#runner').runner({countdown: true,startAt: 12*60*1000,stopAt: 0}).on('runnerFinish',function(eventObject,info){alert('The eggs are now hard-boiled!');});

Changelog

v2.3.3 - 2014-08-06 - Small improvement

  • Made the non-vendor specific requestAnimationFrame the primary one to suppress deprecation error messages.

v2.3.2 - 2014-05-28 - Bug fix

  • Another jQuery noConflict related fix. Hopefully the last.

v2.3.1 - 2014-05-24 - Improvements and fixes

  • Fixed a bug when running jQuery in noConflict mode.

v2.3.0 - 2013-07-14 - Improvements and fixes

  • Runner now utilizes requestAnimationFrame if applicable and falls back to setTimeout
  • Fixed a small bug with dependency checks
  • Removed ability to tweak the runner interval due to requestAnimationFrame change

v2.2.0 - 2013-05-24 - Feature improvements and fixes

  • Fixed a couple of small underlying bugs
  • The first lap-time value now takes under consideration if the startAt time was something else than 0
  • Lap-time now returns negative value if we are counting down

v2.1.3 - 2013-05-22 - Yet another bug fix release

  • I make a lot of bugs apparently
  • Runner lap wasn't returning the correct lap time, it's fixed now, I swear!

v2.1.2 - 2013-03-22 - Bug fix release

  • Fixed another woopsie.

v2.1.1 - 2013-02-07 - Bug fixes

  • Fixed a couple of woopsies.

v2.1.0 - 2013-01-18 - Changes to the API and bug fixes

  • The custom format function no longer gets the inbuilt formatter as a second parameter. You can access the runner's inbuilt formatter through $().runner.format.
  • The custom format function now gets the settings object as second parameter, which has the milliseconds -property that was given as 3rd parameter in the old version.
  • Added a way to stop the runner when calling reset method with a boolean true parameter.
  • Runner now fires a runnerFinish event after it reaches the stopAt value.
  • We now also fire a runnerReset event after the reset method is called.
  • Streamlined the other events to be more consistent.
    • runnerStarted is now runnerStart.
    • runnerStopped is now runnerStop.

v2.0.0 - 2013-01-17 - Rewrote the runner plugin with CoffeeScript

  • Backwards compatible with the 1.x release

v1.0.0 - eons ago - First version of the runner plugin

Development

Author

Jyrki Laurila

License (MIT)

WWWWWW||WWWWWW
W W W||W W W
||
( OO )__________
/ | \
/o o| MIT \
\___/||_||__||_|| *
|| || || ||
_||_|| _||_||
(__|__|(__|__|

Copyright © 2013 Jyrki Laurila

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Bitdeli Badge

About

A runner/stopwatch plugin for jQuery

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - innovationsforlearning/jquery-runner: A runner/stopwatch plugin for jQuery · GitHub
Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

Repository files navigation

runner: jQuery plugin

A simple runner/stopwatch jQuery plugin for counting time up and down.

Project Status

Dependency StatusdevDependency StatusBuild Status

Installation

Grab the latest version from the build/ folder.

There's several different versions of the file, but you only need one.

  • In case you want to develop against the Runner, you can pick the non-minified version jquery.runner.js.
  • If you want to deploy Runner with your site/app, pick either jquery.runner-min.js.
  • Or if you develop with CoffeeScript and really want to know what's happening there, grab the jquery.runner.coffee. (Disclaimer: no support provided for the CoffeeScript file. If you don't know what it is, don't use it.)

Include script after the jQuery library:

<scriptsrc="jquery.js" type="text/javascript"></script><scriptsrc="jquery.runner.js" type="text/javascript"></script>

Usage

First you need a container element where we can input the value of the runner:

<spanid="runner"></span>

Note that this allows you to use any kind of element (h1, div, span, td, li, input, etc), and gives you an easy way to style it any way you want. Just remember that everything inside the container will be replaced with the formatted time.

Then you initialize the runner to that element:

$('#runner').runner();

After that you can start the runner from a button click or some other event:

$('#myButton').click(function(){$('#runner').runner('start');});

More examples below

Methods

By default, when the runner method is invoked, the script will initialize itself to the selected element. If no options are given, the default values are used.

$('#runner').runner();

start - Start the runner. If runner is not already initialized, it will first initialize and then start itself. Fires runnerStart event.

$('#runner').runner('start');

stop - Stop the runner. Fires runnerStop event.

$('#runner').runner('stop');

lap - Take a lap time (time between the current time and time from the last checkpoint) and return it as a formatted string. Fires runnerLap event.

alert("Current lap time: "+$('#runner').runner('lap'));

toggle - Toggle between start and stop.

$('#runner').runner('toggle');

reset - Resets the time and settings to the original (initial) values. Fires runnerReset event. Note that if the runner is running when invoking this method, this does not stop the runner, it just resets the time back to where it started and continues from there.

$('#runner').runner('reset');

To stop the runner along with the reset, you can provide an additional boolean true parameter for the command.

$('#runner').runner('reset',true);

version - Returns the current version string of the runner plugin

$('#runner').runner('version');

info - Returns a JavaScript object with information about the current status of the runner.

$('#runner').runner('info');

Options

You can alter the behavior by passing options object to the initialization.

Here's a list of options you can use:

  • autostart - (boolean) If set to true, the runner will be started automatically after the initialization. Defaults to false. If set to true, will trigger runnerStart event once the runner starts.

  • countdown - (boolean) If set to true, the time will run down instead of up (default). Note that if you set this to true, you should also set startAt option, otherwise the time goes to negative.

  • startAt - (integer) Time in milliseconds from which the runner should start running. Defaults to 0.

  • stopAt - (integer) Time in milliseconds at which the runner should stop running and invoke the runnerStop and runnerFinish events. Default is null (don't stop). This works with both counting up and down, as long as the value is within the current run direction.

  • milliseconds - (boolean) If set to false, the default formatter will omit the milliseconds from displaying. Defaults to true (show milliseconds). Note that if you use a custom formatter, this option will not affect the first value of that custom formatter function. This property, however, is passed in the object as second argument.

  • format - (function) A custom format function to replace the default time formatting. By default this is not set. Takes in two arguments: first one is the current time value in milliseconds, second one is the settings object. This function should return a string or a number.

Events

There are 5 events that gets fired:

  • runnerStart - This event gets fired when the start method is invoked, or if autostart option is set to true. Basically when ever the runner starts (duh!).

  • runnerStop - This event gets fired when the stop method is invoked. Note that this event is also fired when the runner reaches the stopAt value.

  • runnerLap - This event gets fired when the lap method is invoked.

  • runnerReset - This event gets fired when the reset method is invoked.

  • runnerFinish - This event gets fired when the runner reaches the stopAt value.

Each of these events will pass the result of the info method as an argument in the event call. See examples for usage.

Examples

Initialize a count down runner that starts from 60 seconds, and start it automatically:

$('#runner').runner({autostart: true,countdown: true,startAt: 60000// alternatively you could just write: 60*1000});

Initialize a count up runner that stops after 2 minutes:

$('#runner').runner({stopAt: 120000// 2(min) * 60(sec) * 1000(ms) = 120000});

Initialize a count down runner that starts from 30 seconds, updates the value once every second and doesn't show milliseconds:

$('#runner').runner({countdown: true,startAt: 30000,milliseconds: false,});

Initialize a normal count up runner with a custom formatter function that displays the time in minutes (with decimals):

$('#runner').runner({format: function(value){return(value/1000)/60;}});

Initialize a count down runner that starts from 12 minutes and stops at 0, and alerts when the runner finishes:

$('#runner').runner({countdown: true,startAt: 12*60*1000,stopAt: 0}).on('runnerFinish',function(eventObject,info){alert('The eggs are now hard-boiled!');});

Changelog

v2.3.3 - 2014-08-06 - Small improvement

  • Made the non-vendor specific requestAnimationFrame the primary one to suppress deprecation error messages.

v2.3.2 - 2014-05-28 - Bug fix

  • Another jQuery noConflict related fix. Hopefully the last.

v2.3.1 - 2014-05-24 - Improvements and fixes

  • Fixed a bug when running jQuery in noConflict mode.

v2.3.0 - 2013-07-14 - Improvements and fixes

  • Runner now utilizes requestAnimationFrame if applicable and falls back to setTimeout
  • Fixed a small bug with dependency checks
  • Removed ability to tweak the runner interval due to requestAnimationFrame change

v2.2.0 - 2013-05-24 - Feature improvements and fixes

  • Fixed a couple of small underlying bugs
  • The first lap-time value now takes under consideration if the startAt time was something else than 0
  • Lap-time now returns negative value if we are counting down

v2.1.3 - 2013-05-22 - Yet another bug fix release

  • I make a lot of bugs apparently
  • Runner lap wasn't returning the correct lap time, it's fixed now, I swear!

v2.1.2 - 2013-03-22 - Bug fix release

  • Fixed another woopsie.

v2.1.1 - 2013-02-07 - Bug fixes

  • Fixed a couple of woopsies.

v2.1.0 - 2013-01-18 - Changes to the API and bug fixes

  • The custom format function no longer gets the inbuilt formatter as a second parameter. You can access the runner's inbuilt formatter through $().runner.format.
  • The custom format function now gets the settings object as second parameter, which has the milliseconds -property that was given as 3rd parameter in the old version.
  • Added a way to stop the runner when calling reset method with a boolean true parameter.
  • Runner now fires a runnerFinish event after it reaches the stopAt value.
  • We now also fire a runnerReset event after the reset method is called.
  • Streamlined the other events to be more consistent.
    • runnerStarted is now runnerStart.
    • runnerStopped is now runnerStop.

v2.0.0 - 2013-01-17 - Rewrote the runner plugin with CoffeeScript

  • Backwards compatible with the 1.x release

v1.0.0 - eons ago - First version of the runner plugin

Development

Author

Jyrki Laurila

License (MIT)

WWWWWW||WWWWWW
W W W||W W W
||
( OO )__________
/ | \
/o o| MIT \
\___/||_||__||_|| *
|| || || ||
_||_|| _||_||
(__|__|(__|__|

Copyright © 2013 Jyrki Laurila

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Bitdeli Badge

About

A runner/stopwatch plugin for jQuery

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - innovationsforlearning/jquery-runner: A runner/stopwatch plugin for jQuery · GitHub
Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

Repository files navigation

runner: jQuery plugin

A simple runner/stopwatch jQuery plugin for counting time up and down.

Project Status

Dependency StatusdevDependency StatusBuild Status

Installation

Grab the latest version from the build/ folder.

There's several different versions of the file, but you only need one.

  • In case you want to develop against the Runner, you can pick the non-minified version jquery.runner.js.
  • If you want to deploy Runner with your site/app, pick either jquery.runner-min.js.
  • Or if you develop with CoffeeScript and really want to know what's happening there, grab the jquery.runner.coffee. (Disclaimer: no support provided for the CoffeeScript file. If you don't know what it is, don't use it.)

Include script after the jQuery library:

<scriptsrc="jquery.js" type="text/javascript"></script><scriptsrc="jquery.runner.js" type="text/javascript"></script>

Usage

First you need a container element where we can input the value of the runner:

<spanid="runner"></span>

Note that this allows you to use any kind of element (h1, div, span, td, li, input, etc), and gives you an easy way to style it any way you want. Just remember that everything inside the container will be replaced with the formatted time.

Then you initialize the runner to that element:

$('#runner').runner();

After that you can start the runner from a button click or some other event:

$('#myButton').click(function(){$('#runner').runner('start');});

More examples below

Methods

By default, when the runner method is invoked, the script will initialize itself to the selected element. If no options are given, the default values are used.

$('#runner').runner();

start - Start the runner. If runner is not already initialized, it will first initialize and then start itself. Fires runnerStart event.

$('#runner').runner('start');

stop - Stop the runner. Fires runnerStop event.

$('#runner').runner('stop');

lap - Take a lap time (time between the current time and time from the last checkpoint) and return it as a formatted string. Fires runnerLap event.

alert("Current lap time: "+$('#runner').runner('lap'));

toggle - Toggle between start and stop.

$('#runner').runner('toggle');

reset - Resets the time and settings to the original (initial) values. Fires runnerReset event. Note that if the runner is running when invoking this method, this does not stop the runner, it just resets the time back to where it started and continues from there.

$('#runner').runner('reset');

To stop the runner along with the reset, you can provide an additional boolean true parameter for the command.

$('#runner').runner('reset',true);

version - Returns the current version string of the runner plugin

$('#runner').runner('version');

info - Returns a JavaScript object with information about the current status of the runner.

$('#runner').runner('info');

Options

You can alter the behavior by passing options object to the initialization.

Here's a list of options you can use:

  • autostart - (boolean) If set to true, the runner will be started automatically after the initialization. Defaults to false. If set to true, will trigger runnerStart event once the runner starts.

  • countdown - (boolean) If set to true, the time will run down instead of up (default). Note that if you set this to true, you should also set startAt option, otherwise the time goes to negative.

  • startAt - (integer) Time in milliseconds from which the runner should start running. Defaults to 0.

  • stopAt - (integer) Time in milliseconds at which the runner should stop running and invoke the runnerStop and runnerFinish events. Default is null (don't stop). This works with both counting up and down, as long as the value is within the current run direction.

  • milliseconds - (boolean) If set to false, the default formatter will omit the milliseconds from displaying. Defaults to true (show milliseconds). Note that if you use a custom formatter, this option will not affect the first value of that custom formatter function. This property, however, is passed in the object as second argument.

  • format - (function) A custom format function to replace the default time formatting. By default this is not set. Takes in two arguments: first one is the current time value in milliseconds, second one is the settings object. This function should return a string or a number.

Events

There are 5 events that gets fired:

  • runnerStart - This event gets fired when the start method is invoked, or if autostart option is set to true. Basically when ever the runner starts (duh!).

  • runnerStop - This event gets fired when the stop method is invoked. Note that this event is also fired when the runner reaches the stopAt value.

  • runnerLap - This event gets fired when the lap method is invoked.

  • runnerReset - This event gets fired when the reset method is invoked.

  • runnerFinish - This event gets fired when the runner reaches the stopAt value.

Each of these events will pass the result of the info method as an argument in the event call. See examples for usage.

Examples

Initialize a count down runner that starts from 60 seconds, and start it automatically:

$('#runner').runner({autostart: true,countdown: true,startAt: 60000// alternatively you could just write: 60*1000});

Initialize a count up runner that stops after 2 minutes:

$('#runner').runner({stopAt: 120000// 2(min) * 60(sec) * 1000(ms) = 120000});

Initialize a count down runner that starts from 30 seconds, updates the value once every second and doesn't show milliseconds:

$('#runner').runner({countdown: true,startAt: 30000,milliseconds: false,});

Initialize a normal count up runner with a custom formatter function that displays the time in minutes (with decimals):

$('#runner').runner({format: function(value){return(value/1000)/60;}});

Initialize a count down runner that starts from 12 minutes and stops at 0, and alerts when the runner finishes:

$('#runner').runner({countdown: true,startAt: 12*60*1000,stopAt: 0}).on('runnerFinish',function(eventObject,info){alert('The eggs are now hard-boiled!');});

Changelog

v2.3.3 - 2014-08-06 - Small improvement

  • Made the non-vendor specific requestAnimationFrame the primary one to suppress deprecation error messages.

v2.3.2 - 2014-05-28 - Bug fix

  • Another jQuery noConflict related fix. Hopefully the last.

v2.3.1 - 2014-05-24 - Improvements and fixes

  • Fixed a bug when running jQuery in noConflict mode.

v2.3.0 - 2013-07-14 - Improvements and fixes

  • Runner now utilizes requestAnimationFrame if applicable and falls back to setTimeout
  • Fixed a small bug with dependency checks
  • Removed ability to tweak the runner interval due to requestAnimationFrame change

v2.2.0 - 2013-05-24 - Feature improvements and fixes

  • Fixed a couple of small underlying bugs
  • The first lap-time value now takes under consideration if the startAt time was something else than 0
  • Lap-time now returns negative value if we are counting down

v2.1.3 - 2013-05-22 - Yet another bug fix release

  • I make a lot of bugs apparently
  • Runner lap wasn't returning the correct lap time, it's fixed now, I swear!

v2.1.2 - 2013-03-22 - Bug fix release

  • Fixed another woopsie.

v2.1.1 - 2013-02-07 - Bug fixes

  • Fixed a couple of woopsies.

v2.1.0 - 2013-01-18 - Changes to the API and bug fixes

  • The custom format function no longer gets the inbuilt formatter as a second parameter. You can access the runner's inbuilt formatter through $().runner.format.
  • The custom format function now gets the settings object as second parameter, which has the milliseconds -property that was given as 3rd parameter in the old version.
  • Added a way to stop the runner when calling reset method with a boolean true parameter.
  • Runner now fires a runnerFinish event after it reaches the stopAt value.
  • We now also fire a runnerReset event after the reset method is called.
  • Streamlined the other events to be more consistent.
    • runnerStarted is now runnerStart.
    • runnerStopped is now runnerStop.

v2.0.0 - 2013-01-17 - Rewrote the runner plugin with CoffeeScript

  • Backwards compatible with the 1.x release

v1.0.0 - eons ago - First version of the runner plugin

Development

Author

Jyrki Laurila

License (MIT)

WWWWWW||WWWWWW
W W W||W W W
||
( OO )__________
/ | \
/o o| MIT \
\___/||_||__||_|| *
|| || || ||
_||_|| _||_||
(__|__|(__|__|

Copyright © 2013 Jyrki Laurila

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Bitdeli Badge

About

A runner/stopwatch plugin for jQuery

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); GitHub - innovationsforlearning/jquery-runner: A runner/stopwatch plugin for jQuery · GitHub
Skip to content
This repository was archived by the owner on Sep 30, 2025. It is now read-only.

Repository files navigation

runner: jQuery plugin

A simple runner/stopwatch jQuery plugin for counting time up and down.

Project Status

Dependency StatusdevDependency StatusBuild Status

Installation

Grab the latest version from the build/ folder.

There's several different versions of the file, but you only need one.

  • In case you want to develop against the Runner, you can pick the non-minified version jquery.runner.js.
  • If you want to deploy Runner with your site/app, pick either jquery.runner-min.js.
  • Or if you develop with CoffeeScript and really want to know what's happening there, grab the jquery.runner.coffee. (Disclaimer: no support provided for the CoffeeScript file. If you don't know what it is, don't use it.)

Include script after the jQuery library:

<scriptsrc="jquery.js" type="text/javascript"></script><scriptsrc="jquery.runner.js" type="text/javascript"></script>

Usage

First you need a container element where we can input the value of the runner:

<spanid="runner"></span>

Note that this allows you to use any kind of element (h1, div, span, td, li, input, etc), and gives you an easy way to style it any way you want. Just remember that everything inside the container will be replaced with the formatted time.

Then you initialize the runner to that element:

$('#runner').runner();

After that you can start the runner from a button click or some other event:

$('#myButton').click(function(){$('#runner').runner('start');});

More examples below

Methods

By default, when the runner method is invoked, the script will initialize itself to the selected element. If no options are given, the default values are used.

$('#runner').runner();

start - Start the runner. If runner is not already initialized, it will first initialize and then start itself. Fires runnerStart event.

$('#runner').runner('start');

stop - Stop the runner. Fires runnerStop event.

$('#runner').runner('stop');

lap - Take a lap time (time between the current time and time from the last checkpoint) and return it as a formatted string. Fires runnerLap event.

alert("Current lap time: "+$('#runner').runner('lap'));

toggle - Toggle between start and stop.

$('#runner').runner('toggle');

reset - Resets the time and settings to the original (initial) values. Fires runnerReset event. Note that if the runner is running when invoking this method, this does not stop the runner, it just resets the time back to where it started and continues from there.

$('#runner').runner('reset');

To stop the runner along with the reset, you can provide an additional boolean true parameter for the command.

$('#runner').runner('reset',true);

version - Returns the current version string of the runner plugin

$('#runner').runner('version');

info - Returns a JavaScript object with information about the current status of the runner.

$('#runner').runner('info');

Options

You can alter the behavior by passing options object to the initialization.

Here's a list of options you can use:

  • autostart - (boolean) If set to true, the runner will be started automatically after the initialization. Defaults to false. If set to true, will trigger runnerStart event once the runner starts.

  • countdown - (boolean) If set to true, the time will run down instead of up (default). Note that if you set this to true, you should also set startAt option, otherwise the time goes to negative.

  • startAt - (integer) Time in milliseconds from which the runner should start running. Defaults to 0.

  • stopAt - (integer) Time in milliseconds at which the runner should stop running and invoke the runnerStop and runnerFinish events. Default is null (don't stop). This works with both counting up and down, as long as the value is within the current run direction.

  • milliseconds - (boolean) If set to false, the default formatter will omit the milliseconds from displaying. Defaults to true (show milliseconds). Note that if you use a custom formatter, this option will not affect the first value of that custom formatter function. This property, however, is passed in the object as second argument.

  • format - (function) A custom format function to replace the default time formatting. By default this is not set. Takes in two arguments: first one is the current time value in milliseconds, second one is the settings object. This function should return a string or a number.

Events

There are 5 events that gets fired:

  • runnerStart - This event gets fired when the start method is invoked, or if autostart option is set to true. Basically when ever the runner starts (duh!).

  • runnerStop - This event gets fired when the stop method is invoked. Note that this event is also fired when the runner reaches the stopAt value.

  • runnerLap - This event gets fired when the lap method is invoked.

  • runnerReset - This event gets fired when the reset method is invoked.

  • runnerFinish - This event gets fired when the runner reaches the stopAt value.

Each of these events will pass the result of the info method as an argument in the event call. See examples for usage.

Examples

Initialize a count down runner that starts from 60 seconds, and start it automatically:

$('#runner').runner({autostart: true,countdown: true,startAt: 60000// alternatively you could just write: 60*1000});

Initialize a count up runner that stops after 2 minutes:

$('#runner').runner({stopAt: 120000// 2(min) * 60(sec) * 1000(ms) = 120000});

Initialize a count down runner that starts from 30 seconds, updates the value once every second and doesn't show milliseconds:

$('#runner').runner({countdown: true,startAt: 30000,milliseconds: false,});

Initialize a normal count up runner with a custom formatter function that displays the time in minutes (with decimals):

$('#runner').runner({format: function(value){return(value/1000)/60;}});

Initialize a count down runner that starts from 12 minutes and stops at 0, and alerts when the runner finishes:

$('#runner').runner({countdown: true,startAt: 12*60*1000,stopAt: 0}).on('runnerFinish',function(eventObject,info){alert('The eggs are now hard-boiled!');});

Changelog

v2.3.3 - 2014-08-06 - Small improvement

  • Made the non-vendor specific requestAnimationFrame the primary one to suppress deprecation error messages.

v2.3.2 - 2014-05-28 - Bug fix

  • Another jQuery noConflict related fix. Hopefully the last.

v2.3.1 - 2014-05-24 - Improvements and fixes

  • Fixed a bug when running jQuery in noConflict mode.

v2.3.0 - 2013-07-14 - Improvements and fixes

  • Runner now utilizes requestAnimationFrame if applicable and falls back to setTimeout
  • Fixed a small bug with dependency checks
  • Removed ability to tweak the runner interval due to requestAnimationFrame change

v2.2.0 - 2013-05-24 - Feature improvements and fixes

  • Fixed a couple of small underlying bugs
  • The first lap-time value now takes under consideration if the startAt time was something else than 0
  • Lap-time now returns negative value if we are counting down

v2.1.3 - 2013-05-22 - Yet another bug fix release

  • I make a lot of bugs apparently
  • Runner lap wasn't returning the correct lap time, it's fixed now, I swear!

v2.1.2 - 2013-03-22 - Bug fix release

  • Fixed another woopsie.

v2.1.1 - 2013-02-07 - Bug fixes

  • Fixed a couple of woopsies.

v2.1.0 - 2013-01-18 - Changes to the API and bug fixes

  • The custom format function no longer gets the inbuilt formatter as a second parameter. You can access the runner's inbuilt formatter through $().runner.format.
  • The custom format function now gets the settings object as second parameter, which has the milliseconds -property that was given as 3rd parameter in the old version.
  • Added a way to stop the runner when calling reset method with a boolean true parameter.
  • Runner now fires a runnerFinish event after it reaches the stopAt value.
  • We now also fire a runnerReset event after the reset method is called.
  • Streamlined the other events to be more consistent.
    • runnerStarted is now runnerStart.
    • runnerStopped is now runnerStop.

v2.0.0 - 2013-01-17 - Rewrote the runner plugin with CoffeeScript

  • Backwards compatible with the 1.x release

v1.0.0 - eons ago - First version of the runner plugin

Development

Author

Jyrki Laurila

License (MIT)

WWWWWW||WWWWWW
W W W||W W W
||
( OO )__________
/ | \
/o o| MIT \
\___/||_||__||_|| *
|| || || ||
_||_|| _||_||
(__|__|(__|__|

Copyright © 2013 Jyrki Laurila

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Bitdeli Badge

About

A runner/stopwatch plugin for jQuery

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors