jQuery Countdown- unable to change the date

jQuery Countdown- unable to change the date

Hi, i downloaded this cool jquery countdown but when I try and change the counter I get errors or the counter disappears. The download even came with instructions embedded but I am unsure where to change the clock or if I am to change it in multiple places. I'm sure it's something I'm missing, any help would be great! It is so long....


(function($) { // Hide scope, no $ conflict

var pluginName = 'countdown';

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

/
@module Countdown
@augments JQPlugin
@example $(selector).countdown({until: +300}) */
$.JQPlugin.createPlugin({
/** The name of the plugin. */
name: pluginName,

/** Default settings for the plugin.
@property until {Date|number|string} The date/time to count down to, or number of seconds
offset from now, or string of amounts and units for offset(s) from now:
'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds.
@example until: new Date(2013, 12-1, 25, 13, 30)
 until: +300
 until: '+1O -2D'
  var secs = $.countdown.periodsToSeconds(periods);
  if (secs < 300) { // Last five minutes
...
  }
 }
@property [tickInterval=1] {number} The interval (seconds) between <code>onTick</code> callbacks. */
defaultOptions: {
until: null,
since: null,
timezone: null,
serverSync: null,
format: 'dHMS',
layout: '',
compact: false,
padZeroes: false,
significant: 0,
description: '',
expiryUrl: '',
expiryText: '',
alwaysExpire: false,
onExpiry: null,
onTick: null,
tickInterval: 1
},

},
/** Names of getter methods - those that can't be chained. */
_getters: ['getTimes'],

/* Class name for the right-to-left marker. */
_rtlClass: pluginName + '-rtl',
/* Class name for the countdown section marker. */
_sectionClass: pluginName + '-section',
/* Class name for the period amount marker. */
_amountClass: pluginName + '-amount',
/* Class name for the period name marker. */
_periodClass: pluginName + '-period',
/* Class name for the countdown row marker. */
_rowClass: pluginName + '-row',
/* Class name for the holding countdown marker. */
_holdingClass: pluginName + '-holding',
/* Class name for the showing countdown marker. */
_showClass: pluginName + '-show',
/* Class name for the description marker. */
_descrClass: pluginName + '-descr',

/* List of currently active countdown elements. */
_timerElems: [],

/** Additional setup for the countdown.
Apply default localisations.
Create the timer. */
_init: function() {
var self = this;
this._super();
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) {
self._updateElems();
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() { self._updateElems(); }, 980); // Fall back to good old setInterval
}
else {
animationStartTime = window.animationStartTime ||
window.webkitAnimationStartTime || window.mozAnimationStartTime ||
window.oAnimationStartTime || window.msAnimationStartTime || now();
requestAnimationFrame(timerCallBack);
}
},
/** Convert a date/time to UTC.
@param tz {number} The hour or minute offset from GMT, e.g. +9, -360.
@param year {Date|number} the date/time in that timezone or the year in that timezone.
@param [month] {number} The month (0 - 11) (omit if <code>year</code> is a <code>Date</code>).
@param [day] {number} The day (omit if <code>year</code> is a <code>Date</code>).
@param [hours] {number} The hour (omit if <code>year</code> is a <code>Date</code>).
@param [mins] {number} The minute (omit if <code>year</code> is a <code>Date</code>).
@param [secs] {number} The second (omit if <code>year</code> is a <code>Date</code>).
@param [ms] {number} The millisecond (omit if <code>year</code> is a <code>Date</code>).
@return {Date} The equivalent UTC date/time.
@example $.countdown.UTCDate(+10, 2013, 12-1, 25, 12, 0)
 $.countdown.UTCDate(-7, new Date(2013, 12-1, 25, 12, 0)) */
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[]} The periods per year/month/week/day/hour/minute/second.
@return {number} The corresponding number of seconds.
@example var secs = $.countdown.periodsToSeconds(periods) */
periodsToSeconds: function(periods) {
return periods[0] * 31557600 + periods[1] * 2629800 + periods[2] * 604800 +
periods[3] * 86400 + periods[4] * 3600 + periods[5] * 60 + periods[6];
},

_instSettings: function(elem, options) {
return {_periods: [0, 0, 0, 0, 0, 0, 0]};
},

