libbux / jquery-knob-countdown Goto Github PK
View Code? Open in Web Editor NEWA simple, amazing jQuery countdown timer, visualized with jQuery Knob (aterrien/jQuery-Knob)
A simple, amazing jQuery countdown timer, visualized with jQuery Knob (aterrien/jQuery-Knob)
As the title says, this does not yet work for multiple countdowns. I 'hacked' myself a way to get this working.
Here's what I did:
(function($) {
var counters = [],
dates = [],
counting = 0;
$.fn.countdown = function(options) {
counters[counting] = $(this);
dates[counting] = options['date'];
counting++;
var interval = setInterval(function () {
for (var i = counters.length - 1; i >= 0; i--) {
count_exec(counters[i], dates[i]);
};
}, 1000);
} // End of the main function
function count_exec(elem, datestring) {
eventDate = Date.parse(datestring) / 1000; // Parse the date string
currentDate = Math.floor($.now() / 1000); // Find the timestamp for now
seconds = eventDate - currentDate; // Find the number of seconds remaining
if (seconds <= 0) { // After the event date has passed
days = 0;
hours = 0;
minutes = 0;
seconds = 0;
} else {
days = Math.floor(seconds / (60 * 60 * 24)); // Divide to find the number of days remaining
seconds -= days * 60 * 60 * 24; // Subtract the number of (complete, => 24 hours) days calculated above
hours = Math.floor(seconds / (60 * 60)); // Get the number of hours from that modified number ^
seconds -= hours * 60 * 60;
minutes = Math.floor(seconds / 60);
seconds -= minutes * 60;
}
elem.find('.days').val(days).trigger('change');
elem.find('.hours').val(hours).trigger('change');
elem.find('.mins').val(minutes).trigger('change');
elem.find('.secs').val(seconds).trigger('change');
}
}) (jQuery);
There needs to be a javascript event which is triggered when the countdown timer gets to zero.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.