All Projects → walmik → Timer.jquery

walmik / Timer.jquery

Licence: mit
jQuery Timer: Start/Stop/Resume/Remove pretty timer inside any HTML element.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Timer.jquery

Footer Reveal
A jQuery plugin for easy implementation of the 'fixed/reveal' footer effect. Demo here:
Stars: ✭ 111 (-60.78%)
Mutual labels:  demo, jquery
Jquery.scrollto
Lightweight, cross-browser and highly customizable animated scrolling with jQuery
Stars: ✭ 3,609 (+1175.27%)
Mutual labels:  demo, jquery
Clone Section Of Form Es6 Or Jquery
Now on npm. Using vanilla JavaScript (ES6) or jQuery to duplicate a section of a form, maintaining accessibility (a11y).
Stars: ✭ 112 (-60.42%)
Mutual labels:  demo, jquery
Tableexport
The simple, easy-to-implement library to export HTML tables to xlsx, xls, csv, and txt files.
Stars: ✭ 781 (+175.97%)
Mutual labels:  demo, jquery
Favesound Redux
🎶 A SoundCloud Client in React + Redux running in production. Live Demo and Source Code to explore React + Redux as a beginner.
Stars: ✭ 1,586 (+460.42%)
Mutual labels:  duration, demo
Qbr
A webcam-based 3x3x3 rubik's cube solver written in Python 3 and OpenCV.
Stars: ✭ 122 (-56.89%)
Mutual labels:  demo
Poisson blend
Seamless copy-and-paste of images with Poisson Blending.
Stars: ✭ 277 (-2.12%)
Mutual labels:  demo
Colorpicker
jQuery UI widget for color picking (similar to the one in Microsoft Office 2010).
Stars: ✭ 271 (-4.24%)
Mutual labels:  jquery
Spider For Netease Music
抓取网易云音乐上所有歌曲的评论数量,并整理数据打造一个前端展示页面
Stars: ✭ 268 (-5.3%)
Mutual labels:  demo
Reptile
爬取机械工业出版社所有的计算机方面的书
Stars: ✭ 282 (-0.35%)
Mutual labels:  jquery
Sidr
Sidr is a jQuery plugin for creating side menus and the easiest way for doing your menu responsive.
Stars: ✭ 2,924 (+933.22%)
Mutual labels:  jquery
Quietnet
Simple chat program that communicates using inaudible sounds
Stars: ✭ 2,924 (+933.22%)
Mutual labels:  demo
E107
e107 Bootstrap CMS (Content Management System) v2 with PHP, MySQL, HTML5, jQuery and Twitter Bootstrap. Issue Discussion Room: https://gitter.im/e107inc/e107
Stars: ✭ 272 (-3.89%)
Mutual labels:  jquery
Wepy Demo Bookmall
Demo codes for 🐼📖 which used in a very early version.
Stars: ✭ 278 (-1.77%)
Mutual labels:  demo
Js Offcanvas
A lightweight, flexible jQuery off-canvas navigation plugin which lets you create fully accessible sidebar or top/bottom sliding (or push) panels with keyboard interactions and ARIA attributes.
Stars: ✭ 272 (-3.89%)
Mutual labels:  jquery
Stickynavbar.js
stickyNavbar.js: Fancy sticky navigation jQuery plugin with smart anchor link highlighting
Stars: ✭ 279 (-1.41%)
Mutual labels:  jquery
Api Docs
api.nasa.gov
Stars: ✭ 267 (-5.65%)
Mutual labels:  demo
Reqwest
browser asynchronous http requests
Stars: ✭ 2,918 (+931.1%)
Mutual labels:  jquery
Cp Demo
Confluent Platform Demo including Apache Kafka, ksqlDB, Control Center, Replicator, Confluent Schema Registry, Security
Stars: ✭ 278 (-1.77%)
Mutual labels:  demo
Vue Demo Collection
A collection of Vue.js demos
Stars: ✭ 274 (-3.18%)
Mutual labels:  demo

jQuery Timer plugin

  • Lightweight, well tested Build Status jQuery pretty timer plugin
  • Start, Pause, Resume and Remove a timer inside any HTML element.
  • Get notified after specific time or at regular intervals.
  • Click and edit time while timer is running!
  • Enable multiple timers on the same page.

Demo & Instructions | Download

Getting started

Load the plugin in a script tag (right after loading jQuery) directly from CDNjs using this URL,