/** Add an element to the list of active ones.
@private
@param elem {Element} The countdown element. */
_addElem: function(elem) {
if (!this._hasElem(elem)) {
this._timerElems.push(elem);
}
},

/** See if an element is in the list of active ones.
@private
@param elem {Element} The countdown element.
@return {boolean} True if present, false if not. */
_hasElem: function(elem) {
return ($.inArray(elem, this._timerElems) > -1);
},

/** Remove an element from the list of active ones.
@private
@param elem {Element} The countdown element. */
_removeElem: function(elem) {
this._timerElems = $.map(this._timerElems,
function(value) { return (value == elem ? null : value); }); // delete entry
},

/** Update each active timer element.
@private */
_updateElems: function() {
for (var i = this._timerElems.length - 1; i >= 0; i--) {
this._updateCountdown(this._timerElems[i]);
}
},

_optionsChanged: function(elem, inst, options) {
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(elem, inst,
options.until != null || options.since != null || timezoneChanged);
var now = new Date();
if ((inst._since && inst._since < now) || (inst._until && inst._until > now)) {
this._addElem(elem[0]);
}
this._updateCountdown(elem, inst);
},

        

/** Redisplay the countdown with an updated display.
@private
@param elem {Element|jQuery} The containing division.
@param inst {object} The current settings for this instance. */
_updateCountdown: function(elem, inst) {
elem = elem.jquery ? elem : $(elem);
inst = inst || elem.data(this.name);
if (!inst) {
return;
}
elem.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(elem[0], [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._hasElem(elem[0]) || inst.options.alwaysExpire) {
this._removeElem(elem[0]);
if ($.isFunction(inst.options.onExpiry)) {
inst.options.onExpiry.apply(elem[0], []);
}
if (inst.options.expiryText) {
var layout = inst.options.layout;
inst.options.layout = inst.options.expiryText;
this._updateCountdown(elem[0], inst);
inst.options.layout = layout;
}
if (inst.options.expiryUrl) {
window.location = inst.options.expiryUrl;
}
}
inst._expiring = false;
}
else if (inst._hold == 'pause') {
this._removeElem(elem[0]);
}
},

/** Reset any extra labelsn and compactLabelsn entries if changing labels.
@private
@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 internal settings for an instance.
@private
@param elem {jQuery} The containing division.
@param inst {object} The current settings for this instance.
@param recalc {boolean} True if until or since are set. */
_adjustSettings: function(elem, 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(elem[0], []) : 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 elem {jQuery} The containing division.
@param inst {object} The current instance object. */
_preDestroy: function(elem, inst) {
this._removeElem(elem[0]);
elem.empty();
},

/** Pause a countdown widget at the current time.
  Stop it running but remember and display the current time.
@param elem {Element} The containing division.
@example $(selector).countdown('pause') */
pause: function(elem) {
this._hold(elem, 'pause');
},

/** Pause a countdown widget at the current time.
  Stop the display but keep the countdown running.
@param elem {Element} The containing division.
@example $(selector).countdown('lap') */
lap: function(elem) {
this._hold(elem, 'lap');
},

/** Resume a paused countdown widget.
@param elem {Element} The containing division.
@example $(selector).countdown('resume') */
resume: function(elem) {
this._hold(elem, null);
},

/** Toggle a paused countdown widget.
@param elem {Element} The containing division.
@example $(selector).countdown('toggle') */
toggle: function(elem) {
var inst = $.data(elem, this.name) || {};
this[!inst._hold ? 'pause' : 'resume'](elem);
},

/** Toggle a lapped countdown widget.
@param elem {Element} The containing division.
@example $(selector).countdown('toggleLap') */
toggleLap: function(elem) {
var inst = $.data(elem, this.name) || {};
this[!inst._hold ? 'lap' : 'resume'](elem);
},

/** Pause or resume a countdown widget.
@private
@param elem {Element} The containing division.
@param hold {string} The new hold setting. */
_hold: function(elem, hold) {
var inst = $.data(elem, this.name);
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._addElem(elem);
}
inst._hold = hold;
inst._savePeriods = (hold == 'pause' ? inst._periods : null);
$.data(elem, this.name, inst);
this._updateCountdown(elem, inst);
}
},

});

})(jQuery);