Skip to content

Commit

Permalink
Merge pull request #21 from albert-gonzalez/node_refactor
Browse files Browse the repository at this point in the history
Library refactor using Rollup + Babel
  • Loading branch information
albert-gonzalez authored Sep 30, 2017
2 parents 154441d + 231185f commit 74f6a1e
Show file tree
Hide file tree
Showing 24 changed files with 2,682 additions and 1,390 deletions.
12 changes: 12 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "standard",
"rules": {
"semi": ["error", "always"]
},
"env": {
"browser": true,
"node": true,
"amd": true,
"mocha": true
}
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bower_components/*
node_modules/*
.idea/*
.idea/*
.vscode/*
8 changes: 8 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
test/*
.eslintrc.json
.gitignore
bower.json
rollup.config.js
dist/examples*
src/examples/*
index.html
18 changes: 0 additions & 18 deletions Gruntfile.js

This file was deleted.

88 changes: 86 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,95 @@
easytimer.js
============

[![npm version](https://badge.fury.io/js/easytimer.js.svg)](https://badge.fury.io/js/easytimer.js)

Easy to use Timer/Chronometer/Countdown library compatible with AMD and NodeJS

Check out the examples here: http://albert-gonzalez.github.io/easytimer.js/
## Install

### NPM
```
npm install easytimer.js --save
````
### Bower
```
bower install easytimer.js
```
## Library Load
### Script
```html
<script src="lib/easytimer/dist/easytimer.min.js"></script>
<script>
var timerInstance = new Timer();
</script>
```

### Node

```js
var Timer = require('easytimer.js');
var timerInstance = new Timer();
```

### AMD

```js
require(['node_modules/easytimer.js/dist/easytimer.min.js'], function (Timer) {
var timer = new Timer();
});
```

## Examples

http://albert-gonzalez.github.io/easytimer.js/

## Basic Usage

```js
var timer = new Timer();
timer.start();
timer.addEventListener('secondsUpdated', function (e) {
$('#basicUsage').html(timer.getTimeValues().toString());
});
```

## Timer instance API

Documentation will be available soon!
* start(config): Start the timer
* Parameters:
* config (object):
* startValues (object or array): The initial values of the timer when it is started
* Accepted Values: Object with some of this keys: 'secondTenths', 'seconds', 'minutes', 'hours', 'days'. Or an array with this 5 positions: [secondTenths, seconds, minutes, hours, days]
* Default Value (object or array): [0,0,0,0,0]
* target (object or array): The target values that will make timer to stop.
* Accepted Values: Object with some of this keys: 'secondTenths', 'seconds', 'minutes', 'hours', 'days'. Or an array with this 5 positions: [secondTenths, seconds, minutes, hours, days]
* Default Value: Undefined
* precision (string): The timer update frequency.
* Accepted Values: 'secondTenths', 'seconds', 'minutes', 'hours'
* Default value: 'seconds'
* callback (function): A callback function executed every time the timer is updated. The callback receives the timer as a parameter.
* countdown (bool): If true, the timer is a countdown.
* stop(): Stop the timer
* pause(): Pause the timer
* reset(): Reset the timer values
* addEventListener(eventType, callback): Add a lister to an event. Timer triggers events when is updated
* Events triggered:
* secondTenthsUpdated
* secondsUpdated
* minutesUpdated
* hoursUpdated
* daysUpdated
* Parameters:
* eventType (string): The type of the event that you want to listen.
* callback (function): Function that will be executed when the timer triggers the specified event. The callback receives an object with the timer as a parameter.
* removeEventListener(eventType, callback): Remove an event listener from the timer. Same usage than addEventListener.
* getTimeValues(): Return and object with the current values. The keys of the returned object are 'secondTenths', 'seconds', 'minutes', 'hours' and 'days'.
* getTotalTimeValues(): Return and object with the current absolute values. The keys of the returned object are 'secondTenths', 'seconds', 'minutes', 'hours' and 'days'.

## Browser Support

Expand Down
13 changes: 3 additions & 10 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "easytimer.js",
"version": "1.3.2",
"version": "2.0.0",
"authors": [
"Albert Gonzalez ([email protected])"
],
"description": "Timer/Chronometer/Countdown compatible with AMD and NodeJS",
"main": "src/easytimer.js",
"main": "src/easytimer/easytimer.js",
"moduleType": [
"amd",
"node"
Expand All @@ -27,12 +27,5 @@
"bower_components",
"test",
"tests"
],
"devDependencies": {
"assert": "~0.1.0",
"mocha": "~1.21.4",
"sinon": "~1.10.3",
"bootstrap": "~3.2.0",
"jquery": "~2.1.1"
}
]
}
Loading

0 comments on commit 74f6a1e

Please sign in to comment.