GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - MrQuery/easytimer.js: Easy to use Timer/Chronometer/Countdown library compatible with AMD and NodeJS

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

60 Commits
60 Commits

Folders and files

NameName
Last commit message
Last commit date
dist
dist
 
 
src
src
 
 
test
test
 
 
.eslintrc.json
.eslintrc.json
 
 
.gitignore
.gitignore
 
 
.npmignore
.npmignore
 
 
README.md
README.md
 
 
bower.json
bower.json
 
 
index.d.ts
index.d.ts
 
 
index.html
index.html
 
 
package.json
package.json
 
 
rollup.config.examples.js
rollup.config.examples.js
 
 
rollup.config.js
rollup.config.js
 
 

Repository files navigation

easytimer.js

npm version

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

Install

NPM

npm install easytimer.js --save

Bower

bower install easytimer.js

Library Load

Script

<script src="lib/easytimer/dist/easytimer.min.js"></script>
<script>
    var timerInstance = new Timer();
</script>

Node

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

AMD

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

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

Timer instance API

  • 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

Easytimer uses dispatchEvent, and this feature is available in these Browsers:

  • Chrome (version >= 4)
  • Firefox (version >= 2)
  • IE (version >= 9)
  • Opera (version >= 9)
  • Safari (version >= 3)
  • Mobile browsers

About

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

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

Resources

Readme
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.