Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasanx committed Jun 2, 2012
1 parent a71ec61 commit 266e39b
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions jquery.scountdown.js
Expand Up @@ -3,26 +3,27 @@
* https://github.com/jonasanx/jQuery-simple-countdown * https://github.com/jonasanx/jQuery-simple-countdown
* @author Jonathan J. Flores * @author Jonathan J. Flores
*/ */
;(function ($) { ;(function ($) {
$.scountdown = function (element, options) { $.scountdown = function (element, options) {
var plugin = this; var plugin = this;


var time = { var time = {
days : 24*60*60, days: 24 * 60 * 60,
hours : 60*60, hours: 60 * 60,
minutes: 60 }; minutes: 60
};


plugin.init = function () { plugin.init = function () {
var settings = $.extend({}, { var settings = $.extend({}, {
timestamp : 0, timestamp: 0,
callback : function(){} callback: function () {}
}, options); }, options);


(function countdown(){ (function countdown() {
var timeLeft = Math.floor((settings.timestamp - (new Date())) / 1000); var timeLeft = Math.floor((settings.timestamp - (new Date())) / 1000);
var digits = {} var digits = {}


if(timeLeft < 0) timeLeft = 0; if (timeLeft < 0) timeLeft = 0;


for (key in time) { for (key in time) {
var y = time[key]; var y = time[key];
Expand All @@ -41,11 +42,11 @@


// Private methods // Private methods
var add_leading_zero = function (n) { var add_leading_zero = function (n) {
return (n.toString().length < 2) ? '0' + n : n; return (n.toString().length < 2) ? '0' + n : n;
} }


// Fire! // Fire!
plugin.init(); plugin.init();
} }


$.fn.scountdown = function (options) { $.fn.scountdown = function (options) {
Expand Down

0 comments on commit 266e39b

Please sign in to comment.