/* CountDown Clock v1.0.0.0 - https://github.com/e-piksel/countdown */ (function (e) { e.fn.countdown = function (t, n) { function o() { var e = new Date(r.date), t = s(); var o = e - t; if (o < 0) { clearInterval(u); if (n && typeof n === 'function') n(); return } var a = 1000, f = a * 60, l = f * 60, c = l * 24; var h = Math.floor(o / c), p = Math.floor(o % c / l), d = Math.floor(o % l / f), v = Math.floor(o % f / a); h = String(h).length >= 2 ? h : '0' + h; p = String(p).length >= 2 ? p : '0' + p; d = String(d).length >= 2 ? d : '0' + d; v = String(v).length >= 2 ? v : '0' + v; var m = h === 1 ? r.day : r.days, g = p === 1 ? r.hour : r.hours, y = d === 1 ? r.minute : r.minutes, b = v === 1 ? r.second : r.seconds; if($('body').hasClass('ltr')){ i.find('.days').text(h); i.find('.hours').text(p); i.find('.minutes').text(d); i.find('.seconds').text(v); }else{ i.find('.days').text(digitsEn2Fa(h)); i.find('.hours').text(digitsEn2Fa(p)); i.find('.minutes').text(digitsEn2Fa(d)); i.find('.seconds').text(digitsEn2Fa(v)); } i.find('.days_text').text(m); i.find('.hours_text').text(g); i.find('.minutes_text').text(y); i.find('.seconds_text').text(b); } function digitsEn2Fa(number) { return number.toString().replace(/\d/g, function (d) { return String.fromCharCode(d.charCodeAt(0) + 1728); }); } var r = e.extend({ date: null, offset: null, day: 'Day', days: 'Days', hour: 'Hour', hours: 'Hours', minute: 'Minute', minutes: 'Minutes', second: 'Second', seconds: 'Seconds' }, t); if (!r.date) { e.error('Date is not defined.') } if (!Date.parse(r.date)) { e.error('Incorrect date format, it should look like this, 12/24/2012 12:00:00.') } var i = this; var s = function () { var e = new Date; var t = e.getTime() + e.getTimezoneOffset() * 60000; var n = new Date(t + 3600000 * r.offset); return n }; var u = setInterval(o, 1000) } }) (jQuery);