https://cdnjs.cloudflare.com/ajax/libs/timer.jquery/0.7.0/timer.jquery.js

If you are using bower,

bower install timer.jquery

Alternatively you can download the jQuery timer plugin and host it relative to your HTML file. Once you have your preferred way to get jquery and the timer plugin, in your web page:

<script src="path/to/jquery.js"></script>
<script src="path/to/timer.jquery.js"></script>
<script>
(function($) {

  //start a timer
  $("#div-id").timer();

}());
</script>

Usage

To start a timer with options:

$("#div-id").timer(options);

Options for timer:

$("#div-id").timer({
	seconds:	{Int},		// The number of seconds to start the timer from
	duration: 	{String},	// The time to countdown from. `seconds` and `duration` are mutually exclusive
	callback: 	{Function},	// If duration is set, this function is called after `duration` has elapsed
	repeat: 	{Bool},		// If duration is set, `callback` will be called repeatedly
	format:		{String},	// Format to show time in
	editable:	{Bool}		// If click and edit time is enabled
	hidden;		{Bool}		// If true, the timer is not displayed in the selected item.
});

Methods available on an initialized timer:

//pause an existing timer
$("#div-id").timer('pause');

//resume a paused timer
$("#div-id").timer('resume');

//remove an existing timer
$("#div-id").timer('remove');  //leaves the display intact

//get elapsed time in seconds
$("#div-id").data('seconds');

Timed Events

Start a timer and execute a function after a certain duration. You can use this to simulate a timed event.

//start a timer & execute a function in 5 minutes & 30 seconds
$('#div-id').timer({
	duration: '5m30s',
	callback: function() {
		alert('Time up!');
	}
});

Start a timer and execute a function repeatedly at a certain duration.

//start a timer & execute a function every 2 minutes
$('#div-id').timer({
	duration: '2m',
	callback: function() {
		console.log('Why, Hello there');	//you could have a ajax call here instead
	},
	repeat: true //repeatedly calls the callback you specify
});

Start a timer and execute a function repeatedly at a certain duration and then reset the timer.

//start a timer & execute a function every 2 minutes
$('#div-id').timer({
	duration: '2m',
	callback: function() {
		$('#div-id').timer('reset');
	},
	repeat: true //repeatedly calls the callback you specify
});

Timer state

You can get the current state of timer by querying the state property on it's data object

$('#div-id').data('state'); 	// running | paused | stopped | removed
Duration Syntax

When you initialize a timer with the duration and callback parameters, the timer plugin executes the callback function at the set duration. The syntax for specifying the duration is verbose. h for hours. m for minutes and s for seconds. Here are some examples:

'3h15m'		// 3 hours, 15 minutes
'15m'		// 15 minutes
'30s'		// 30 seconds
'2m30s'		// 2 minutes 30 seconds
'2h15m30s'	// 2 hours 15 minutes and 30 seconds
Format Syntax

By default the timer displays the biggest whole unit. Examples:

  • seconds: 50 will show as 50 sec
  • seconds: 63 will show as 1:03 min
  • seconds: 3663 will show as 1:01:03

If you want to customize the format in which the timer displays time, use the format option. Available formats the timer understands are:

Format Description Example
%h Non-zero padded Hours %h hours gives 3 hours
%m Non-zero padded Minutes unless number of minutes is greater than 60 %h:%m minutes gives 0:6 minutes or 1:06 minutes
%g Non-zero padded Total Minutes Irrelative to hours %G minutes gives 75 minutes or 6 minutes
%s Non-zero padded Seconds unless number of seconds is greater than 60 %h:%m:%s gives 0:0:6 or 0:1:06 or 1:01:06
%t Non-zero padded Total Seconds Irrelative to minutes and hours %t gives 3660 or '9'
%H Zero padded Hours %H hours gives 03 hours
%M Zero padded Minutes %H:%M minutes gives 00:06 minutes
%G Zero padded Total Minutes Irrelative to hours %G minutes gives 75 minutes
%S Zero padded Seconds %H:%M:%S gives 00:00:06
%T Zero padded Total Seconds Irrelative to minutes and hours %T gives 3660

Countdown

You can use the jQuery timer plugin for countdown as well.

$('#timerDiv').timer({
    countdown: true,
    duration: '3m40s',    	// This will start the countdown from 3 mins 40 seconds
    callback: function() {	// This will execute after the duration has elapsed
    	console.log('Time up!');
    }
});
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].