Giter VIP home page Giter VIP logo

countdown.js's Introduction

countdown.js

Very lightweight (0.39kb minified and gzipped), no dependencies Countdown Timer that provides a simple API to get various time formats

Install

npm install countdown-js

or clone directly from this repository

Usage

See the demo file for an example.

Create an index.js file

var Countdown = require('countdown-js')

// setup end datetime for timer
var ten_days = 1000 * 60 * 60 * 24 * 10
var end = new Date(new Date().getTime() + ten_days)

var timer = Countdown.timer(end, function(timeLeft) {
  console.log(timeLeft)
  console.log(timeLeft.days)
  console.log(timeLeft.hours)
  console.log(timeLeft.minutes)
  console.log(timeLeft.seconds)
}, function() {
  console.log("Countdown Finished!")
})

Run uglify-js to minify your file and browserify on your index.js so it can be run in the browser

npm install -g uglify-js browserify
uglifyjs ./index.js -o index.min.js -c -m | browserify -g uglifyify ./index.min.js > bundle.js

Include your bundle.js in your code right before the closing </body> tag so it doesn't need to wait for DOM.ready signal.

<script src="./bundle.js"></script>

Contributing

Fork the repository and clone it

Set up the development environment

npm install

After making changes run the following from the root countdown.js folder to test the demo and ensure it still works

uglifyjs ./index.js -o dist/countdown.min.js -c -m | browserify -g uglifyify demo/js/index.js > demo/js/bundle.js

Make any changes, update test/*.js files as appropriate.

Before committing run npm run test to ensure all tests pass

Make a pull request! Thanks!

countdown.js's People

Contributors

audiolion avatar

Stargazers

EHTACL avatar Classic Values avatar iman unknown avatar Mathieu de Gouville avatar Johnny Maynne avatar  avatar Henrique Kuwai avatar Andrés Santibáñez avatar 解念念 avatar William avatar  avatar

Watchers

James Cloos avatar Nick Lloyd avatar

countdown.js's Issues

days error

eg: set end date to new Date(2017, 12, 23) days will be 63

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.