JSFiddle - React, Tailwind, and code Playground
HTML
<h1 align="center">До сходочки аутистов осталось:</h1><br />
<div align="center" id="time" class="time"></div>
CSS
@import url('http://getbootstrap.com/dist/css/bootstrap.css');
JavaScript
$("#time").countdown({
date: "june 14, 2014 14:00:00",
onComplete: function( event ) {
alert("hello");
},
minsOnly: false,
leadingZero: true
});
});
$(document).ready(function($) {
$.fn.countdown = function( method /*, options*/ ) {
var defaults = {
date: null,
updateTime: 1000,
htmlTemplate: "%h часов, %i минут и %s секунд",
minus: false,
onChange: null,
onComplete: null,
onResume: null,
onPause: null,
leadingZero: false,
offset: null,
servertime:null,
hoursOnly: false,
minsOnly: false,
secsOnly: false,
weeks: false,
hours: false,
yearsAndMonths: false,
direction: "down",
stopwatch: false
},
slice = Array.prototype.slice,
clear = window.clearInterval,
floor = Math.floor,
msPerHr = 3600000,
secPerYear = 31556926,
secPerMonth = 2629743.83,
secPerWeek = 604800,
secPerDay = 86400,
secPerHr = 3600,
secPerMin = 60,
secPerSec = 1,
rDate = /(%y|%m|%w|%d|%h|%i|%s)/g,
rYears = /%y/,
rMonths = /%m/,
rWeeks = /%w/,
rDays = /%d/,
rHrs = /%h/,
rMins = /%i/,
rSecs = /%s/,
dateNow = function( $this ) {
var now = new Date(),
settings = $this.data("jcdData");
if( !settings ) {
return new Date();
}
if( settings.offset !== null ) {
now = getTZDate( settings.offset );
} else {
now = getTZDate( null, settings.difference ); //Date now
}
now.setMilliseconds(0);
return now;
},
getTZDate = function( offset, difference ) {
var hrs,
dateMS,
curHrs,
tmpDate = new Date();
if( offset === null ) {
dateMS = tmpDate.getTime() - difference;
} else {
hrs = offset * msPerHr;
curHrs = tmpDate.getTime() - ( ( -tmpDate.getTimezoneOffset() / 60 ) * msPerHr ) + hrs;
dateMS = tmpDate.setTime( curHrs );
}
return new Date( dateMS );
},
timerFunc = function() {
//Function runs at set interval updating countdown
var $this =...