JSFiddle - React, Tailwind, and code Playground
HTML
<div id="foo"></div>
JavaScript
/*
* jquery-counter plugin
*
* Copyright (c) 2009 Martin Conte Mac Donell <[email protected]>
* Dual licensed under the MIT and GPL licenses.
* http://docs.jquery.com/License
*/
jQuery.fn.countdown = function (userOptions) {
// Default options
var options = {
stepTime: 2000,
// startTime and format MUST follow the same format.
// also you cannot specify a format unordered (e.g. hh:ss:mm is wrong)
format: "ss",
startTime: "1036800",
digitImages: 6,
digitWidth: 53,
digitHeight: 77,
timerEnd: function () {},
image: "digits.png"
};
var digits = [],
interval;
// Draw digits in given container
var createDigits = function (where) {
var c = 0;
// Iterate each startTime digit, if it is not a digit
// we'll asume that it's a separator
for (var i = 0; i < options.startTime.length; i++) {
if (parseInt(options.startTime[i]) >= 0) {
elem = $('<div id="cnt_' + i + '" class="cntDigit" />').css({
height: options.digitHeight * options.digitImages * 10,
float: 'left',
background: 'url(\'' + options.image + '\')',
width: options.digitWidth
});
digits.push(elem);
margin(c, -((parseInt(options.startTime[i]) * options.digitHeight * options.digitImages)));
digits[c].__max = 0;
// Add max digits, for example, first digit of minutes (mm) has
// a max of 5. Conditional max is used when the left digit has reach
// the max. For example second "hours" digit has a conditional max of 4
switch (options.format[i]) {
case 'h':
digits[c].__max = (c % 2 == 0) ? 2 : 9;
if (c % 2 == 0) digits[c].__condmax = 4;
break;
...