Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anti-work/countdown.js
Super simple countdowns.
https://github.com/anti-work/countdown.js
Last synced: about 1 month ago
JSON representation
Super simple countdowns.
- Host: GitHub
- URL: https://github.com/anti-work/countdown.js
- Owner: anti-work
- License: mit
- Created: 2013-07-09T22:30:12.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-09-21T15:08:57.000Z (over 11 years ago)
- Last Synced: 2024-10-28T03:57:37.581Z (about 2 months ago)
- Language: JavaScript
- Homepage: gumroad.github.io/countdown.js/
- Size: 168 KB
- Stars: 406
- Watchers: 29
- Forks: 27
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-javascript - countdown.js - Super simple countdowns. - ★ 384 (Date)
README
# Countdown.js [![Build Status](https://travis-ci.org/gumroad/countdown.js.png)](https://travis-ci.org/gumroad/countdown.js)
Countdown.js is a library that allows developers to set countdowns for any kind of interaction. For example, if you would
like to submit a form, Countdown.js allows you to set a 5 second countdown and give the user a chance to cancel the
submission. You can see it in action [here](http://gumroad.github.io/countdown.js/).## Installation
If you use bower:
```
bower install countdown.js
```Otherwise, you can download it from [here](https://raw.github.com/gumroad/countdown.js/master/lib/countdown.js).
## API
### new Countdown(duration, onTick, onComplete)
Begins a countdown. After `duration` time has passed, the function `onComplete `will be executed. Every second, the `onTick`
function will be executed.Example:
```javascript
var countdown = new Countdown(5, function(seconds) {
console.log(seconds); //log the number of seconds that have passed
}, function() {
console.log("Countdown complete!") //log that the countdown has complete
});
```### abort()
Terminates countdown.
Example:
```javascript
countdown.abort();
```### getRemainingTime()
Returns remaining time in seconds.
Example:
```javascript
countdown.getRemainingTime(); //=> 4
```## Example
[http://gumroad.github.io/countdown.js/](http://gumroad.github.io/countdown.js/)
## Contribute
Install development dependencies
```
npm install
```## Test
```
npm test
```