Initial commit

This commit is contained in:
Khanh Ngo
2015-12-13 16:34:12 +07:00
commit 2dac8205f6
3113 changed files with 514935 additions and 0 deletions

View File

@ -0,0 +1,810 @@
/* http://keith-wood.name/countdown.html
Countdown for jQuery v1.6.3.
Written by Keith Wood (kbwood{at}iinet.com.au) January 2008.
Available under the MIT (https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt) license.
Please attribute the author if you use it. */
/* Display a countdown timer.
Attach it with options like:
$('div selector').countdown(
{until: new Date(2009, 1 - 1, 1, 0, 0, 0), onExpiry: happyNewYear}); */
(function($) { // Hide scope, no $ conflict
/* Countdown manager. */
function Countdown() {
this.regional = []; // Available regional settings, indexed by language code
this.regional[''] = { // Default regional settings
// The display texts for the counters
labels: ['Years', 'Months', 'Weeks', 'Days', 'Hours', 'Minutes', 'Seconds'],
// The display texts for the counters if only one
labels1: ['Year', 'Month', 'Week', 'Day', 'Hour', 'Minute', 'Second'],
compactLabels: ['y', 'm', 'w', 'd'], // The compact texts for the counters
whichLabels: null, // Function to determine which labels to use
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], // The digits to display
timeSeparator: ':', // Separator for time periods
isRTL: false // True for right-to-left languages, false for left-to-right
};
this._defaults = {
until: null, // new Date(year, mth - 1, day, hr, min, sec) - date/time to count down to
// or numeric for seconds offset, or string for unit offset(s):
// 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
since: null, // new Date(year, mth - 1, day, hr, min, sec) - date/time to count up from
// or numeric for seconds offset, or string for unit offset(s):
// 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
timezone: null, // The timezone (hours or minutes from GMT) for the target times,
// or null for client local
serverSync: null, // A function to retrieve the current server time for synchronisation
format: 'dHMS', // Format for display - upper case for always, lower case only if non-zero,
// 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
layout: '', // Build your own layout for the countdown
compact: false, // True to display in a compact format, false for an expanded one
significant: 0, // The number of periods with values to show, zero for all
description: '', // The description displayed for the countdown
expiryUrl: '', // A URL to load upon expiry, replacing the current page
expiryText: '', // Text to display upon expiry, replacing the countdown
alwaysExpire: false, // True to trigger onExpiry even if never counted down
onExpiry: null, // Callback when the countdown expires -
// receives no parameters and 'this' is the containing division
onTick: null, // Callback when the countdown is updated -
// receives int[7] being the breakdown by period (based on format)
// and 'this' is the containing division
tickInterval: 1 // Interval (seconds) between onTick callbacks
};
$.extend(this._defaults, this.regional['']);
this._serverSyncs = [];
var now = (typeof Date.now == 'function' ? Date.now :
function() { return new Date().getTime(); });
var perfAvail = (window.performance && typeof window.performance.now == 'function');
// Shared timer for all countdowns
function timerCallBack(timestamp) {
var drawStart = (timestamp < 1e12 ? // New HTML5 high resolution timer
(perfAvail ? (performance.now() + performance.timing.navigationStart) : now()) :
// Integer milliseconds since unix epoch
timestamp || now());
if (drawStart - animationStartTime >= 1000) {
plugin._updateTargets();
animationStartTime = drawStart;
}
requestAnimationFrame(timerCallBack);
}
var requestAnimationFrame = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame || window.msRequestAnimationFrame || null;
// This is when we expect a fall-back to setInterval as it's much more fluid
var animationStartTime = 0;
if (!requestAnimationFrame || $.noRequestAnimationFrame) {
$.noRequestAnimationFrame = null;
setInterval(function() { plugin._updateTargets(); }, 980); // Fall back to good old setInterval
}
else {
animationStartTime = window.animationStartTime ||
window.webkitAnimationStartTime || window.mozAnimationStartTime ||
window.oAnimationStartTime || window.msAnimationStartTime || now();
requestAnimationFrame(timerCallBack);
}
}
var Y = 0; // Years
var O = 1; // Months
var W = 2; // Weeks
var D = 3; // Days
var H = 4; // Hours
var M = 5; // Minutes
var S = 6; // Seconds
$.extend(Countdown.prototype, {
/* Class name added to elements to indicate already configured with countdown. */
markerClassName: 'hasCountdown',
/* Name of the data property for instance settings. */
propertyName: 'countdown',
/* Class name for the right-to-left marker. */
_rtlClass: 'countdown_rtl',
/* Class name for the countdown section marker. */
_sectionClass: 'countdown_section',
/* Class name for the period amount marker. */
_amountClass: 'countdown_amount',
/* Class name for the countdown row marker. */
_rowClass: 'countdown_row',
/* Class name for the holding countdown marker. */
_holdingClass: 'countdown_holding',
/* Class name for the showing countdown marker. */
_showClass: 'countdown_show',
/* Class name for the description marker. */
_descrClass: 'countdown_descr',
/* List of currently active countdown targets. */
_timerTargets: [],
/* Override the default settings for all instances of the countdown widget.
@param options (object) the new settings to use as defaults */
setDefaults: function(options) {
this._resetExtraLabels(this._defaults, options);
$.extend(this._defaults, options || {});
},
/* Convert a date/time to UTC.
@param tz (number) the hour or minute offset from GMT, e.g. +9, -360
@param year (Date) the date/time in that timezone or
(number) the year in that timezone
@param month (number, optional) the month (0 - 11) (omit if year is a Date)
@param day (number, optional) the day (omit if year is a Date)
@param hours (number, optional) the hour (omit if year is a Date)
@param mins (number, optional) the minute (omit if year is a Date)
@param secs (number, optional) the second (omit if year is a Date)
@param ms (number, optional) the millisecond (omit if year is a Date)
@return (Date) the equivalent UTC date/time */
UTCDate: function(tz, year, month, day, hours, mins, secs, ms) {
if (typeof year == 'object' && year.constructor == Date) {
ms = year.getMilliseconds();
secs = year.getSeconds();
mins = year.getMinutes();
hours = year.getHours();
day = year.getDate();
month = year.getMonth();
year = year.getFullYear();
}
var d = new Date();
d.setUTCFullYear(year);
d.setUTCDate(1);
d.setUTCMonth(month || 0);
d.setUTCDate(day || 1);
d.setUTCHours(hours || 0);
d.setUTCMinutes((mins || 0) - (Math.abs(tz) < 30 ? tz * 60 : tz));
d.setUTCSeconds(secs || 0);
d.setUTCMilliseconds(ms || 0);
return d;
},
/* Convert a set of periods into seconds.
Averaged for months and years.
@param periods (number[7]) the periods per year/month/week/day/hour/minute/second
@return (number) the corresponding number of seconds */
periodsToSeconds: function(periods) {
return periods[0] * 31557600 + periods[1] * 2629800 + periods[2] * 604800 +
periods[3] * 86400 + periods[4] * 3600 + periods[5] * 60 + periods[6];
},
/* Attach the countdown widget to a div.
@param target (element) the containing division
@param options (object) the initial settings for the countdown */
_attachPlugin: function(target, options) {
target = $(target);
if (target.hasClass(this.markerClassName)) {
return;
}
var inst = {options: $.extend({}, this._defaults), _periods: [0, 0, 0, 0, 0, 0, 0]};
target.addClass(this.markerClassName).data(this.propertyName, inst);
this._optionPlugin(target, options);
},
/* Add a target to the list of active ones.
@param target (element) the countdown target */
_addTarget: function(target) {
if (!this._hasTarget(target)) {
this._timerTargets.push(target);
}
},
/* See if a target is in the list of active ones.
@param target (element) the countdown target
@return (boolean) true if present, false if not */
_hasTarget: function(target) {
return ($.inArray(target, this._timerTargets) > -1);
},
/* Remove a target from the list of active ones.
@param target (element) the countdown target */
_removeTarget: function(target) {
this._timerTargets = $.map(this._timerTargets,
function(value) { return (value == target ? null : value); }); // delete entry
},
/* Update each active timer target. */
_updateTargets: function() {
for (var i = this._timerTargets.length - 1; i >= 0; i--) {
this._updateCountdown(this._timerTargets[i]);
}
},
/* Reconfigure the settings for a countdown div.
@param target (element) the control to affect
@param options (object) the new options for this instance or
(string) an individual property name
@param value (any) the individual property value (omit if options
is an object or to retrieve the value of a setting)
@return (any) if retrieving a value */
_optionPlugin: function(target, options, value) {
target = $(target);
var inst = target.data(this.propertyName);
if (!options || (typeof options == 'string' && value == null)) { // Get option
var name = options;
options = (inst || {}).options;
return (options && name ? options[name] : options);
}
if (!target.hasClass(this.markerClassName)) {
return;
}
options = options || {};
if (typeof options == 'string') {
var name = options;
options = {};
options[name] = value;
}
if (options.layout) {
options.layout = options.layout.replace(/&lt;/g, '<').replace(/&gt;/g, '>');
}
this._resetExtraLabels(inst.options, options);
var timezoneChanged = (inst.options.timezone != options.timezone);
$.extend(inst.options, options);
this._adjustSettings(target, inst,
options.until != null || options.since != null || timezoneChanged);
var now = new Date();
if ((inst._since && inst._since < now) || (inst._until && inst._until > now)) {
this._addTarget(target[0]);
}
this._updateCountdown(target, inst);
},
/* Redisplay the countdown with an updated display.
@param target (jQuery) the containing division
@param inst (object) the current settings for this instance */
_updateCountdown: function(target, inst) {
var $target = $(target);
inst = inst || $target.data(this.propertyName);
if (!inst) {
return;
}
$target.html(this._generateHTML(inst)).toggleClass(this._rtlClass, inst.options.isRTL);
if ($.isFunction(inst.options.onTick)) {
var periods = inst._hold != 'lap' ? inst._periods :
this._calculatePeriods(inst, inst._show, inst.options.significant, new Date());
if (inst.options.tickInterval == 1 ||
this.periodsToSeconds(periods) % inst.options.tickInterval == 0) {
inst.options.onTick.apply(target, [periods]);
}
}
var expired = inst._hold != 'pause' &&
(inst._since ? inst._now.getTime() < inst._since.getTime() :
inst._now.getTime() >= inst._until.getTime());
if (expired && !inst._expiring) {
inst._expiring = true;
if (this._hasTarget(target) || inst.options.alwaysExpire) {
this._removeTarget(target);
if ($.isFunction(inst.options.onExpiry)) {
inst.options.onExpiry.apply(target, []);
}
if (inst.options.expiryText) {
var layout = inst.options.layout;
inst.options.layout = inst.options.expiryText;
this._updateCountdown(target, inst);
inst.options.layout = layout;
}
if (inst.options.expiryUrl) {
window.location = inst.options.expiryUrl;
}
}
inst._expiring = false;
}
else if (inst._hold == 'pause') {
this._removeTarget(target);
}
$target.data(this.propertyName, inst);
},
/* Reset any extra labelsn and compactLabelsn entries if changing labels.
@param base (object) the options to be updated
@param options (object) the new option values */
_resetExtraLabels: function(base, options) {
var changingLabels = false;
for (var n in options) {
if (n != 'whichLabels' && n.match(/[Ll]abels/)) {
changingLabels = true;
break;
}
}
if (changingLabels) {
for (var n in base) { // Remove custom numbered labels
if (n.match(/[Ll]abels[02-9]|compactLabels1/)) {
base[n] = null;
}
}
}
},
/* Calculate interal settings for an instance.
@param target (element) the containing division
@param inst (object) the current settings for this instance
@param recalc (boolean) true if until or since are set */
_adjustSettings: function(target, inst, recalc) {
var now;
var serverOffset = 0;
var serverEntry = null;
for (var i = 0; i < this._serverSyncs.length; i++) {
if (this._serverSyncs[i][0] == inst.options.serverSync) {
serverEntry = this._serverSyncs[i][1];
break;
}
}
if (serverEntry != null) {
serverOffset = (inst.options.serverSync ? serverEntry : 0);
now = new Date();
}
else {
var serverResult = ($.isFunction(inst.options.serverSync) ?
inst.options.serverSync.apply(target, []) : null);
now = new Date();
serverOffset = (serverResult ? now.getTime() - serverResult.getTime() : 0);
this._serverSyncs.push([inst.options.serverSync, serverOffset]);
}
var timezone = inst.options.timezone;
timezone = (timezone == null ? -now.getTimezoneOffset() : timezone);
if (recalc || (!recalc && inst._until == null && inst._since == null)) {
inst._since = inst.options.since;
if (inst._since != null) {
inst._since = this.UTCDate(timezone, this._determineTime(inst._since, null));
if (inst._since && serverOffset) {
inst._since.setMilliseconds(inst._since.getMilliseconds() + serverOffset);
}
}
inst._until = this.UTCDate(timezone, this._determineTime(inst.options.until, now));
if (serverOffset) {
inst._until.setMilliseconds(inst._until.getMilliseconds() + serverOffset);
}
}
inst._show = this._determineShow(inst);
},
/* Remove the countdown widget from a div.
@param target (element) the containing division */
_destroyPlugin: function(target) {
target = $(target);
if (!target.hasClass(this.markerClassName)) {
return;
}
this._removeTarget(target[0]);
target.removeClass(this.markerClassName).empty().removeData(this.propertyName);
},
/* Pause a countdown widget at the current time.
Stop it running but remember and display the current time.
@param target (element) the containing division */
_pausePlugin: function(target) {
this._hold(target, 'pause');
},
/* Pause a countdown widget at the current time.
Stop the display but keep the countdown running.
@param target (element) the containing division */
_lapPlugin: function(target) {
this._hold(target, 'lap');
},
/* Resume a paused countdown widget.
@param target (element) the containing division */
_resumePlugin: function(target) {
this._hold(target, null);
},
/* Pause or resume a countdown widget.
@param target (element) the containing division
@param hold (string) the new hold setting */
_hold: function(target, hold) {
var inst = $.data(target, this.propertyName);
if (inst) {
if (inst._hold == 'pause' && !hold) {
inst._periods = inst._savePeriods;
var sign = (inst._since ? '-' : '+');
inst[inst._since ? '_since' : '_until'] =
this._determineTime(sign + inst._periods[0] + 'y' +
sign + inst._periods[1] + 'o' + sign + inst._periods[2] + 'w' +
sign + inst._periods[3] + 'd' + sign + inst._periods[4] + 'h' +
sign + inst._periods[5] + 'm' + sign + inst._periods[6] + 's');
this._addTarget(target);
}
inst._hold = hold;
inst._savePeriods = (hold == 'pause' ? inst._periods : null);
$.data(target, this.propertyName, inst);
this._updateCountdown(target, inst);
}
},
/* Return the current time periods.
@param target (element) the containing division
@return (number[7]) the current periods for the countdown */
_getTimesPlugin: function(target) {
var inst = $.data(target, this.propertyName);
return (!inst ? null : (inst._hold == 'pause' ? inst._savePeriods : (!inst._hold ? inst._periods :
this._calculatePeriods(inst, inst._show, inst.options.significant, new Date()))));
},
/* A time may be specified as an exact value or a relative one.
@param setting (string or number or Date) - the date/time value
as a relative or absolute value
@param defaultTime (Date) the date/time to use if no other is supplied
@return (Date) the corresponding date/time */
_determineTime: function(setting, defaultTime) {
var offsetNumeric = function(offset) { // e.g. +300, -2
var time = new Date();
time.setTime(time.getTime() + offset * 1000);
return time;
};
var offsetString = function(offset) { // e.g. '+2d', '-4w', '+3h +30m'
offset = offset.toLowerCase();
var time = new Date();
var year = time.getFullYear();
var month = time.getMonth();
var day = time.getDate();
var hour = time.getHours();
var minute = time.getMinutes();
var second = time.getSeconds();
var pattern = /([+-]?[0-9]+)\s*(s|m|h|d|w|o|y)?/g;
var matches = pattern.exec(offset);
while (matches) {
switch (matches[2] || 's') {
case 's': second += parseInt(matches[1], 10); break;
case 'm': minute += parseInt(matches[1], 10); break;
case 'h': hour += parseInt(matches[1], 10); break;
case 'd': day += parseInt(matches[1], 10); break;
case 'w': day += parseInt(matches[1], 10) * 7; break;
case 'o':
month += parseInt(matches[1], 10);
day = Math.min(day, plugin._getDaysInMonth(year, month));
break;
case 'y':
year += parseInt(matches[1], 10);
day = Math.min(day, plugin._getDaysInMonth(year, month));
break;
}
matches = pattern.exec(offset);
}
return new Date(year, month, day, hour, minute, second, 0);
};
var time = (setting == null ? defaultTime :
(typeof setting == 'string' ? offsetString(setting) :
(typeof setting == 'number' ? offsetNumeric(setting) : setting)));
if (time) time.setMilliseconds(0);
return time;
},
/* Determine the number of days in a month.
@param year (number) the year
@param month (number) the month
@return (number) the days in that month */
_getDaysInMonth: function(year, month) {
return 32 - new Date(year, month, 32).getDate();
},
/* Determine which set of labels should be used for an amount.
@param num (number) the amount to be displayed
@return (number) the set of labels to be used for this amount */
_normalLabels: function(num) {
return num;
},
/* Generate the HTML to display the countdown widget.
@param inst (object) the current settings for this instance
@return (string) the new HTML for the countdown display */
_generateHTML: function(inst) {
var self = this;
// Determine what to show
inst._periods = (inst._hold ? inst._periods :
this._calculatePeriods(inst, inst._show, inst.options.significant, new Date()));
// Show all 'asNeeded' after first non-zero value
var shownNonZero = false;
var showCount = 0;
var sigCount = inst.options.significant;
var show = $.extend({}, inst._show);
for (var period = Y; period <= S; period++) {
shownNonZero |= (inst._show[period] == '?' && inst._periods[period] > 0);
show[period] = (inst._show[period] == '?' && !shownNonZero ? null : inst._show[period]);
showCount += (show[period] ? 1 : 0);
sigCount -= (inst._periods[period] > 0 ? 1 : 0);
}
var showSignificant = [false, false, false, false, false, false, false];
for (var period = S; period >= Y; period--) { // Determine significant periods
if (inst._show[period]) {
if (inst._periods[period]) {
showSignificant[period] = true;
}
else {
showSignificant[period] = sigCount > 0;
sigCount--;
}
}
}
var labels = (inst.options.compact ? inst.options.compactLabels : inst.options.labels);
var whichLabels = inst.options.whichLabels || this._normalLabels;
var showCompact = function(period) {
var labelsNum = inst.options['compactLabels' + whichLabels(inst._periods[period])];
return (show[period] ? self._translateDigits(inst, inst._periods[period]) +
(labelsNum ? labelsNum[period] : labels[period]) + ' ' : '');
};
var showFull = function(period) {
var labelsNum = inst.options['labels' + whichLabels(inst._periods[period])];
return ((!inst.options.significant && show[period]) ||
(inst.options.significant && showSignificant[period]) ?
'<span class="' + plugin._sectionClass + '">' +
'<span class="' + plugin._amountClass + '">' +
self._translateDigits(inst, inst._periods[period]) + '</span><br/>' +
(labelsNum ? labelsNum[period] : labels[period]) + '</span>' : '');
};
return (inst.options.layout ? this._buildLayout(inst, show, inst.options.layout,
inst.options.compact, inst.options.significant, showSignificant) :
((inst.options.compact ? // Compact version
'<span class="' + this._rowClass + ' ' + this._amountClass +
(inst._hold ? ' ' + this._holdingClass : '') + '">' +
showCompact(Y) + showCompact(O) + showCompact(W) + showCompact(D) +
(show[H] ? this._minDigits(inst, inst._periods[H], 2) : '') +
(show[M] ? (show[H] ? inst.options.timeSeparator : '') +
this._minDigits(inst, inst._periods[M], 2) : '') +
(show[S] ? (show[H] || show[M] ? inst.options.timeSeparator : '') +
this._minDigits(inst, inst._periods[S], 2) : '') :
// Full version
'<span class="' + this._rowClass + ' ' + this._showClass + (inst.options.significant || showCount) +
(inst._hold ? ' ' + this._holdingClass : '') + '">' +
showFull(Y) + showFull(O) + showFull(W) + showFull(D) +
showFull(H) + showFull(M) + showFull(S)) + '</span>' +
(inst.options.description ? '<span class="' + this._rowClass + ' ' + this._descrClass + '">' +
inst.options.description + '</span>' : '')));
},
/* Construct a custom layout.
@param inst (object) the current settings for this instance
@param show (string[7]) flags indicating which periods are requested
@param layout (string) the customised layout
@param compact (boolean) true if using compact labels
@param significant (number) the number of periods with values to show, zero for all
@param showSignificant (boolean[7]) other periods to show for significance
@return (string) the custom HTML */
_buildLayout: function(inst, show, layout, compact, significant, showSignificant) {
var labels = inst.options[compact ? 'compactLabels' : 'labels'];
var whichLabels = inst.options.whichLabels || this._normalLabels;
var labelFor = function(index) {
return (inst.options[(compact ? 'compactLabels' : 'labels') +
whichLabels(inst._periods[index])] || labels)[index];
};
var digit = function(value, position) {
return inst.options.digits[Math.floor(value / position) % 10];
};
var subs = {desc: inst.options.description, sep: inst.options.timeSeparator,
yl: labelFor(Y), yn: this._minDigits(inst, inst._periods[Y], 1),
ynn: this._minDigits(inst, inst._periods[Y], 2),
ynnn: this._minDigits(inst, inst._periods[Y], 3), y1: digit(inst._periods[Y], 1),
y10: digit(inst._periods[Y], 10), y100: digit(inst._periods[Y], 100),
y1000: digit(inst._periods[Y], 1000),
ol: labelFor(O), on: this._minDigits(inst, inst._periods[O], 1),
onn: this._minDigits(inst, inst._periods[O], 2),
onnn: this._minDigits(inst, inst._periods[O], 3), o1: digit(inst._periods[O], 1),
o10: digit(inst._periods[O], 10), o100: digit(inst._periods[O], 100),
o1000: digit(inst._periods[O], 1000),
wl: labelFor(W), wn: this._minDigits(inst, inst._periods[W], 1),
wnn: this._minDigits(inst, inst._periods[W], 2),
wnnn: this._minDigits(inst, inst._periods[W], 3), w1: digit(inst._periods[W], 1),
w10: digit(inst._periods[W], 10), w100: digit(inst._periods[W], 100),
w1000: digit(inst._periods[W], 1000),
dl: labelFor(D), dn: this._minDigits(inst, inst._periods[D], 1),
dnn: this._minDigits(inst, inst._periods[D], 2),
dnnn: this._minDigits(inst, inst._periods[D], 3), d1: digit(inst._periods[D], 1),
d10: digit(inst._periods[D], 10), d100: digit(inst._periods[D], 100),
d1000: digit(inst._periods[D], 1000),
hl: labelFor(H), hn: this._minDigits(inst, inst._periods[H], 1),
hnn: this._minDigits(inst, inst._periods[H], 2),
hnnn: this._minDigits(inst, inst._periods[H], 3), h1: digit(inst._periods[H], 1),
h10: digit(inst._periods[H], 10), h100: digit(inst._periods[H], 100),
h1000: digit(inst._periods[H], 1000),
ml: labelFor(M), mn: this._minDigits(inst, inst._periods[M], 1),
mnn: this._minDigits(inst, inst._periods[M], 2),
mnnn: this._minDigits(inst, inst._periods[M], 3), m1: digit(inst._periods[M], 1),
m10: digit(inst._periods[M], 10), m100: digit(inst._periods[M], 100),
m1000: digit(inst._periods[M], 1000),
sl: labelFor(S), sn: this._minDigits(inst, inst._periods[S], 1),
snn: this._minDigits(inst, inst._periods[S], 2),
snnn: this._minDigits(inst, inst._periods[S], 3), s1: digit(inst._periods[S], 1),
s10: digit(inst._periods[S], 10), s100: digit(inst._periods[S], 100),
s1000: digit(inst._periods[S], 1000)};
var html = layout;
// Replace period containers: {p<}...{p>}
for (var i = Y; i <= S; i++) {
var period = 'yowdhms'.charAt(i);
var re = new RegExp('\\{' + period + '<\\}([\\s\\S]*)\\{' + period + '>\\}', 'g');
html = html.replace(re, ((!significant && show[i]) ||
(significant && showSignificant[i]) ? '$1' : ''));
}
// Replace period values: {pn}
$.each(subs, function(n, v) {
var re = new RegExp('\\{' + n + '\\}', 'g');
html = html.replace(re, v);
});
return html;
},
/* Ensure a numeric value has at least n digits for display.
@param inst (object) the current settings for this instance
@param value (number) the value to display
@param len (number) the minimum length
@return (string) the display text */
_minDigits: function(inst, value, len) {
value = '' + value;
if (value.length >= len) {
return this._translateDigits(inst, value);
}
value = '0000000000' + value;
return this._translateDigits(inst, value.substr(value.length - len));
},
/* Translate digits into other representations.
@param inst (object) the current settings for this instance
@param value (string) the text to translate
@return (string) the translated text */
_translateDigits: function(inst, value) {
return ('' + value).replace(/[0-9]/g, function(digit) {
return inst.options.digits[digit];
});
},
/* Translate the format into flags for each period.
@param inst (object) the current settings for this instance
@return (string[7]) flags indicating which periods are requested (?) or
required (!) by year, month, week, day, hour, minute, second */
_determineShow: function(inst) {
var format = inst.options.format;
var show = [];
show[Y] = (format.match('y') ? '?' : (format.match('Y') ? '!' : null));
show[O] = (format.match('o') ? '?' : (format.match('O') ? '!' : null));
show[W] = (format.match('w') ? '?' : (format.match('W') ? '!' : null));
show[D] = (format.match('d') ? '?' : (format.match('D') ? '!' : null));
show[H] = (format.match('h') ? '?' : (format.match('H') ? '!' : null));
show[M] = (format.match('m') ? '?' : (format.match('M') ? '!' : null));
show[S] = (format.match('s') ? '?' : (format.match('S') ? '!' : null));
return show;
},
/* Calculate the requested periods between now and the target time.
@param inst (object) the current settings for this instance
@param show (string[7]) flags indicating which periods are requested/required
@param significant (number) the number of periods with values to show, zero for all
@param now (Date) the current date and time
@return (number[7]) the current time periods (always positive)
by year, month, week, day, hour, minute, second */
_calculatePeriods: function(inst, show, significant, now) {
// Find endpoints
inst._now = now;
inst._now.setMilliseconds(0);
var until = new Date(inst._now.getTime());
if (inst._since) {
if (now.getTime() < inst._since.getTime()) {
inst._now = now = until;
}
else {
now = inst._since;
}
}
else {
until.setTime(inst._until.getTime());
if (now.getTime() > inst._until.getTime()) {
inst._now = now = until;
}
}
// Calculate differences by period
var periods = [0, 0, 0, 0, 0, 0, 0];
if (show[Y] || show[O]) {
// Treat end of months as the same
var lastNow = plugin._getDaysInMonth(now.getFullYear(), now.getMonth());
var lastUntil = plugin._getDaysInMonth(until.getFullYear(), until.getMonth());
var sameDay = (until.getDate() == now.getDate() ||
(until.getDate() >= Math.min(lastNow, lastUntil) &&
now.getDate() >= Math.min(lastNow, lastUntil)));
var getSecs = function(date) {
return (date.getHours() * 60 + date.getMinutes()) * 60 + date.getSeconds();
};
var months = Math.max(0,
(until.getFullYear() - now.getFullYear()) * 12 + until.getMonth() - now.getMonth() +
((until.getDate() < now.getDate() && !sameDay) ||
(sameDay && getSecs(until) < getSecs(now)) ? -1 : 0));
periods[Y] = (show[Y] ? Math.floor(months / 12) : 0);
periods[O] = (show[O] ? months - periods[Y] * 12 : 0);
// Adjust for months difference and end of month if necessary
now = new Date(now.getTime());
var wasLastDay = (now.getDate() == lastNow);
var lastDay = plugin._getDaysInMonth(now.getFullYear() + periods[Y],
now.getMonth() + periods[O]);
if (now.getDate() > lastDay) {
now.setDate(lastDay);
}
now.setFullYear(now.getFullYear() + periods[Y]);
now.setMonth(now.getMonth() + periods[O]);
if (wasLastDay) {
now.setDate(lastDay);
}
}
var diff = Math.floor((until.getTime() - now.getTime()) / 1000);
var extractPeriod = function(period, numSecs) {
periods[period] = (show[period] ? Math.floor(diff / numSecs) : 0);
diff -= periods[period] * numSecs;
};
extractPeriod(W, 604800);
extractPeriod(D, 86400);
extractPeriod(H, 3600);
extractPeriod(M, 60);
extractPeriod(S, 1);
if (diff > 0 && !inst._since) { // Round up if left overs
var multiplier = [1, 12, 4.3482, 7, 24, 60, 60];
var lastShown = S;
var max = 1;
for (var period = S; period >= Y; period--) {
if (show[period]) {
if (periods[lastShown] >= max) {
periods[lastShown] = 0;
diff = 1;
}
if (diff > 0) {
periods[period]++;
diff = 0;
lastShown = period;
max = 1;
}
}
max *= multiplier[period];
}
}
if (significant) { // Zero out insignificant periods
for (var period = Y; period <= S; period++) {
if (significant && periods[period]) {
significant--;
}
else if (!significant) {
periods[period] = 0;
}
}
}
return periods;
}
});
// The list of commands that return values and don't permit chaining
var getters = ['getTimes'];
/* Determine whether a command is a getter and doesn't permit chaining.
@param command (string, optional) the command to run
@param otherArgs ([], optional) any other arguments for the command
@return true if the command is a getter, false if not */
function isNotChained(command, otherArgs) {
if (command == 'option' && (otherArgs.length == 0 ||
(otherArgs.length == 1 && typeof otherArgs[0] == 'string'))) {
return true;
}
return $.inArray(command, getters) > -1;
}
/* Process the countdown functionality for a jQuery selection.
@param options (object) the new settings to use for these instances (optional) or
(string) the command to run (optional)
@return (jQuery) for chaining further calls or
(any) getter value */
$.fn.countdown = function(options) {
var otherArgs = Array.prototype.slice.call(arguments, 1);
if (isNotChained(options, otherArgs)) {
return plugin['_' + options + 'Plugin'].
apply(plugin, [this[0]].concat(otherArgs));
}
return this.each(function() {
if (typeof options == 'string') {
if (!plugin['_' + options + 'Plugin']) {
throw 'Unknown command: ' + options;
}
plugin['_' + options + 'Plugin'].
apply(plugin, [this].concat(otherArgs));
}
else {
plugin._attachPlugin(this, options || {});
}
});
};
/* Initialise the countdown functionality. */
var plugin = $.countdown = new Countdown(); // Singleton instance
})(jQuery);

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,31 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>jQuery Countdown</title>
<link rel="stylesheet" href="jquery.countdown.css">
<style type="text/css">
#defaultCountdown { width: 240px; height: 45px; }
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="jquery.countdown.js"></script>
<script type="text/javascript">
$(function () {
var austDay = new Date();
austDay = new Date(austDay.getFullYear() + 1, 1 - 1, 26);
$('#defaultCountdown').countdown({until: austDay});
$('#year').text(austDay.getFullYear());
});
</script>
</head>
<body>
<h1>jQuery Countdown Basics</h1>
<p>This page demonstrates the very basics of the
<a href="http://keith-wood.name/countdown.html">jQuery Countdown plugin</a>.
It contains the minimum requirements for using the plugin and
can be used as the basis for your own experimentation.</p>
<p>For more detail see the <a href="http://keith-wood.name/countdownRef.html">documentation reference</a> page.</p>
<p>Counting down to 26 January <span id="year">2010</span>.</p>
<div id="defaultCountdown"></div>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
Arabic (عربي) initialisation for the jQuery countdown extension
Translated by Talal Al Asmari (talal@psdgroups.com), April 2009. */
(function($) {
$.countdown.regional['ar'] = {
labels: ['سنوات','أشهر','أسابيع','أيام','ساعات','دقائق','ثواني'],
labels1: ['سنة','شهر','أسبوع','يوم','ساعة','دقيقة','ثانية'],
compactLabels: ['س', 'ش', 'أ', 'ي'],
whichLabels: null,
digits: ['٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'],
timeSeparator: ':', isRTL: true};
$.countdown.setDefaults($.countdown.regional['ar']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
* Bulgarian initialisation for the jQuery countdown extension
* Written by Manol Trendafilov manol@rastermania.com (2010) */
(function($) {
$.countdown.regional['bg'] = {
labels: ['Години', 'Месеца', 'Седмица', 'Дни', 'Часа', 'Минути', 'Секунди'],
labels1: ['Година', 'Месец', 'Седмица', 'Ден', 'Час', 'Минута', 'Секунда'],
compactLabels: ['l', 'm', 'n', 'd'], compactLabels1: ['g', 'm', 'n', 'd'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['bg']);
})(jQuery);

View File

@ -0,0 +1,16 @@
/* http://keith-wood.name/countdown.html
* Bosnian Latin initialisation for the jQuery countdown extension
* Written by Miralem Mehic miralem@mehic.info (2011) */
(function($) {
$.countdown.regional['bs'] = {
labels: ['Godina', 'Mjeseci', 'Sedmica', 'Dana', 'Sati', 'Minuta', 'Sekundi'],
labels1: ['Godina', 'Mjesec', 'Sedmica', 'Dan', 'Sat', 'Minuta', 'Sekunda'],
labels2: ['Godine', 'Mjeseca', 'Sedmica', 'Dana', 'Sata', 'Minute', 'Sekunde'],
compactLabels: ['g', 'm', 't', 'd'],
whichLabels: function(amount) {
return (amount == 1 ? 1 : (amount >= 2 && amount <= 4 ? 2 : 0));
},
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['bs']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
Catalan initialisation for the jQuery countdown extension
Written by Amanida Media www.amanidamedia.com (2010) */
(function($) {
$.countdown.regional['ca'] = {
labels: ['Anys', 'Mesos', 'Setmanes', 'Dies', 'Hores', 'Minuts', 'Segons'],
labels1: ['Anys', 'Mesos', 'Setmanes', 'Dies', 'Hores', 'Minuts', 'Segons'],
compactLabels: ['a', 'm', 's', 'g'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['ca']);
})(jQuery);

View File

@ -0,0 +1,16 @@
/* http://keith-wood.name/countdown.html
* Czech initialisation for the jQuery countdown extension
* Written by Roman Chlebec (creamd@c64.sk) (2008) */
(function($) {
$.countdown.regional['cs'] = {
labels: ['Roků', 'Měsíců', 'Týdnů', 'Dní', 'Hodin', 'Minut', 'Sekund'],
labels1: ['Rok', 'Měsíc', 'Týden', 'Den', 'Hodina', 'Minuta', 'Sekunda'],
labels2: ['Roky', 'Měsíce', 'Týdny', 'Dny', 'Hodiny', 'Minuty', 'Sekundy'],
compactLabels: ['r', 'm', 't', 'd'],
whichLabels: function(amount) {
return (amount == 1 ? 1 : (amount >= 2 && amount <= 4 ? 2 : 0));
},
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['cs']);
})(jQuery);

View File

@ -0,0 +1 @@
/* http://keith-wood.name/countdown.html

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
Danish initialisation for the jQuery countdown extension
Written by Buch (admin@buch90.dk). */
(function($) {
$.countdown.regional['da'] = {
labels: ['År', 'Måneder', 'Uger', 'Dage', 'Timer', 'Minutter', 'Sekunder'],
labels1: ['År', 'Månad', 'Uge', 'Dag', 'Time', 'Minut', 'Sekund'],
compactLabels: ['Å', 'M', 'U', 'D'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['da']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
German initialisation for the jQuery countdown extension
Written by Samuel Wulf. */
(function($) {
$.countdown.regional['de'] = {
labels: ['Jahre', 'Monate', 'Wochen', 'Tage', 'Stunden', 'Minuten', 'Sekunden'],
labels1: ['Jahr', 'Monat', 'Woche', 'Tag', 'Stunde', 'Minute', 'Sekunde'],
compactLabels: ['J', 'M', 'W', 'T'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['de']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
Greek initialisation for the jQuery countdown extension
Written by Philip. */
(function($) {
$.countdown.regional['el'] = {
labels: ['Χρόνια', 'Μήνες', 'Εβδομάδες', 'Μέρες', 'Ώρες', 'Λεπτά', 'Δευτερόλεπτα'],
labels1: ['Χρόνος', 'Μήνας', 'Εβδομάδα', 'Ημέρα', 'Ώρα', 'Λεπτό', 'Δευτερόλεπτο'],
compactLabels: ['Χρ.', 'Μην.', 'Εβδ.', 'Ημ.'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['el']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
* Spanish initialisation for the jQuery countdown extension
* Written by Sergio Carracedo Martinez webmaster@neodisenoweb.com (2008) */
(function($) {
$.countdown.regional['es'] = {
labels: ['Años', 'Meses', 'Semanas', 'Días', 'Horas', 'Minutos', 'Segundos'],
labels1: ['Año', 'Mes', 'Semana', 'Día', 'Hora', 'Minuto', 'Segundo'],
compactLabels: ['a', 'm', 's', 'g'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['es']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
Estonian initialisation for the jQuery countdown extension
Written by Helmer <helmer{at}city.ee> */
(function($) {
$.countdown.regional['et'] = {
labels: ['Aastat', 'Kuud', 'Nädalat', 'Päeva', 'Tundi', 'Minutit', 'Sekundit'],
labels1: ['Aasta', 'Kuu', 'Nädal', 'Päev', 'Tund', 'Minut', 'Sekund'],
compactLabels: ['a', 'k', 'n', 'p'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['et']);
})(jQuery);

View File

@ -0,0 +1,14 @@
/* http://keith-wood.name/countdown.html
Persian (فارسی) initialisation for the jQuery countdown extension
Written by Alireza Ziaie (ziai@magfa.com) Oct 2008.
Digits corrected by Hamed Ramezanian Feb 2013. */
(function($) {
$.countdown.regional['fa'] = {
labels: ['‌سال', 'ماه', 'هفته', 'روز', 'ساعت', 'دقیقه', 'ثانیه'],
labels1: ['سال', 'ماه', 'هفته', 'روز', 'ساعت', 'دقیقه', 'ثانیه'],
compactLabels: ['س', 'م', 'ه', 'ر'],
whichLabels: null,
digits: ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'],
timeSeparator: ':', isRTL: true};
$.countdown.setDefaults($.countdown.regional['fa']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
Finnish initialisation for the jQuery countdown extension
Written by Kalle Vänskä and Juha Suni (juhis.suni@gmail.com). Corrected by Olli. */
(function($) {
$.countdown.regional['fi'] = {
labels: ['vuotta', 'kuukautta', 'viikkoa', 'päivää', 'tuntia', 'minuuttia', 'sekuntia'],
labels1: ['vuosi', 'kuukausi', 'viikko', 'päivä', 'tunti', 'minuutti', 'sekunti'],
compactLabels: ['v', 'kk', 'vk', 'pv'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['fi']);
})(jQuery);

View File

@ -0,0 +1,15 @@
/* http://keith-wood.name/countdown.html
French initialisation for the jQuery countdown extension
Written by Keith Wood (kbwood{at}iinet.com.au) Jan 2008. */
(function($) {
$.countdown.regional['fr'] = {
labels: ['Années', 'Mois', 'Semaines', 'Jours', 'Heures', 'Minutes', 'Secondes'],
labels1: ['Année', 'Mois', 'Semaine', 'Jour', 'Heure', 'Minute', 'Seconde'],
compactLabels: ['a', 'm', 's', 'j'],
whichLabels: function(amount) {
return (amount > 1 ? 0 : 1);
},
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['fr']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
* Galician initialisation for the jQuery countdown extension
* Written by Moncho Pena ramon.pena.rodriguez@gmail.com (2009) and Angel Farrapeira */
(function($) {
$.countdown.regional['gl'] = {
labels: ['Anos', 'Meses', 'Semanas', 'Días', 'Horas', 'Minutos', 'Segundos'],
labels1: ['Ano', 'Mes', 'Semana', 'Día', 'Hora', 'Minuto', 'Segundo'],
compactLabels: ['a', 'm', 's', 'g'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['gl']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
* Gujarati initialization for the jQuery countdown extension
* Written by Sahil Jariwala jariwala.sahil@gmail.com (2012) */
(function($) {
$.countdown.regional['gu'] = {
labels: ['વર્ષ', 'મહિનો', 'અઠવાડિયા', 'દિવસ', 'કલાક', 'મિનિટ','સેકન્ડ'],
labels1: ['વર્ષ','મહિનો','અઠવાડિયા','દિવસ','કલાક','મિનિટ', 'સેકન્ડ'],
compactLabels: ['વ', 'મ', 'અ', 'દિ'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['gu']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
* Hebrew initialisation for the jQuery countdown extension
* Translated by Nir Livne, Dec 2008 */
(function($) {
$.countdown.regional['he'] = {
labels: ['שנים', 'חודשים', 'שבועות', 'ימים', 'שעות', 'דקות', 'שניות'],
labels1: ['שנה', 'חודש', 'שבוע', 'יום', 'שעה', 'דקה', 'שנייה'],
compactLabels: ['שנ', 'ח', 'שב', 'י'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: true};
$.countdown.setDefaults($.countdown.regional['he']);
})(jQuery);

View File

@ -0,0 +1,16 @@
/* http://keith-wood.name/countdown.html
* Croatian Latin initialisation for the jQuery countdown extension
* Written by Dejan Broz info@hqfactory.com (2011) */
(function($) {
$.countdown.regional['hr'] = {
labels: ['Godina', 'Mjeseci', 'Tjedana', 'Dana', 'Sati', 'Minuta', 'Sekundi'],
labels1: ['Godina', 'Mjesec', 'Tjedan', 'Dan', 'Sat', 'Minuta', 'Sekunda'],
labels2: ['Godine', 'Mjeseca', 'Tjedna', 'Dana', 'Sata', 'Minute', 'Sekunde'],
compactLabels: ['g', 'm', 't', 'd'],
whichLabels: function(amount) {
return (amount == 1 ? 1 : (amount >= 2 && amount <= 4 ? 2 : 0));
},
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['hr']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
* Hungarian initialisation for the jQuery countdown extension
* Written by Edmond L. (webmond@gmail.com). */
(function($) {
$.countdown.regional['hu'] = {
labels: ['Év', 'Hónap', 'Hét', 'Nap', 'Óra', 'Perc', 'Másodperc'],
labels1: ['Év', 'Hónap', 'Hét', 'Nap', 'Óra', 'Perc', 'Másodperc'],
compactLabels: ['É', 'H', 'Hé', 'N'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['hu']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
* Armenian initialisation for the jQuery countdown extension
* Written by Artur Martirosyan. (artur{at}zoom.am) October 2011. */
(function($) {
$.countdown.regional['hy'] = {
labels: ['Տարի', 'Ամիս', 'Շաբաթ', 'Օր', 'Ժամ', 'Րոպե', 'Վարկյան'],
labels1: ['Տարի', 'Ամիս', 'Շաբաթ', 'Օր', 'Ժամ', 'Րոպե', 'Վարկյան'],
compactLabels: ['տ', 'ա', 'շ', 'օ'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['hy']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
Indonesian initialisation for the jQuery countdown extension
Written by Erwin Yonathan Jan 2009. */
(function($) {
$.countdown.regional['id'] = {
labels: ['tahun', 'bulan', 'minggu', 'hari', 'jam', 'menit', 'detik'],
labels1: ['tahun', 'bulan', 'minggu', 'hari', 'jam', 'menit', 'detik'],
compactLabels: ['t', 'b', 'm', 'h'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['id']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
* Italian initialisation for the jQuery countdown extension
* Written by Davide Bellettini (davide.bellettini@gmail.com) and Roberto Chiaveri Feb 2008. */
(function($) {
$.countdown.regional['it'] = {
labels: ['Anni', 'Mesi', 'Settimane', 'Giorni', 'Ore', 'Minuti', 'Secondi'],
labels1: ['Anno', 'Mese', 'Settimana', 'Giorno', 'Ora', 'Minuto', 'Secondo'],
compactLabels: ['a', 'm', 's', 'g'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['it']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
Japanese initialisation for the jQuery countdown extension
Written by Ken Ishimoto (ken@ksroom.com) Aug 2009. */
(function($) {
$.countdown.regional['ja'] = {
labels: ['年', '月', '週', '日', '時', '分', '秒'],
labels1: ['年', '月', '週', '日', '時', '分', '秒'],
compactLabels: ['年', '月', '週', '日'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['ja']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
* Kannada initialization for the jQuery countdown extension
* Written by Guru Chaturvedi guru@gangarasa.com (2011) */
(function($) {
$.countdown.regional['kn'] = {
labels: ['ವರ್ಷಗಳು', 'ತಿಂಗಳು', 'ವಾರಗಳು', 'ದಿನಗಳು', 'ಘಂಟೆಗಳು', 'ನಿಮಿಷಗಳು', 'ಕ್ಷಣಗಳು'],
labels1: ['ವರ್ಷ', 'ತಿಂಗಳು', 'ವಾರ', 'ದಿನ', 'ಘಂಟೆ', 'ನಿಮಿಷ', 'ಕ್ಷಣ'],
compactLabels: ['ವ', 'ತಿ', 'ವಾ', 'ದಿ'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['kn']);
})(jQuery);

View File

@ -0,0 +1,14 @@
/* http://keith-wood.name/countdown.html
Korean initialisation for the jQuery countdown extension
Written by Ryan Yu (ryanyu79@gmail.com). */
(function($) {
$.countdown.regional['ko'] = {
labels: ['년', '월', '주', '일', '시', '분', '초'],
labels1: ['년', '월', '주', '일', '시', '분', '초'],
compactLabels: ['년', '월', '주', '일'],
compactLabels1: ['년', '월', '주', '일'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['ko']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
* Lithuanian localisation for the jQuery countdown extension
* Written by Moacir P. de Sá Pereira (moacir{at}gmail.com) (2009) */
(function($) {
$.countdown.regional['lt'] = {
labels: ['Metų', 'Mėnesių', 'Savaičių', 'Dienų', 'Valandų', 'Minučių', 'Sekundžių'],
labels1: ['Metai', 'Mėnuo', 'Savaitė', 'Diena', 'Valanda', 'Minutė', 'Sekundė'],
compactLabels: ['m', 'm', 's', 'd'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['lt']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
* Latvian initialisation for the jQuery countdown extension
* Written by Jānis Peisenieks janis.peisenieks@gmail.com (2010) */
(function($) {
$.countdown.regional['lv'] = {
labels: ['Gadi', 'Mēneši', 'Nedēļas', 'Dienas', 'Stundas', 'Minūtes', 'Sekundes'],
labels1: ['Gads', 'Mēnesis', 'Nedēļa', 'Diena', 'Stunda', 'Minūte', 'Sekunde'],
compactLabels: ['l', 'm', 'n', 'd'], compactLabels1: ['g', 'm', 'n', 'd'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['lv']);
})(jQuery);

View File

@ -0,0 +1,14 @@
/* http://keith-wood.name/countdown.html
* Malayalam/(Indian>>Kerala) initialisation for the jQuery countdown extension
* Written by Harilal.B (harilal1234@gmail.com) Feb 2013. */
(function($) {
$.countdown.regional['ml'] = {
labels: ['വര്‍ഷങ്ങള്‍', 'മാസങ്ങള്‍', 'ആഴ്ചകള്‍', 'ദിവസങ്ങള്‍', 'മണിക്കൂറുകള്‍', 'മിനിറ്റുകള്‍', 'സെക്കന്റുകള്‍'],
labels1: ['വര്‍ഷം', 'മാസം', 'ആഴ്ച', 'ദിവസം', 'മണിക്കൂര്‍', 'മിനിറ്റ്', 'സെക്കന്റ്'],
compactLabels: ['വ', 'മ', 'ആ', 'ദി'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
// digits: ['', '൧', '൨', '൩', '൪', '൫', '൬', '', '൮', '൯'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['ml']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
Malay initialisation for the jQuery countdown extension
Written by Jason Ong (jason{at}portalgroove.com) May 2010. */
(function($) {
$.countdown.regional['ms'] = {
labels: ['Tahun', 'Bulan', 'Minggu', 'Hari', 'Jam', 'Minit', 'Saat'],
labels1: ['Tahun', 'Bulan', 'Minggu', 'Hari', 'Jam', 'Minit', 'Saat'],
compactLabels: ['t', 'b', 'm', 'h'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['ms']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
Burmese initialisation for the jQuery countdown extension
Written by Win Lwin Moe (winnlwinmoe@gmail.com) Dec 2009. */
(function($) {
$.countdown.regional['my'] = {
labels: ['နွစ္', 'လ', 'ရက္သတဿတပတ္', 'ရက္', 'နာရီ', 'မိနစ္', 'စကဿကန့္'],
labels1: ['နွစ္', 'လ', 'ရက္သတဿတပတ္', 'ရက္', 'နာရီ', 'မိနစ္', 'စကဿကန့္'],
compactLabels: ['နွစ္', 'လ', 'ရက္သတဿတပတ္', 'ရက္'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['my']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
Norwegian Bokmål translation
Written by Kristian Ravnevand */
(function($) {
$.countdown.regional['nb'] = {
labels: ['År', 'Måneder', 'Uker', 'Dager', 'Timer', 'Minutter', 'Sekunder'],
labels1: ['År', 'Måned', 'Uke', 'Dag', 'Time', 'Minutt', 'Sekund'],
compactLabels: ['Å', 'M', 'U', 'D'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['nb']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
Dutch initialisation for the jQuery countdown extension
Written by Mathias Bynens <http://mathiasbynens.be/> Mar 2008. */
(function($) {
$.countdown.regional['nl'] = {
labels: ['Jaren', 'Maanden', 'Weken', 'Dagen', 'Uren', 'Minuten', 'Seconden'],
labels1: ['Jaar', 'Maand', 'Week', 'Dag', 'Uur', 'Minuut', 'Seconde'],
compactLabels: ['j', 'm', 'w', 'd'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['nl']);
})(jQuery);

View File

@ -0,0 +1,18 @@
/* http://keith-wood.name/countdown.html
* Polish initialisation for the jQuery countdown extension
* Written by Pawel Lewtak lewtak@gmail.com (2008) */
(function($) {
$.countdown.regional['pl'] = {
labels: ['lat', 'miesięcy', 'tygodni', 'dni', 'godzin', 'minut', 'sekund'],
labels1: ['rok', 'miesiąc', 'tydzień', 'dzień', 'godzina', 'minuta', 'sekunda'],
labels2: ['lata', 'miesiące', 'tygodnie', 'dni', 'godziny', 'minuty', 'sekundy'],
compactLabels: ['l', 'm', 't', 'd'], compactLabels1: ['r', 'm', 't', 'd'],
whichLabels: function(amount) {
var units = amount % 10;
var tens = Math.floor((amount % 100) / 10);
return (amount == 1 ? 1 : (units >= 2 && units <= 4 && tens != 1 ? 2 : 0));
},
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['pl']);
})(jQuery);

View File

@ -0,0 +1,14 @@
/* http://keith-wood.name/countdown.html
Brazilian initialisation for the jQuery countdown extension
Translated by Marcelo Pellicano de Oliveira (pellicano@gmail.com) Feb 2008.
and Juan Roldan (juan.roldan[at]relayweb.com.br) Mar 2012. */
(function($) {
$.countdown.regional['pt-BR'] = {
labels: ['Anos', 'Meses', 'Semanas', 'Dias', 'Horas', 'Minutos', 'Segundos'],
labels1: ['Ano', 'M<>s', 'Semana', 'Dia', 'Hora', 'Minuto', 'Segundo'],
compactLabels: ['a', 'm', 's', 'd'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['pt-BR']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
* Romanian initialisation for the jQuery countdown extension
* Written by Edmond L. (webmond@gmail.com). */
(function($) {
$.countdown.regional['ro'] = {
labels: ['Ani', 'Luni', 'Saptamani', 'Zile', 'Ore', 'Minute', 'Secunde'],
labels1: ['An', 'Luna', 'Saptamana', 'Ziua', 'Ora', 'Minutul', 'Secunda'],
compactLabels: ['A', 'L', 'S', 'Z'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['ro']);
})(jQuery);

View File

@ -0,0 +1,19 @@
/* http://keith-wood.name/countdown.html
* Russian initialisation for the jQuery countdown extension
* Written by Sergey K. (xslade{at}gmail.com) June 2010. */
(function($) {
$.countdown.regional['ru'] = {
labels: ['Лет', 'Месяцев', 'Недель', 'Дней', 'Часов', 'Минут', 'Секунд'],
labels1: ['Год', 'Месяц', 'Неделя', 'День', 'Час', 'Минута', 'Секунда'],
labels2: ['Года', 'Месяца', 'Недели', 'Дня', 'Часа', 'Минуты', 'Секунды'],
compactLabels: ['л', 'м', 'н', 'д'], compactLabels1: ['г', 'м', 'н', 'д'],
whichLabels: function(amount) {
var units = amount % 10;
var tens = Math.floor((amount % 100) / 10);
return (amount == 1 ? 1 : (units >= 2 && units <= 4 && tens != 1 ? 2 :
(units == 1 && tens != 1 ? 1 : 0)));
},
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['ru']);
})(jQuery);

View File

@ -0,0 +1,16 @@
/* http://keith-wood.name/countdown.html
* Slovak initialisation for the jQuery countdown extension
* Written by Roman Chlebec (creamd@c64.sk) (2008) */
(function($) {
$.countdown.regional['sk'] = {
labels: ['Rokov', 'Mesiacov', 'Týždňov', 'Dní', 'Hodín', 'Minút', 'Sekúnd'],
labels1: ['Rok', 'Mesiac', 'Týždeň', 'Deň', 'Hodina', 'Minúta', 'Sekunda'],
labels2: ['Roky', 'Mesiace', 'Týždne', 'Dni', 'Hodiny', 'Minúty', 'Sekundy'],
compactLabels: ['r', 'm', 't', 'd'],
whichLabels: function(amount) {
return (amount == 1 ? 1 : (amount >= 2 && amount <= 4 ? 2 : 0));
},
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['sk']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
* Slovenian localisation for the jQuery countdown extension
* Written by Borut Tomažin (debijan{at}gmail.com) (2011) */
(function($) {
$.countdown.regional['sl'] = {
labels: ['Let', 'Mesecev', 'Tednov', 'Dni', 'Ur', 'Minut', 'Sekund'],
labels1: ['Leto', 'Mesec', 'Teden', 'Dan', 'Ura', 'Minuta', 'Sekunda'],
compactLabels: ['l', 'm', 't', 'd'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['sl']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
Albanian initialisation for the jQuery countdown extension
Written by Erzen Komoni. */
(function($) {
$.countdown.regional['sq'] = {
labels: ['Vite', 'Muaj', 'Javë', 'Ditë', 'Orë', 'Minuta', 'Sekonda'],
labels1: ['Vit', 'Muaj', 'Javë', 'Dit', 'Orë', 'Minutë', 'Sekond'],
compactLabels: ['V', 'M', 'J', 'D'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['sq']);
})(jQuery);

View File

@ -0,0 +1,16 @@
/* http://keith-wood.name/countdown.html
* Serbian Latin initialisation for the jQuery countdown extension
* Written by Predrag Leka lp@lemurcake.com (2010) */
(function($) {
$.countdown.regional['sr-SR'] = {
labels: ['Godina', 'Meseci', 'Nedelja', 'Dana', 'Časova', 'Minuta', 'Sekundi'],
labels1: ['Godina', 'Mesec', 'Nedelja', 'Dan', 'Čas', 'Minut', 'Sekunda'],
labels2: ['Godine', 'Meseca', 'Nedelje', 'Dana', 'Časa', 'Minuta', 'Sekunde'],
compactLabels: ['g', 'm', 'n', 'd'],
whichLabels: function(amount) {
return (amount == 1 ? 1 : (amount >= 2 && amount <= 4 ? 2 : 0));
},
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['sr-SR']);
})(jQuery);

View File

@ -0,0 +1,16 @@
/* http://keith-wood.name/countdown.html
* Serbian Cyrillic initialisation for the jQuery countdown extension
* Written by Predrag Leka lp@lemurcake.com (2010) */
(function($) {
$.countdown.regional['sr'] = {
labels: ['Година', 'Месеци', 'Недеља', 'Дана', 'Часова', 'Минута', 'Секунди'],
labels1: ['Година', 'месец', 'Недеља', 'Дан', 'Час', 'Минут', 'Секунда'],
labels2: ['Године', 'Месеца', 'Недеље', 'Дана', 'Часа', 'Минута', 'Секунде'],
compactLabels: ['г', 'м', 'н', 'д'],
whichLabels: function(amount) {
return (amount == 1 ? 1 : (amount >= 2 && amount <= 4 ? 2 : 0));
},
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['sr']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
Swedish initialisation for the jQuery countdown extension
Written by Carl (carl@nordenfelt.com). */
(function($) {
$.countdown.regional['sv'] = {
labels: ['År', 'Månader', 'Veckor', 'Dagar', 'Timmar', 'Minuter', 'Sekunder'],
labels1: ['År', 'Månad', 'Vecka', 'Dag', 'Timme', 'Minut', 'Sekund'],
compactLabels: ['Å', 'M', 'V', 'D'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['sv']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
Thai initialisation for the jQuery countdown extension
Written by Pornchai Sakulsrimontri (li_sin_th@yahoo.com). */
(function($) {
$.countdown.regional['th'] = {
labels: ['ปี', 'เดือน', 'สัปดาห์', 'วัน', 'ชั่วโมง', 'นาที', 'วินาที'],
labels1: ['ปี', 'เดือน', 'สัปดาห์', 'วัน', 'ชั่วโมง', 'นาที', 'วินาที'],
compactLabels: ['ปี', 'เดือน', 'สัปดาห์', 'วัน'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['th']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
* Turkish initialisation for the jQuery countdown extension
* Written by Bekir Ahmetoğlu (bekir@cerek.com) Aug 2008. */
(function($) {
$.countdown.regional['tr'] = {
labels: ['Yıl', 'Ay', 'Hafta', 'Gün', 'Saat', 'Dakika', 'Saniye'],
labels1: ['Yıl', 'Ay', 'Hafta', 'Gün', 'Saat', 'Dakika', 'Saniye'],
compactLabels: ['y', 'a', 'h', 'g'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['tr']);
})(jQuery);

View File

@ -0,0 +1,16 @@
/* http://keith-wood.name/countdown.html
* Ukrainian initialisation for the jQuery countdown extension
* Written by Goloborodko M misha.gm@gmail.com (2009), corrections by Iгор Kоновал */
(function($) {
$.countdown.regional['uk'] = {
labels: ['Років', 'Місяців', 'Тижнів', 'Днів', 'Годин', 'Хвилин', 'Секунд'],
labels1: ['Рік', 'Місяць', 'Тиждень', 'День', 'Година', 'Хвилина', 'Секунда'],
labels2: ['Роки', 'Місяці', 'Тижні', 'Дні', 'Години', 'Хвилини', 'Секунди'],
compactLabels: ['r', 'm', 't', 'd'],
whichLabels: function(amount) {
return (amount == 1 ? 1 : (amount >=2 && amount <= 4 ? 2 : 0));
},
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['uk']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
* Uzbek initialisation for the jQuery countdown extension
* Written by Alisher U. (ulugbekov{at}gmail.com) August 2012. */
(function($) {
$.countdown.regional['uz'] = {
labels: ['Yil', 'Oy', 'Hafta', 'Kun', 'Soat', 'Daqiqa', 'Soniya'],
labels1: ['Yil', 'Oy', 'Hafta', 'Kun', 'Soat', 'Daqiqa', 'Soniya'],
compactLabels: ['y', 'o', 'h', 'k'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['uz']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
* Vietnamese initialisation for the jQuery countdown extension
* Written by Pham Tien Hung phamtienhung@gmail.com (2010) */
(function($) {
$.countdown.regional['vi'] = {
labels: ['Năm', 'Tháng', 'Tuần', 'Ngày', 'Giờ', 'Phút', 'Giây'],
labels1: ['Năm', 'Tháng', 'Tuần', 'Ngày', 'Giờ', 'Phút', 'Giây'],
compactLabels: ['năm', 'th', 'tu', 'ng'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['vi']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
Simplified Chinese initialisation for the jQuery countdown extension
Written by Cloudream (cloudream@gmail.com). */
(function($) {
$.countdown.regional['zh-CN'] = {
labels: ['年', '月', '周', '天', '时', '分', '秒'],
labels1: ['年', '月', '周', '天', '时', '分', '秒'],
compactLabels: ['年', '月', '周', '天'], compactLabels1: ['年', '月', '周', '天'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['zh-CN']);
})(jQuery);

View File

@ -0,0 +1,13 @@
/* http://keith-wood.name/countdown.html
Traditional Chinese initialisation for the jQuery countdown extension
Written by Cloudream (cloudream@gmail.com). */
(function($) {
$.countdown.regional['zh-TW'] = {
labels: ['年', '月', '周', '天', '時', '分', '秒'],
labels1: ['年', '月', '周', '天', '時', '分', '秒'],
compactLabels: ['年', '月', '周', '天'], compactLabels1: ['年', '月', '周', '天'],
whichLabels: null,
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
timeSeparator: ':', isRTL: false};
$.countdown.setDefaults($.countdown.regional['zh-TW']);
})(jQuery);

View File

@ -0,0 +1,51 @@
/* jQuery Countdown styles 1.6.3. */
.hasCountdown {
border: 1px solid #ccc;
background-color: #eee;
}
.countdown_rtl {
direction: rtl;
}
.countdown_holding span {
color: #888;
}
.countdown_row {
clear: both;
width: 100%;
padding: 0px 2px;
text-align: center;
}
.countdown_show1 .countdown_section {
width: 98%;
}
.countdown_show2 .countdown_section {
width: 48%;
}
.countdown_show3 .countdown_section {
width: 32.5%;
}
.countdown_show4 .countdown_section {
width: 24.5%;
}
.countdown_show5 .countdown_section {
width: 19.5%;
}
.countdown_show6 .countdown_section {
width: 16.25%;
}
.countdown_show7 .countdown_section {
width: 14%;
}
.countdown_section {
display: block;
float: left;
font-size: 75%;
text-align: center;
}
.countdown_amount {
font-size: 200%;
}
.countdown_descr {
display: block;
width: 100%;
}

View File

@ -0,0 +1,810 @@
/* http://keith-wood.name/countdown.html
Countdown for jQuery v1.6.3.
Written by Keith Wood (kbwood{at}iinet.com.au) January 2008.
Available under the MIT (https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt) license.
Please attribute the author if you use it. */
/* Display a countdown timer.
Attach it with options like:
$('div selector').countdown(
{until: new Date(2009, 1 - 1, 1, 0, 0, 0), onExpiry: happyNewYear}); */
(function($) { // Hide scope, no $ conflict
/* Countdown manager. */
function Countdown() {
this.regional = []; // Available regional settings, indexed by language code
this.regional[''] = { // Default regional settings
// The display texts for the counters
labels: ['Years', 'Months', 'Weeks', 'Days', 'Hours', 'Minutes', 'Seconds'],
// The display texts for the counters if only one
labels1: ['Year', 'Month', 'Week', 'Day', 'Hour', 'Minute', 'Second'],
compactLabels: ['y', 'm', 'w', 'd'], // The compact texts for the counters
whichLabels: null, // Function to determine which labels to use
digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], // The digits to display
timeSeparator: ':', // Separator for time periods
isRTL: false // True for right-to-left languages, false for left-to-right
};
this._defaults = {
until: null, // new Date(year, mth - 1, day, hr, min, sec) - date/time to count down to
// or numeric for seconds offset, or string for unit offset(s):
// 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
since: null, // new Date(year, mth - 1, day, hr, min, sec) - date/time to count up from
// or numeric for seconds offset, or string for unit offset(s):
// 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
timezone: null, // The timezone (hours or minutes from GMT) for the target times,
// or null for client local
serverSync: null, // A function to retrieve the current server time for synchronisation
format: 'dHMS', // Format for display - upper case for always, lower case only if non-zero,
// 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
layout: '', // Build your own layout for the countdown
compact: false, // True to display in a compact format, false for an expanded one
significant: 0, // The number of periods with values to show, zero for all
description: '', // The description displayed for the countdown
expiryUrl: '', // A URL to load upon expiry, replacing the current page
expiryText: '', // Text to display upon expiry, replacing the countdown
alwaysExpire: false, // True to trigger onExpiry even if never counted down
onExpiry: null, // Callback when the countdown expires -
// receives no parameters and 'this' is the containing division
onTick: null, // Callback when the countdown is updated -
// receives int[7] being the breakdown by period (based on format)
// and 'this' is the containing division
tickInterval: 1 // Interval (seconds) between onTick callbacks
};
$.extend(this._defaults, this.regional['']);
this._serverSyncs = [];
var now = (typeof Date.now == 'function' ? Date.now :
function() { return new Date().getTime(); });
var perfAvail = (window.performance && typeof window.performance.now == 'function');
// Shared timer for all countdowns
function timerCallBack(timestamp) {
var drawStart = (timestamp < 1e12 ? // New HTML5 high resolution timer
(perfAvail ? (performance.now() + performance.timing.navigationStart) : now()) :
// Integer milliseconds since unix epoch
timestamp || now());
if (drawStart - animationStartTime >= 1000) {
plugin._updateTargets();
animationStartTime = drawStart;
}
requestAnimationFrame(timerCallBack);
}
var requestAnimationFrame = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame || window.msRequestAnimationFrame || null;
// This is when we expect a fall-back to setInterval as it's much more fluid
var animationStartTime = 0;
if (!requestAnimationFrame || $.noRequestAnimationFrame) {
$.noRequestAnimationFrame = null;
setInterval(function() { plugin._updateTargets(); }, 980); // Fall back to good old setInterval
}
else {
animationStartTime = window.animationStartTime ||
window.webkitAnimationStartTime || window.mozAnimationStartTime ||
window.oAnimationStartTime || window.msAnimationStartTime || now();
requestAnimationFrame(timerCallBack);
}
}
var Y = 0; // Years
var O = 1; // Months
var W = 2; // Weeks
var D = 3; // Days
var H = 4; // Hours
var M = 5; // Minutes
var S = 6; // Seconds
$.extend(Countdown.prototype, {
/* Class name added to elements to indicate already configured with countdown. */
markerClassName: 'hasCountdown',
/* Name of the data property for instance settings. */
propertyName: 'countdown',
/* Class name for the right-to-left marker. */
_rtlClass: 'countdown_rtl',
/* Class name for the countdown section marker. */
_sectionClass: 'countdown_section',
/* Class name for the period amount marker. */
_amountClass: 'countdown_amount',
/* Class name for the countdown row marker. */
_rowClass: 'countdown_row',
/* Class name for the holding countdown marker. */
_holdingClass: 'countdown_holding',
/* Class name for the showing countdown marker. */
_showClass: 'countdown_show',
/* Class name for the description marker. */
_descrClass: 'countdown_descr',
/* List of currently active countdown targets. */
_timerTargets: [],
/* Override the default settings for all instances of the countdown widget.
@param options (object) the new settings to use as defaults */
setDefaults: function(options) {
this._resetExtraLabels(this._defaults, options);
$.extend(this._defaults, options || {});
},
/* Convert a date/time to UTC.
@param tz (number) the hour or minute offset from GMT, e.g. +9, -360
@param year (Date) the date/time in that timezone or
(number) the year in that timezone
@param month (number, optional) the month (0 - 11) (omit if year is a Date)
@param day (number, optional) the day (omit if year is a Date)
@param hours (number, optional) the hour (omit if year is a Date)
@param mins (number, optional) the minute (omit if year is a Date)
@param secs (number, optional) the second (omit if year is a Date)
@param ms (number, optional) the millisecond (omit if year is a Date)
@return (Date) the equivalent UTC date/time */
UTCDate: function(tz, year, month, day, hours, mins, secs, ms) {
if (typeof year == 'object' && year.constructor == Date) {
ms = year.getMilliseconds();
secs = year.getSeconds();
mins = year.getMinutes();
hours = year.getHours();
day = year.getDate();
month = year.getMonth();
year = year.getFullYear();
}
var d = new Date();
d.setUTCFullYear(year);
d.setUTCDate(1);
d.setUTCMonth(month || 0);
d.setUTCDate(day || 1);
d.setUTCHours(hours || 0);
d.setUTCMinutes((mins || 0) - (Math.abs(tz) < 30 ? tz * 60 : tz));
d.setUTCSeconds(secs || 0);
d.setUTCMilliseconds(ms || 0);
return d;
},
/* Convert a set of periods into seconds.
Averaged for months and years.
@param periods (number[7]) the periods per year/month/week/day/hour/minute/second
@return (number) the corresponding number of seconds */
periodsToSeconds: function(periods) {
return periods[0] * 31557600 + periods[1] * 2629800 + periods[2] * 604800 +
periods[3] * 86400 + periods[4] * 3600 + periods[5] * 60 + periods[6];
},
/* Attach the countdown widget to a div.
@param target (element) the containing division
@param options (object) the initial settings for the countdown */
_attachPlugin: function(target, options) {
target = $(target);
if (target.hasClass(this.markerClassName)) {
return;
}
var inst = {options: $.extend({}, this._defaults), _periods: [0, 0, 0, 0, 0, 0, 0]};
target.addClass(this.markerClassName).data(this.propertyName, inst);
this._optionPlugin(target, options);
},
/* Add a target to the list of active ones.
@param target (element) the countdown target */
_addTarget: function(target) {
if (!this._hasTarget(target)) {
this._timerTargets.push(target);
}
},
/* See if a target is in the list of active ones.
@param target (element) the countdown target
@return (boolean) true if present, false if not */
_hasTarget: function(target) {
return ($.inArray(target, this._timerTargets) > -1);
},
/* Remove a target from the list of active ones.
@param target (element) the countdown target */
_removeTarget: function(target) {
this._timerTargets = $.map(this._timerTargets,
function(value) { return (value == target ? null : value); }); // delete entry
},
/* Update each active timer target. */
_updateTargets: function() {
for (var i = this._timerTargets.length - 1; i >= 0; i--) {
this._updateCountdown(this._timerTargets[i]);
}
},
/* Reconfigure the settings for a countdown div.
@param target (element) the control to affect
@param options (object) the new options for this instance or
(string) an individual property name
@param value (any) the individual property value (omit if options
is an object or to retrieve the value of a setting)
@return (any) if retrieving a value */
_optionPlugin: function(target, options, value) {
target = $(target);
var inst = target.data(this.propertyName);
if (!options || (typeof options == 'string' && value == null)) { // Get option
var name = options;
options = (inst || {}).options;
return (options && name ? options[name] : options);
}
if (!target.hasClass(this.markerClassName)) {
return;
}
options = options || {};
if (typeof options == 'string') {
var name = options;
options = {};
options[name] = value;
}
if (options.layout) {
options.layout = options.layout.replace(/&lt;/g, '<').replace(/&gt;/g, '>');
}
this._resetExtraLabels(inst.options, options);
var timezoneChanged = (inst.options.timezone != options.timezone);
$.extend(inst.options, options);
this._adjustSettings(target, inst,
options.until != null || options.since != null || timezoneChanged);
var now = new Date();
if ((inst._since && inst._since < now) || (inst._until && inst._until > now)) {
this._addTarget(target[0]);
}
this._updateCountdown(target, inst);
},
/* Redisplay the countdown with an updated display.
@param target (jQuery) the containing division
@param inst (object) the current settings for this instance */
_updateCountdown: function(target, inst) {
var $target = $(target);
inst = inst || $target.data(this.propertyName);
if (!inst) {
return;
}
$target.html(this._generateHTML(inst)).toggleClass(this._rtlClass, inst.options.isRTL);
if ($.isFunction(inst.options.onTick)) {
var periods = inst._hold != 'lap' ? inst._periods :
this._calculatePeriods(inst, inst._show, inst.options.significant, new Date());
if (inst.options.tickInterval == 1 ||
this.periodsToSeconds(periods) % inst.options.tickInterval == 0) {
inst.options.onTick.apply(target, [periods]);
}
}
var expired = inst._hold != 'pause' &&
(inst._since ? inst._now.getTime() < inst._since.getTime() :
inst._now.getTime() >= inst._until.getTime());
if (expired && !inst._expiring) {
inst._expiring = true;
if (this._hasTarget(target) || inst.options.alwaysExpire) {
this._removeTarget(target);
if ($.isFunction(inst.options.onExpiry)) {
inst.options.onExpiry.apply(target, []);
}
if (inst.options.expiryText) {
var layout = inst.options.layout;
inst.options.layout = inst.options.expiryText;
this._updateCountdown(target, inst);
inst.options.layout = layout;
}
if (inst.options.expiryUrl) {
window.location = inst.options.expiryUrl;
}
}
inst._expiring = false;
}
else if (inst._hold == 'pause') {
this._removeTarget(target);
}
$target.data(this.propertyName, inst);
},
/* Reset any extra labelsn and compactLabelsn entries if changing labels.
@param base (object) the options to be updated
@param options (object) the new option values */
_resetExtraLabels: function(base, options) {
var changingLabels = false;
for (var n in options) {
if (n != 'whichLabels' && n.match(/[Ll]abels/)) {
changingLabels = true;
break;
}
}
if (changingLabels) {
for (var n in base) { // Remove custom numbered labels
if (n.match(/[Ll]abels[02-9]|compactLabels1/)) {
base[n] = null;
}
}
}
},
/* Calculate interal settings for an instance.
@param target (element) the containing division
@param inst (object) the current settings for this instance
@param recalc (boolean) true if until or since are set */
_adjustSettings: function(target, inst, recalc) {
var now;
var serverOffset = 0;
var serverEntry = null;
for (var i = 0; i < this._serverSyncs.length; i++) {
if (this._serverSyncs[i][0] == inst.options.serverSync) {
serverEntry = this._serverSyncs[i][1];
break;
}
}
if (serverEntry != null) {
serverOffset = (inst.options.serverSync ? serverEntry : 0);
now = new Date();
}
else {
var serverResult = ($.isFunction(inst.options.serverSync) ?
inst.options.serverSync.apply(target, []) : null);
now = new Date();
serverOffset = (serverResult ? now.getTime() - serverResult.getTime() : 0);
this._serverSyncs.push([inst.options.serverSync, serverOffset]);
}
var timezone = inst.options.timezone;
timezone = (timezone == null ? -now.getTimezoneOffset() : timezone);
if (recalc || (!recalc && inst._until == null && inst._since == null)) {
inst._since = inst.options.since;
if (inst._since != null) {
inst._since = this.UTCDate(timezone, this._determineTime(inst._since, null));
if (inst._since && serverOffset) {
inst._since.setMilliseconds(inst._since.getMilliseconds() + serverOffset);
}
}
inst._until = this.UTCDate(timezone, this._determineTime(inst.options.until, now));
if (serverOffset) {
inst._until.setMilliseconds(inst._until.getMilliseconds() + serverOffset);
}
}
inst._show = this._determineShow(inst);
},
/* Remove the countdown widget from a div.
@param target (element) the containing division */
_destroyPlugin: function(target) {
target = $(target);
if (!target.hasClass(this.markerClassName)) {
return;
}
this._removeTarget(target[0]);
target.removeClass(this.markerClassName).empty().removeData(this.propertyName);
},
/* Pause a countdown widget at the current time.
Stop it running but remember and display the current time.
@param target (element) the containing division */
_pausePlugin: function(target) {
this._hold(target, 'pause');
},
/* Pause a countdown widget at the current time.
Stop the display but keep the countdown running.
@param target (element) the containing division */
_lapPlugin: function(target) {
this._hold(target, 'lap');
},
/* Resume a paused countdown widget.
@param target (element) the containing division */
_resumePlugin: function(target) {
this._hold(target, null);
},
/* Pause or resume a countdown widget.
@param target (element) the containing division
@param hold (string) the new hold setting */
_hold: function(target, hold) {
var inst = $.data(target, this.propertyName);
if (inst) {
if (inst._hold == 'pause' && !hold) {
inst._periods = inst._savePeriods;
var sign = (inst._since ? '-' : '+');
inst[inst._since ? '_since' : '_until'] =
this._determineTime(sign + inst._periods[0] + 'y' +
sign + inst._periods[1] + 'o' + sign + inst._periods[2] + 'w' +
sign + inst._periods[3] + 'd' + sign + inst._periods[4] + 'h' +
sign + inst._periods[5] + 'm' + sign + inst._periods[6] + 's');
this._addTarget(target);
}
inst._hold = hold;
inst._savePeriods = (hold == 'pause' ? inst._periods : null);
$.data(target, this.propertyName, inst);
this._updateCountdown(target, inst);
}
},
/* Return the current time periods.
@param target (element) the containing division
@return (number[7]) the current periods for the countdown */
_getTimesPlugin: function(target) {
var inst = $.data(target, this.propertyName);
return (!inst ? null : (inst._hold == 'pause' ? inst._savePeriods : (!inst._hold ? inst._periods :
this._calculatePeriods(inst, inst._show, inst.options.significant, new Date()))));
},
/* A time may be specified as an exact value or a relative one.
@param setting (string or number or Date) - the date/time value
as a relative or absolute value
@param defaultTime (Date) the date/time to use if no other is supplied
@return (Date) the corresponding date/time */
_determineTime: function(setting, defaultTime) {
var offsetNumeric = function(offset) { // e.g. +300, -2
var time = new Date();
time.setTime(time.getTime() + offset * 1000);
return time;
};
var offsetString = function(offset) { // e.g. '+2d', '-4w', '+3h +30m'
offset = offset.toLowerCase();
var time = new Date();
var year = time.getFullYear();
var month = time.getMonth();
var day = time.getDate();
var hour = time.getHours();
var minute = time.getMinutes();
var second = time.getSeconds();
var pattern = /([+-]?[0-9]+)\s*(s|m|h|d|w|o|y)?/g;
var matches = pattern.exec(offset);
while (matches) {
switch (matches[2] || 's') {
case 's': second += parseInt(matches[1], 10); break;
case 'm': minute += parseInt(matches[1], 10); break;
case 'h': hour += parseInt(matches[1], 10); break;
case 'd': day += parseInt(matches[1], 10); break;
case 'w': day += parseInt(matches[1], 10) * 7; break;
case 'o':
month += parseInt(matches[1], 10);
day = Math.min(day, plugin._getDaysInMonth(year, month));
break;
case 'y':
year += parseInt(matches[1], 10);
day = Math.min(day, plugin._getDaysInMonth(year, month));
break;
}
matches = pattern.exec(offset);
}
return new Date(year, month, day, hour, minute, second, 0);
};
var time = (setting == null ? defaultTime :
(typeof setting == 'string' ? offsetString(setting) :
(typeof setting == 'number' ? offsetNumeric(setting) : setting)));
if (time) time.setMilliseconds(0);
return time;
},
/* Determine the number of days in a month.
@param year (number) the year
@param month (number) the month
@return (number) the days in that month */
_getDaysInMonth: function(year, month) {
return 32 - new Date(year, month, 32).getDate();
},
/* Determine which set of labels should be used for an amount.
@param num (number) the amount to be displayed
@return (number) the set of labels to be used for this amount */
_normalLabels: function(num) {
return num;
},
/* Generate the HTML to display the countdown widget.
@param inst (object) the current settings for this instance
@return (string) the new HTML for the countdown display */
_generateHTML: function(inst) {
var self = this;
// Determine what to show
inst._periods = (inst._hold ? inst._periods :
this._calculatePeriods(inst, inst._show, inst.options.significant, new Date()));
// Show all 'asNeeded' after first non-zero value
var shownNonZero = false;
var showCount = 0;
var sigCount = inst.options.significant;
var show = $.extend({}, inst._show);
for (var period = Y; period <= S; period++) {
shownNonZero |= (inst._show[period] == '?' && inst._periods[period] > 0);
show[period] = (inst._show[period] == '?' && !shownNonZero ? null : inst._show[period]);
showCount += (show[period] ? 1 : 0);
sigCount -= (inst._periods[period] > 0 ? 1 : 0);
}
var showSignificant = [false, false, false, false, false, false, false];
for (var period = S; period >= Y; period--) { // Determine significant periods
if (inst._show[period]) {
if (inst._periods[period]) {
showSignificant[period] = true;
}
else {
showSignificant[period] = sigCount > 0;
sigCount--;
}
}
}
var labels = (inst.options.compact ? inst.options.compactLabels : inst.options.labels);
var whichLabels = inst.options.whichLabels || this._normalLabels;
var showCompact = function(period) {
var labelsNum = inst.options['compactLabels' + whichLabels(inst._periods[period])];
return (show[period] ? self._translateDigits(inst, inst._periods[period]) +
(labelsNum ? labelsNum[period] : labels[period]) + ' ' : '');
};
var showFull = function(period) {
var labelsNum = inst.options['labels' + whichLabels(inst._periods[period])];
return ((!inst.options.significant && show[period]) ||
(inst.options.significant && showSignificant[period]) ?
'<span class="' + plugin._sectionClass + '">' +
'<span class="' + plugin._amountClass + '">' +
self._translateDigits(inst, inst._periods[period]) + '</span><br/>' +
(labelsNum ? labelsNum[period] : labels[period]) + '</span>' : '');
};
return (inst.options.layout ? this._buildLayout(inst, show, inst.options.layout,
inst.options.compact, inst.options.significant, showSignificant) :
((inst.options.compact ? // Compact version
'<span class="' + this._rowClass + ' ' + this._amountClass +
(inst._hold ? ' ' + this._holdingClass : '') + '">' +
showCompact(Y) + showCompact(O) + showCompact(W) + showCompact(D) +
(show[H] ? this._minDigits(inst, inst._periods[H], 2) : '') +
(show[M] ? (show[H] ? inst.options.timeSeparator : '') +
this._minDigits(inst, inst._periods[M], 2) : '') +
(show[S] ? (show[H] || show[M] ? inst.options.timeSeparator : '') +
this._minDigits(inst, inst._periods[S], 2) : '') :
// Full version
'<span class="' + this._rowClass + ' ' + this._showClass + (inst.options.significant || showCount) +
(inst._hold ? ' ' + this._holdingClass : '') + '">' +
showFull(Y) + showFull(O) + showFull(W) + showFull(D) +
showFull(H) + showFull(M) + showFull(S)) + '</span>' +
(inst.options.description ? '<span class="' + this._rowClass + ' ' + this._descrClass + '">' +
inst.options.description + '</span>' : '')));
},
/* Construct a custom layout.
@param inst (object) the current settings for this instance
@param show (string[7]) flags indicating which periods are requested
@param layout (string) the customised layout
@param compact (boolean) true if using compact labels
@param significant (number) the number of periods with values to show, zero for all
@param showSignificant (boolean[7]) other periods to show for significance
@return (string) the custom HTML */
_buildLayout: function(inst, show, layout, compact, significant, showSignificant) {
var labels = inst.options[compact ? 'compactLabels' : 'labels'];
var whichLabels = inst.options.whichLabels || this._normalLabels;
var labelFor = function(index) {
return (inst.options[(compact ? 'compactLabels' : 'labels') +
whichLabels(inst._periods[index])] || labels)[index];
};
var digit = function(value, position) {
return inst.options.digits[Math.floor(value / position) % 10];
};
var subs = {desc: inst.options.description, sep: inst.options.timeSeparator,
yl: labelFor(Y), yn: this._minDigits(inst, inst._periods[Y], 1),
ynn: this._minDigits(inst, inst._periods[Y], 2),
ynnn: this._minDigits(inst, inst._periods[Y], 3), y1: digit(inst._periods[Y], 1),
y10: digit(inst._periods[Y], 10), y100: digit(inst._periods[Y], 100),
y1000: digit(inst._periods[Y], 1000),
ol: labelFor(O), on: this._minDigits(inst, inst._periods[O], 1),
onn: this._minDigits(inst, inst._periods[O], 2),
onnn: this._minDigits(inst, inst._periods[O], 3), o1: digit(inst._periods[O], 1),
o10: digit(inst._periods[O], 10), o100: digit(inst._periods[O], 100),
o1000: digit(inst._periods[O], 1000),
wl: labelFor(W), wn: this._minDigits(inst, inst._periods[W], 1),
wnn: this._minDigits(inst, inst._periods[W], 2),
wnnn: this._minDigits(inst, inst._periods[W], 3), w1: digit(inst._periods[W], 1),
w10: digit(inst._periods[W], 10), w100: digit(inst._periods[W], 100),
w1000: digit(inst._periods[W], 1000),
dl: labelFor(D), dn: this._minDigits(inst, inst._periods[D], 1),
dnn: this._minDigits(inst, inst._periods[D], 2),
dnnn: this._minDigits(inst, inst._periods[D], 3), d1: digit(inst._periods[D], 1),
d10: digit(inst._periods[D], 10), d100: digit(inst._periods[D], 100),
d1000: digit(inst._periods[D], 1000),
hl: labelFor(H), hn: this._minDigits(inst, inst._periods[H], 1),
hnn: this._minDigits(inst, inst._periods[H], 2),
hnnn: this._minDigits(inst, inst._periods[H], 3), h1: digit(inst._periods[H], 1),
h10: digit(inst._periods[H], 10), h100: digit(inst._periods[H], 100),
h1000: digit(inst._periods[H], 1000),
ml: labelFor(M), mn: this._minDigits(inst, inst._periods[M], 1),
mnn: this._minDigits(inst, inst._periods[M], 2),
mnnn: this._minDigits(inst, inst._periods[M], 3), m1: digit(inst._periods[M], 1),
m10: digit(inst._periods[M], 10), m100: digit(inst._periods[M], 100),
m1000: digit(inst._periods[M], 1000),
sl: labelFor(S), sn: this._minDigits(inst, inst._periods[S], 1),
snn: this._minDigits(inst, inst._periods[S], 2),
snnn: this._minDigits(inst, inst._periods[S], 3), s1: digit(inst._periods[S], 1),
s10: digit(inst._periods[S], 10), s100: digit(inst._periods[S], 100),
s1000: digit(inst._periods[S], 1000)};
var html = layout;
// Replace period containers: {p<}...{p>}
for (var i = Y; i <= S; i++) {
var period = 'yowdhms'.charAt(i);
var re = new RegExp('\\{' + period + '<\\}([\\s\\S]*)\\{' + period + '>\\}', 'g');
html = html.replace(re, ((!significant && show[i]) ||
(significant && showSignificant[i]) ? '$1' : ''));
}
// Replace period values: {pn}
$.each(subs, function(n, v) {
var re = new RegExp('\\{' + n + '\\}', 'g');
html = html.replace(re, v);
});
return html;
},
/* Ensure a numeric value has at least n digits for display.
@param inst (object) the current settings for this instance
@param value (number) the value to display
@param len (number) the minimum length
@return (string) the display text */
_minDigits: function(inst, value, len) {
value = '' + value;
if (value.length >= len) {
return this._translateDigits(inst, value);
}
value = '0000000000' + value;
return this._translateDigits(inst, value.substr(value.length - len));
},
/* Translate digits into other representations.
@param inst (object) the current settings for this instance
@param value (string) the text to translate
@return (string) the translated text */
_translateDigits: function(inst, value) {
return ('' + value).replace(/[0-9]/g, function(digit) {
return inst.options.digits[digit];
});
},
/* Translate the format into flags for each period.
@param inst (object) the current settings for this instance
@return (string[7]) flags indicating which periods are requested (?) or
required (!) by year, month, week, day, hour, minute, second */
_determineShow: function(inst) {
var format = inst.options.format;
var show = [];
show[Y] = (format.match('y') ? '?' : (format.match('Y') ? '!' : null));
show[O] = (format.match('o') ? '?' : (format.match('O') ? '!' : null));
show[W] = (format.match('w') ? '?' : (format.match('W') ? '!' : null));
show[D] = (format.match('d') ? '?' : (format.match('D') ? '!' : null));
show[H] = (format.match('h') ? '?' : (format.match('H') ? '!' : null));
show[M] = (format.match('m') ? '?' : (format.match('M') ? '!' : null));
show[S] = (format.match('s') ? '?' : (format.match('S') ? '!' : null));
return show;
},
/* Calculate the requested periods between now and the target time.
@param inst (object) the current settings for this instance
@param show (string[7]) flags indicating which periods are requested/required
@param significant (number) the number of periods with values to show, zero for all
@param now (Date) the current date and time
@return (number[7]) the current time periods (always positive)
by year, month, week, day, hour, minute, second */
_calculatePeriods: function(inst, show, significant, now) {
// Find endpoints
inst._now = now;
inst._now.setMilliseconds(0);
var until = new Date(inst._now.getTime());
if (inst._since) {
if (now.getTime() < inst._since.getTime()) {
inst._now = now = until;
}
else {
now = inst._since;
}
}
else {
until.setTime(inst._until.getTime());
if (now.getTime() > inst._until.getTime()) {
inst._now = now = until;
}
}
// Calculate differences by period
var periods = [0, 0, 0, 0, 0, 0, 0];
if (show[Y] || show[O]) {
// Treat end of months as the same
var lastNow = plugin._getDaysInMonth(now.getFullYear(), now.getMonth());
var lastUntil = plugin._getDaysInMonth(until.getFullYear(), until.getMonth());
var sameDay = (until.getDate() == now.getDate() ||
(until.getDate() >= Math.min(lastNow, lastUntil) &&
now.getDate() >= Math.min(lastNow, lastUntil)));
var getSecs = function(date) {
return (date.getHours() * 60 + date.getMinutes()) * 60 + date.getSeconds();
};
var months = Math.max(0,
(until.getFullYear() - now.getFullYear()) * 12 + until.getMonth() - now.getMonth() +
((until.getDate() < now.getDate() && !sameDay) ||
(sameDay && getSecs(until) < getSecs(now)) ? -1 : 0));
periods[Y] = (show[Y] ? Math.floor(months / 12) : 0);
periods[O] = (show[O] ? months - periods[Y] * 12 : 0);
// Adjust for months difference and end of month if necessary
now = new Date(now.getTime());
var wasLastDay = (now.getDate() == lastNow);
var lastDay = plugin._getDaysInMonth(now.getFullYear() + periods[Y],
now.getMonth() + periods[O]);
if (now.getDate() > lastDay) {
now.setDate(lastDay);
}
now.setFullYear(now.getFullYear() + periods[Y]);
now.setMonth(now.getMonth() + periods[O]);
if (wasLastDay) {
now.setDate(lastDay);
}
}
var diff = Math.floor((until.getTime() - now.getTime()) / 1000);
var extractPeriod = function(period, numSecs) {
periods[period] = (show[period] ? Math.floor(diff / numSecs) : 0);
diff -= periods[period] * numSecs;
};
extractPeriod(W, 604800);
extractPeriod(D, 86400);
extractPeriod(H, 3600);
extractPeriod(M, 60);
extractPeriod(S, 1);
if (diff > 0 && !inst._since) { // Round up if left overs
var multiplier = [1, 12, 4.3482, 7, 24, 60, 60];
var lastShown = S;
var max = 1;
for (var period = S; period >= Y; period--) {
if (show[period]) {
if (periods[lastShown] >= max) {
periods[lastShown] = 0;
diff = 1;
}
if (diff > 0) {
periods[period]++;
diff = 0;
lastShown = period;
max = 1;
}
}
max *= multiplier[period];
}
}
if (significant) { // Zero out insignificant periods
for (var period = Y; period <= S; period++) {
if (significant && periods[period]) {
significant--;
}
else if (!significant) {
periods[period] = 0;
}
}
}
return periods;
}
});
// The list of commands that return values and don't permit chaining
var getters = ['getTimes'];
/* Determine whether a command is a getter and doesn't permit chaining.
@param command (string, optional) the command to run
@param otherArgs ([], optional) any other arguments for the command
@return true if the command is a getter, false if not */
function isNotChained(command, otherArgs) {
if (command == 'option' && (otherArgs.length == 0 ||
(otherArgs.length == 1 && typeof otherArgs[0] == 'string'))) {
return true;
}
return $.inArray(command, getters) > -1;
}
/* Process the countdown functionality for a jQuery selection.
@param options (object) the new settings to use for these instances (optional) or
(string) the command to run (optional)
@return (jQuery) for chaining further calls or
(any) getter value */
$.fn.countdown = function(options) {
var otherArgs = Array.prototype.slice.call(arguments, 1);
if (isNotChained(options, otherArgs)) {
return plugin['_' + options + 'Plugin'].
apply(plugin, [this[0]].concat(otherArgs));
}
return this.each(function() {
if (typeof options == 'string') {
if (!plugin['_' + options + 'Plugin']) {
throw 'Unknown command: ' + options;
}
plugin['_' + options + 'Plugin'].
apply(plugin, [this].concat(otherArgs));
}
else {
plugin._attachPlugin(this, options || {});
}
});
};
/* Initialise the countdown functionality. */
var plugin = $.countdown = new Countdown(); // Singleton instance
})(jQuery);

File diff suppressed because one or more lines are too long