Giter Site home page Giter Site logo

clocktimer's Introduction

Clocktimer

A powerful, cross-browser and standalone clock engine written in pure Javascript.

About

ClockTimer is a powerful, cross-browser and standalone clock engine written in pure Javascript. It allows you to implement a clock, a timer or a countdown widget in seconds, or create a sophisticated component extending the core library.

Basic usage

Create a new clock, using the flexible HTML renderer:

HTML

Include the dependencies:

<head>
  <link rel="stylesheet" href="src/w3fclocktimer.css" />
  <script src="src/w3fclocktimer.js"></script>
</head>

Create a placeholder inside the block:

<div id="clock">
  <span data-digit="h"></span>:<span data-digit="i"></span>:<span data-digit="s"></span>
  <span data-digit="m"></span>
  <span data-digit="H"></span> <span data-digit="a"></span>
  <span data-digit="d"></span>-<span data-digit="n"></span>-<span data-digit="y"></span>
  <span data-digit="w"></span>, <span data-digit="N"></span>
</div>

Javascript

Create a new instance inside a <script> block:

document.addEventListener("DOMContentLoaded", function (event) { //you can omit this handler
  //Create a new clock:
  document.getElementById('clock').W3FClockTimer({});
});

Options

This is the list of default options:

mytarget.W3FClockTimer({
  //use it to localize your instances. See the Languages section
  lang: 'default',

  device: {
    //use 'clock' or 'timer'
    type: 'clock',
    //set it to off if you want to enable it manually
    ison: true, 
    //the offset, in seconds
    offset: 0
  },

  //the refresh speed, in milliseconds
  step: 100, 

  //see the Renderers section to get the full list
  renderer: {
    type: 'html',
    settings: {}
  },

  //use it to handle some time-dependant events. See the Milestones and bindings section
  milestones: {},

  bind: {
    //fired when the instance is initialized
    init: function () {},
    //fired when the core updates itself (based on step option)
    tick: function (key, device) {},
    //fired when the device is stopped
    stop: function (device) {}, 
    //fired when the instance in clicked
    click: function (device) {}, 
    //Timer only: fired when the difference between the deadline and the current time is zero
    deadline: function (device) {}
  }
});

You can find detailed information in the examples. Enjoy it!

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.