Uji Countdown - Version 1.1

Version Description

  • Fix Chrome bug
Download this release

Release Info

Developer ujimoto
Plugin Icon 128x128 Uji Countdown
Version 1.1
Comparing to
See all releases

Code changes from version 1.0.9 to 1.1

images/ujic-ps3.png CHANGED
Binary file
js/jquery.countdown.dev.js DELETED
@@ -1,852 +0,0 @@
1
- /* http://keith-wood.name/countdown.html
2
- Countdown for jQuery v1.5.11.
3
- Written by Keith Wood (kbwood{at}iinet.com.au) January 2008.
4
- Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and
5
- MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses.
6
- Please attribute the author if you use it. */
7
-
8
- /* Display a countdown timer.
9
- Attach it with options like:
10
- $('div selector').countdown(
11
- {until: new Date(2009, 1 - 1, 1, 0, 0, 0), onExpiry: happyNewYear}); */
12
-
13
- (function($) { // Hide scope, no $ conflict
14
-
15
- /* Countdown manager. */
16
- function Countdown() {
17
- this.regional = []; // Available regional settings, indexed by language code
18
- this.regional[''] = { // Default regional settings
19
- // The display texts for the counters
20
- labels: ['Years', 'Months', 'Weeks', 'Days', 'Hours', 'Minutes', 'Seconds'],
21
- // The display texts for the counters if only one
22
- labels1: ['Year', 'Month', 'Week', 'Day', 'Hour', 'Minute', 'Second'],
23
- compactLabels: ['y', 'm', 'w', 'd'], // The compact texts for the counters
24
- whichLabels: null, // Function to determine which labels to use
25
- timeSeparator: ':', // Separator for time periods
26
- isRTL: false // True for right-to-left languages, false for left-to-right
27
- };
28
- this._defaults = {
29
- text_size: '35',
30
- animate_sec: false,
31
- color_down : '#3A3A3A',
32
- color_up : '#635b63',
33
- color_txt : '#ffffff',
34
- color_sw : '#000000',
35
- ujic_txt : true,
36
- ujic_url : false,
37
- until: null, // new Date(year, mth - 1, day, hr, min, sec) - date/time to count down to
38
- // or numeric for seconds offset, or string for unit offset(s):
39
- // 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
40
- since: null, // new Date(year, mth - 1, day, hr, min, sec) - date/time to count up from
41
- // or numeric for seconds offset, or string for unit offset(s):
42
- // 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
43
- timezone: null, // The timezone (hours or minutes from GMT) for the target times,
44
- // or null for client local
45
- serverSync: null, // A function to retrieve the current server time for synchronisation
46
- format: 'dHMS', // Format for display - upper case for always, lower case only if non-zero,
47
- // 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
48
- layout: '', // Build your own layout for the countdown
49
- compact: false, // True to display in a compact format, false for an expanded one
50
- significant: 0, // The number of periods with values to show, zero for all
51
- description: '', // The description displayed for the countdown
52
- expiryUrl: '', // A URL to load upon expiry, replacing the current page
53
- expiryText: '', // Text to display upon expiry, replacing the countdown
54
- alwaysExpire: false, // True to trigger onExpiry even if never counted down
55
- onExpiry: null, // Callback when the countdown expires -
56
- // receives no parameters and 'this' is the containing division
57
- onTick: null, // Callback when the countdown is updated -
58
- // receives int[7] being the breakdown by period (based on format)
59
- // and 'this' is the containing division
60
- tickInterval: 1 // Interval (seconds) between onTick callbacks
61
- };
62
- $.extend(this._defaults, this.regional['']);
63
- this._serverSyncs = [];
64
- // Shared timer for all countdowns
65
- function timerCallBack(timestamp) {
66
- var drawStart = (timestamp || new Date().getTime());
67
- if (drawStart - animationStartTime >= 1000) {
68
- $.countdown._updateTargets();
69
- animationStartTime = drawStart;
70
- }
71
- requestAnimationFrame(timerCallBack);
72
- }
73
- var requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame ||
74
- window.mozRequestAnimationFrame || window.oRequestAnimationFrame ||
75
- window.msRequestAnimationFrame || null; // this is when we expect a fall-back to setInterval as it's much more fluid
76
- var animationStartTime = 0;
77
- if (!requestAnimationFrame) {
78
- setInterval(function() { $.countdown._updateTargets(); }, 980); // Fall back to good old setInterval
79
- }
80
- else {
81
- animationStartTime = window.mozAnimationStartTime || new Date().getTime();
82
- requestAnimationFrame(timerCallBack);
83
- }
84
- }
85
-
86
- var PROP_NAME = 'countdown';
87
-
88
- var Y = 0; // Years
89
- var O = 1; // Months
90
- var W = 2; // Weeks
91
- var D = 3; // Days
92
- var H = 4; // Hours
93
- var M = 5; // Minutes
94
- var S = 6; // Seconds
95
-
96
- $.extend(Countdown.prototype, {
97
- /* Class name added to elements to indicate already configured with countdown. */
98
- markerClassName: 'hasCountdown',
99
-
100
- /* List of currently active countdown targets. */
101
- _timerTargets: [],
102
-
103
- /* Override the default settings for all instances of the countdown widget.
104
- @param options (object) the new settings to use as defaults */
105
- setDefaults: function(options) {
106
- this._resetExtraLabels(this._defaults, options);
107
- extendRemove(this._defaults, options || {});
108
- },
109
-
110
- /* Convert a date/time to UTC.
111
- @param tz (number) the hour or minute offset from GMT, e.g. +9, -360
112
- @param year (Date) the date/time in that timezone or
113
- (number) the year in that timezone
114
- @param month (number, optional) the month (0 - 11) (omit if year is a Date)
115
- @param day (number, optional) the day (omit if year is a Date)
116
- @param hours (number, optional) the hour (omit if year is a Date)
117
- @param mins (number, optional) the minute (omit if year is a Date)
118
- @param secs (number, optional) the second (omit if year is a Date)
119
- @param ms (number, optional) the millisecond (omit if year is a Date)
120
- @return (Date) the equivalent UTC date/time */
121
- UTCDate: function(tz, year, month, day, hours, mins, secs, ms) {
122
- if (typeof year == 'object' && year.constructor == Date) {
123
- ms = year.getMilliseconds();
124
- secs = year.getSeconds();
125
- mins = year.getMinutes();
126
- hours = year.getHours();
127
- day = year.getDate();
128
- month = year.getMonth();
129
- year = year.getFullYear();
130
- }
131
- var d = new Date();
132
- d.setUTCFullYear(year);
133
- d.setUTCDate(1);
134
- d.setUTCMonth(month || 0);
135
- d.setUTCDate(day || 1);
136
- d.setUTCHours(hours || 0);
137
- d.setUTCMinutes((mins || 0) - (Math.abs(tz) < 30 ? tz * 60 : tz));
138
- d.setUTCSeconds(secs || 0);
139
- d.setUTCMilliseconds(ms || 0);
140
- return d;
141
- },
142
-
143
- /* Convert a set of periods into seconds.
144
- Averaged for months and years.
145
- @param periods (number[7]) the periods per year/month/week/day/hour/minute/second
146
- @return (number) the corresponding number of seconds */
147
- periodsToSeconds: function(periods) {
148
- return periods[0] * 31557600 + periods[1] * 2629800 + periods[2] * 604800 +
149
- periods[3] * 86400 + periods[4] * 3600 + periods[5] * 60 + periods[6];
150
- },
151
-
152
- /* Retrieve one or more settings values.
153
- @param name (string, optional) the name of the setting to retrieve
154
- or 'all' for all instance settings or omit for all default settings
155
- @return (any) the requested setting(s) */
156
- _settingsCountdown: function(target, name) {
157
- if (!name) {
158
- return $.countdown._defaults;
159
- }
160
- var inst = $.data(target, PROP_NAME);
161
- return (name == 'all' ? inst.options : inst.options[name]);
162
- },
163
-
164
- /* Attach the countdown widget to a div.
165
- @param target (element) the containing division
166
- @param options (object) the initial settings for the countdown */
167
- _attachCountdown: function(target, options) {
168
- var $target = $(target);
169
- if ($target.hasClass(this.markerClassName)) {
170
- return;
171
- }
172
- $target.addClass(this.markerClassName);
173
- var inst = {options: $.extend({}, options),
174
- _periods: [0, 0, 0, 0, 0, 0, 0]};
175
- $.data(target, PROP_NAME, inst);
176
- this._changeCountdown(target);
177
- },
178
-
179
- /* Add a target to the list of active ones.
180
- @param target (element) the countdown target */
181
- _addTarget: function(target) {
182
- if (!this._hasTarget(target)) {
183
- this._timerTargets.push(target);
184
- }
185
- },
186
-
187
- /* See if a target is in the list of active ones.
188
- @param target (element) the countdown target
189
- @return (boolean) true if present, false if not */
190
- _hasTarget: function(target) {
191
- return ($.inArray(target, this._timerTargets) > -1);
192
- },
193
-
194
- /* Remove a target from the list of active ones.
195
- @param target (element) the countdown target */
196
- _removeTarget: function(target) {
197
- this._timerTargets = $.map(this._timerTargets,
198
- function(value) { return (value == target ? null : value); }); // delete entry
199
- },
200
-
201
- /* Update each active timer target. */
202
- _updateTargets: function() {
203
- for (var i = this._timerTargets.length - 1; i >= 0; i--) {
204
- this._updateCountdown(this._timerTargets[i]);
205
- }
206
- },
207
-
208
- /* Redisplay the countdown with an updated display.
209
- @param target (jQuery) the containing division
210
- @param inst (object) the current settings for this instance */
211
- _updateCountdown: function(target, inst) {
212
- var $target = $(target);
213
- inst = inst || $.data(target, PROP_NAME);
214
- if (!inst) {
215
- return;
216
- }
217
- $target.html(this._generateHTML(inst));
218
- //ujimoto
219
-
220
- var ujic_url = this._get(inst, 'ujic_url');
221
- var ujic_until = this._get(inst, 'until');
222
- var foo = new Date; // Generic JS date object
223
- var unixtime = parseInt(foo.getTime() / 1000);
224
- var until_time = parseInt(ujic_until.getTime() / 1000)-2;
225
- /*delay 2 seconds for run process*/
226
-
227
- if(ujic_url && (unixtime>until_time)){
228
- window.location.replace(ujic_url);
229
-
230
- }
231
-
232
- var color_down = this._get(inst, 'color_down');
233
- var color_up = this._get(inst, 'color_up');
234
- jQuery( '.countdown_amount').css("background-image", "linear-gradient(bottom, "+color_down+" 50%, "+color_up+" 50%)");
235
- jQuery( '.countdown_amount').css("background-image", "-o-linear-gradient(bottom, "+color_down+" 50%, "+color_up+" 50%)");
236
- jQuery( '.countdown_amount').css("background-image", "-moz-linear-gradient(bottom, "+color_down+" 50%, "+color_up+" 50%)");
237
- jQuery( '.countdown_amount').css("background-image", "-webkit-linear-gradient(bottom, "+color_down+" 50%, "+color_up+" 50%)");
238
- jQuery( '.countdown_amount').css("background-image", "-ms-linear-gradient(bottom, "+color_down+" 50%, "+color_up+" 50%)");
239
- jQuery( '.countdown_amount').css("filter", "progid:DXImageTransform.Microsoft.Gradient(startColorstr='"+color_down+"', endColorstr='"+color_up+"')");
240
-
241
- var color_txt = this._get(inst, 'color_txt');
242
- var color_sw = this._get(inst, 'color_sw');
243
- jQuery( '.countdown_amount').css("color", color_txt);
244
- jQuery( '.countdown_amount').css("text-shadow",'1px 1px 1px ' + color_sw);
245
-
246
-
247
- var ujic_txt = this._get(inst, 'ujic_txt');
248
- if(ujic_txt){
249
- jQuery('.countdown_txt').css("display","block");
250
- }else{
251
- jQuery('.countdown_txt').css("display","none");
252
- }
253
-
254
- var text_size = this._get(inst, 'text_size');
255
- jQuery( '.countdown_amount').css("font", text_size+"px/1.5 'Open Sans Condensed',sans-serif");
256
-
257
- var animate_sec = this._get(inst, 'animate_sec');
258
- if(animate_sec){
259
- var wsec = $("#uji_sec").find('.countdown_section').width();
260
- $("#uji_sec").find('.countdown_section').css({"width": wsec+"px"});
261
- $("#uji_sec").find('.countdown_amount').eq(1).css({"top": "-74px", "right": "0px", "position": "absolute", opacity:1});
262
- $("#uji_sec").find('.countdown_amount').eq(1).animate({"top": "0px", "right": "0px", opacity:1},700,function(){
263
- // Animation complete.
264
- // $("#uji_sec").find('.countdown_amount').eq(1).animate({ opacity:1}, 500);
265
- $("#uji_sec").find('.countdown_amount').eq(1).animate({opacity:0}, 300);
266
- });
267
- }
268
- //ujimoto
269
- $target[(this._get(inst, 'isRTL') ? 'add' : 'remove') + 'Class']('countdown_rtl');
270
- var onTick = this._get(inst, 'onTick');
271
- if (onTick) {
272
- var periods = inst._hold != 'lap' ? inst._periods :
273
- this._calculatePeriods(inst, inst._show, this._get(inst, 'significant'), new Date());
274
- var tickInterval = this._get(inst, 'tickInterval');
275
- if (tickInterval == 1 || this.periodsToSeconds(periods) % tickInterval == 0) {
276
- onTick.apply(target, [periods]);
277
- }
278
- }
279
- var expired = inst._hold != 'pause' &&
280
- (inst._since ? inst._now.getTime() < inst._since.getTime() :
281
- inst._now.getTime() >= inst._until.getTime());
282
- if (expired && !inst._expiring) {
283
- inst._expiring = true;
284
- if (this._hasTarget(target) || this._get(inst, 'alwaysExpire')) {
285
- this._removeTarget(target);
286
- var onExpiry = this._get(inst, 'onExpiry');
287
- if (onExpiry) {
288
- onExpiry.apply(target, []);
289
- }
290
- var expiryText = this._get(inst, 'expiryText');
291
- if (expiryText) {
292
- var layout = this._get(inst, 'layout');
293
- inst.options.layout = expiryText;
294
- this._updateCountdown(target, inst);
295
- inst.options.layout = layout;
296
- }
297
- var expiryUrl = this._get(inst, 'expiryUrl');
298
- if (expiryUrl) {
299
- window.location = expiryUrl;
300
- }
301
- }
302
- inst._expiring = false;
303
- }
304
- else if (inst._hold == 'pause') {
305
- this._removeTarget(target);
306
- }
307
- $.data(target, PROP_NAME, inst);
308
- },
309
-
310
- /* Reconfigure the settings for a countdown div.
311
- @param target (element) the containing division
312
- @param options (object) the new settings for the countdown or
313
- (string) an individual property name
314
- @param value (any) the individual property value
315
- (omit if options is an object) */
316
- _changeCountdown: function(target, options, value) {
317
- options = options || {};
318
- if (typeof options == 'string') {
319
- var name = options;
320
- options = {};
321
- options[name] = value;
322
- }
323
- var inst = $.data(target, PROP_NAME);
324
- if (inst) {
325
- this._resetExtraLabels(inst.options, options);
326
- extendRemove(inst.options, options);
327
- this._adjustSettings(target, inst);
328
- $.data(target, PROP_NAME, inst);
329
- var now = new Date();
330
- if ((inst._since && inst._since < now) ||
331
- (inst._until && inst._until > now)) {
332
- this._addTarget(target);
333
- }
334
- this._updateCountdown(target, inst);
335
- }
336
- },
337
-
338
- /* Reset any extra labelsn and compactLabelsn entries if changing labels.
339
- @param base (object) the options to be updated
340
- @param options (object) the new option values */
341
- _resetExtraLabels: function(base, options) {
342
- var changingLabels = false;
343
- for (var n in options) {
344
- if (n != 'whichLabels' && n.match(/[Ll]abels/)) {
345
- changingLabels = true;
346
- break;
347
- }
348
- }
349
- if (changingLabels) {
350
- for (var n in base) { // Remove custom numbered labels
351
- if (n.match(/[Ll]abels[0-9]/)) {
352
- base[n] = null;
353
- }
354
- }
355
- }
356
- },
357
-
358
- /* Calculate interal settings for an instance.
359
- @param target (element) the containing division
360
- @param inst (object) the current settings for this instance */
361
- _adjustSettings: function(target, inst) {
362
- var now;
363
- var serverSync = this._get(inst, 'serverSync');
364
- var serverOffset = 0;
365
- var serverEntry = null;
366
- for (var i = 0; i < this._serverSyncs.length; i++) {
367
- if (this._serverSyncs[i][0] == serverSync) {
368
- serverEntry = this._serverSyncs[i][1];
369
- break;
370
- }
371
- }
372
- if (serverEntry != null) {
373
- serverOffset = (serverSync ? serverEntry : 0);
374
- now = new Date();
375
- }
376
- else {
377
- var serverResult = (serverSync ? serverSync.apply(target, []) : null);
378
- now = new Date();
379
- serverOffset = (serverResult ? now.getTime() - serverResult.getTime() : 0);
380
- this._serverSyncs.push([serverSync, serverOffset]);
381
- }
382
- var timezone = this._get(inst, 'timezone');
383
- timezone = (timezone == null ? -now.getTimezoneOffset() : timezone);
384
- inst._since = this._get(inst, 'since');
385
- if (inst._since != null) {
386
- inst._since = this.UTCDate(timezone, this._determineTime(inst._since, null));
387
- if (inst._since && serverOffset) {
388
- inst._since.setMilliseconds(inst._since.getMilliseconds() + serverOffset);
389
- }
390
- }
391
- inst._until = this.UTCDate(timezone, this._determineTime(this._get(inst, 'until'), now));
392
- if (serverOffset) {
393
- inst._until.setMilliseconds(inst._until.getMilliseconds() + serverOffset);
394
- }
395
- inst._show = this._determineShow(inst);
396
- },
397
-
398
- /* Remove the countdown widget from a div.
399
- @param target (element) the containing division */
400
- _destroyCountdown: function(target) {
401
- var $target = $(target);
402
- if (!$target.hasClass(this.markerClassName)) {
403
- return;
404
- }
405
- this._removeTarget(target);
406
- $target.removeClass(this.markerClassName).empty();
407
- $.removeData(target, PROP_NAME);
408
- },
409
-
410
- /* Pause a countdown widget at the current time.
411
- Stop it running but remember and display the current time.
412
- @param target (element) the containing division */
413
- _pauseCountdown: function(target) {
414
- this._hold(target, 'pause');
415
- },
416
-
417
- /* Pause a countdown widget at the current time.
418
- Stop the display but keep the countdown running.
419
- @param target (element) the containing division */
420
- _lapCountdown: function(target) {
421
- this._hold(target, 'lap');
422
- },
423
-
424
- /* Resume a paused countdown widget.
425
- @param target (element) the containing division */
426
- _resumeCountdown: function(target) {
427
- this._hold(target, null);
428
- },
429
-
430
- /* Pause or resume a countdown widget.
431
- @param target (element) the containing division
432
- @param hold (string) the new hold setting */
433
- _hold: function(target, hold) {
434
- var inst = $.data(target, PROP_NAME);
435
- if (inst) {
436
- if (inst._hold == 'pause' && !hold) {
437
- inst._periods = inst._savePeriods;
438
- var sign = (inst._since ? '-' : '+');
439
- inst[inst._since ? '_since' : '_until'] =
440
- this._determineTime(sign + inst._periods[0] + 'y' +
441
- sign + inst._periods[1] + 'o' + sign + inst._periods[2] + 'w' +
442
- sign + inst._periods[3] + 'd' + sign + inst._periods[4] + 'h' +
443
- sign + inst._periods[5] + 'm' + sign + inst._periods[6] + 's');
444
- this._addTarget(target);
445
- }
446
- inst._hold = hold;
447
- inst._savePeriods = (hold == 'pause' ? inst._periods : null);
448
- $.data(target, PROP_NAME, inst);
449
- this._updateCountdown(target, inst);
450
- }
451
- },
452
-
453
- /* Return the current time periods.
454
- @param target (element) the containing division
455
- @return (number[7]) the current periods for the countdown */
456
- _getTimesCountdown: function(target) {
457
- var inst = $.data(target, PROP_NAME);
458
- return (!inst ? null : (!inst._hold ? inst._periods :
459
- this._calculatePeriods(inst, inst._show, this._get(inst, 'significant'), new Date())));
460
- },
461
-
462
- /* Get a setting value, defaulting if necessary.
463
- @param inst (object) the current settings for this instance
464
- @param name (string) the name of the required setting
465
- @return (any) the setting's value or a default if not overridden */
466
- _get: function(inst, name) {
467
- return (inst.options[name] != null ?
468
- inst.options[name] : $.countdown._defaults[name]);
469
- },
470
-
471
- /* A time may be specified as an exact value or a relative one.
472
- @param setting (string or number or Date) - the date/time value
473
- as a relative or absolute value
474
- @param defaultTime (Date) the date/time to use if no other is supplied
475
- @return (Date) the corresponding date/time */
476
- _determineTime: function(setting, defaultTime) {
477
- var offsetNumeric = function(offset) { // e.g. +300, -2
478
- var time = new Date();
479
- time.setTime(time.getTime() + offset * 1000);
480
- return time;
481
- };
482
- var offsetString = function(offset) { // e.g. '+2d', '-4w', '+3h +30m'
483
- offset = offset.toLowerCase();
484
- var time = new Date();
485
- var year = time.getFullYear();
486
- var month = time.getMonth();
487
- var day = time.getDate();
488
- var hour = time.getHours();
489
- var minute = time.getMinutes();
490
- var second = time.getSeconds();
491
- var pattern = /([+-]?[0-9]+)\s*(s|m|h|d|w|o|y)?/g;
492
- var matches = pattern.exec(offset);
493
- while (matches) {
494
- switch (matches[2] || 's') {
495
- case 's': second += parseInt(matches[1], 10); break;
496
- case 'm': minute += parseInt(matches[1], 10); break;
497
- case 'h': hour += parseInt(matches[1], 10); break;
498
- case 'd': day += parseInt(matches[1], 10); break;
499
- case 'w': day += parseInt(matches[1], 10) * 7; break;
500
- case 'o':
501
- month += parseInt(matches[1], 10);
502
- day = Math.min(day, $.countdown._getDaysInMonth(year, month));
503
- break;
504
- case 'y':
505
- year += parseInt(matches[1], 10);
506
- day = Math.min(day, $.countdown._getDaysInMonth(year, month));
507
- break;
508
- }
509
- matches = pattern.exec(offset);
510
- }
511
- return new Date(year, month, day, hour, minute, second, 0);
512
- };
513
- var time = (setting == null ? defaultTime :
514
- (typeof setting == 'string' ? offsetString(setting) :
515
- (typeof setting == 'number' ? offsetNumeric(setting) : setting)));
516
- if (time) time.setMilliseconds(0);
517
- return time;
518
- },
519
-
520
- /* Determine the number of days in a month.
521
- @param year (number) the year
522
- @param month (number) the month
523
- @return (number) the days in that month */
524
- _getDaysInMonth: function(year, month) {
525
- return 32 - new Date(year, month, 32).getDate();
526
- },
527
-
528
- /* Determine which set of labels should be used for an amount.
529
- @param num (number) the amount to be displayed
530
- @return (number) the set of labels to be used for this amount */
531
- _normalLabels: function(num) {
532
- return num;
533
- },
534
-
535
- /* Generate the HTML to display the countdown widget.
536
- @param inst (object) the current settings for this instance
537
- @return (string) the new HTML for the countdown display */
538
- _generateHTML: function(inst) {
539
- // Determine what to show
540
- var significant = this._get(inst, 'significant');
541
- inst._periods = (inst._hold ? inst._periods :
542
- this._calculatePeriods(inst, inst._show, significant, new Date()));
543
- // Show all 'asNeeded' after first non-zero value
544
- var shownNonZero = false;
545
- var showCount = 0;
546
- var sigCount = significant;
547
- var show = $.extend({}, inst._show);
548
- for (var period = Y; period <= S; period++) {
549
- shownNonZero |= (inst._show[period] == '?' && inst._periods[period] > 0);
550
- show[period] = (inst._show[period] == '?' && !shownNonZero ? null : inst._show[period]);
551
- showCount += (show[period] ? 1 : 0);
552
- sigCount -= (inst._periods[period] > 0 ? 1 : 0);
553
- }
554
- var showSignificant = [false, false, false, false, false, false, false];
555
- for (var period = S; period >= Y; period--) { // Determine significant periods
556
- if (inst._show[period]) {
557
- if (inst._periods[period]) {
558
- showSignificant[period] = true;
559
- }
560
- else {
561
- showSignificant[period] = sigCount > 0;
562
- sigCount--;
563
- }
564
- }
565
- }
566
- var compact = this._get(inst, 'compact');
567
- var layout = this._get(inst, 'layout');
568
- var labels = (compact ? this._get(inst, 'compactLabels') : this._get(inst, 'labels'));
569
- var whichLabels = this._get(inst, 'whichLabels') || this._normalLabels;
570
- var timeSeparator = this._get(inst, 'timeSeparator');
571
- var description = this._get(inst, 'description') || '';
572
- var showCompact = function(period) {
573
- var labelsNum = $.countdown._get(inst,
574
- 'compactLabels' + whichLabels(inst._periods[period]));
575
- return (show[period] ? inst._periods[period] +
576
- (labelsNum ? labelsNum[period] : labels[period]) + ' ' : '');
577
- };
578
- var showFull = function(period) {
579
- //ujimoto
580
- var labelsNum = $.countdown._get(inst, 'labels' + whichLabels(inst._periods[period]));
581
-
582
- if((!significant && show[period]) || (significant && showSignificant[period])){
583
- var ujinum ='';
584
- if(inst._periods[period].toString().length == 1){
585
- ujinum = '<span class="countdown_amount">' + 0+ '</span>' + '<span class="countdown_amount">' + inst._periods[period] + '</span>';
586
- } else{
587
- for (var i = 0; i < inst._periods[period].toString().length; i++) {
588
- ujinum += '<span class="countdown_amount">' + inst._periods[period].toString().charAt(i) + '</span>';
589
- }
590
- }
591
- return '<span class="countdown_section">' +
592
- ujinum + '<span class="countdown_txt">' +
593
- (labelsNum ? labelsNum[period] : labels[period]) + '</span></span>';
594
-
595
- }else {
596
- return '';
597
- }
598
- //ujimoto
599
- };
600
-
601
- return (layout ? this._buildLayout(inst, show, layout, compact, significant, showSignificant) :
602
- ((compact ? // Compact version
603
- '<span class="countdown_row countdown_amount' +
604
- (inst._hold ? ' countdown_holding' : '') + '">' +
605
- showCompact(Y) + showCompact(O) + showCompact(W) + showCompact(D) +
606
- (show[H] ? this._minDigits(inst._periods[H], 2) : '') +
607
- (show[M] ? (show[H] ? timeSeparator : '') +
608
- this._minDigits(inst._periods[M], 2) : '') +
609
- (show[S] ? (show[H] || show[M] ? timeSeparator : '') +
610
- this._minDigits(inst._periods[S], 2) : '') :
611
- // Full version
612
- '<span class="countdown_row countdown_show' + (significant || showCount) +
613
- (inst._hold ? ' countdown_holding' : '') + '">' +
614
- showFull(Y) + showFull(O) + showFull(W) + showFull(D) +
615
- showFull(H) + showFull(M) + '<span id="uji_sec">'+ showFull(S)) + '</span>' + '</span>' +
616
- (description ? '<span class="countdown_row countdown_descr">' + description + '</span>' : '')));
617
- },
618
-
619
- /* Construct a custom layout.
620
- @param inst (object) the current settings for this instance
621
- @param show (string[7]) flags indicating which periods are requested
622
- @param layout (string) the customised layout
623
- @param compact (boolean) true if using compact labels
624
- @param significant (number) the number of periods with values to show, zero for all
625
- @param showSignificant (boolean[7]) other periods to show for significance
626
- @return (string) the custom HTML */
627
- _buildLayout: function(inst, show, layout, compact, significant, showSignificant) {
628
- var labels = this._get(inst, (compact ? 'compactLabels' : 'labels'));
629
- var whichLabels = this._get(inst, 'whichLabels') || this._normalLabels;
630
- var labelFor = function(index) {
631
- return ($.countdown._get(inst,
632
- (compact ? 'compactLabels' : 'labels') + whichLabels(inst._periods[index])) ||
633
- labels)[index];
634
- };
635
- var digit = function(value, position) {
636
- return Math.floor(value / position) % 10;
637
- };
638
- var subs = {desc: this._get(inst, 'description'), sep: this._get(inst, 'timeSeparator'),
639
- yl: labelFor(Y), yn: inst._periods[Y], ynn: this._minDigits(inst._periods[Y], 2),
640
- ynnn: this._minDigits(inst._periods[Y], 3), y1: digit(inst._periods[Y], 1),
641
- y10: digit(inst._periods[Y], 10), y100: digit(inst._periods[Y], 100),
642
- y1000: digit(inst._periods[Y], 1000),
643
- ol: labelFor(O), on: inst._periods[O], onn: this._minDigits(inst._periods[O], 2),
644
- onnn: this._minDigits(inst._periods[O], 3), o1: digit(inst._periods[O], 1),
645
- o10: digit(inst._periods[O], 10), o100: digit(inst._periods[O], 100),
646
- o1000: digit(inst._periods[O], 1000),
647
- wl: labelFor(W), wn: inst._periods[W], wnn: this._minDigits(inst._periods[W], 2),
648
- wnnn: this._minDigits(inst._periods[W], 3), w1: digit(inst._periods[W], 1),
649
- w10: digit(inst._periods[W], 10), w100: digit(inst._periods[W], 100),
650
- w1000: digit(inst._periods[W], 1000),
651
- dl: labelFor(D), dn: inst._periods[D], dnn: this._minDigits(inst._periods[D], 2),
652
- dnnn: this._minDigits(inst._periods[D], 3), d1: digit(inst._periods[D], 1),
653
- d10: digit(inst._periods[D], 10), d100: digit(inst._periods[D], 100),
654
- d1000: digit(inst._periods[D], 1000),
655
- hl: labelFor(H), hn: inst._periods[H], hnn: this._minDigits(inst._periods[H], 2),
656
- hnnn: this._minDigits(inst._periods[H], 3), h1: digit(inst._periods[H], 1),
657
- h10: digit(inst._periods[H], 10), h100: digit(inst._periods[H], 100),
658
- h1000: digit(inst._periods[H], 1000),
659
- ml: labelFor(M), mn: inst._periods[M], mnn: this._minDigits(inst._periods[M], 2),
660
- mnnn: this._minDigits(inst._periods[M], 3), m1: digit(inst._periods[M], 1),
661
- m10: digit(inst._periods[M], 10), m100: digit(inst._periods[M], 100),
662
- m1000: digit(inst._periods[M], 1000),
663
- sl: labelFor(S), sn: inst._periods[S], snn: this._minDigits(inst._periods[S], 2),
664
- snnn: this._minDigits(inst._periods[S], 3), s1: digit(inst._periods[S], 1),
665
- s10: digit(inst._periods[S], 10), s100: digit(inst._periods[S], 100),
666
- s1000: digit(inst._periods[S], 1000)};
667
- var html = layout;
668
- // Replace period containers: {p<}...{p>}
669
- for (var i = Y; i <= S; i++) {
670
- var period = 'yowdhms'.charAt(i);
671
- var re = new RegExp('\\{' + period + '<\\}(.*)\\{' + period + '>\\}', 'g');
672
- html = html.replace(re, ((!significant && show[i]) ||
673
- (significant && showSignificant[i]) ? '$1' : ''));
674
- }
675
- // Replace period values: {pn}
676
- $.each(subs, function(n, v) {
677
- var re = new RegExp('\\{' + n + '\\}', 'g');
678
- html = html.replace(re, v);
679
- });
680
- return html;
681
- },
682
-
683
- /* Ensure a numeric value has at least n digits for display.
684
- @param value (number) the value to display
685
- @param len (number) the minimum length
686
- @return (string) the display text */
687
- _minDigits: function(value, len) {
688
- value = '' + value;
689
- if (value.length >= len) {
690
- return value;
691
- }
692
- value = '0000000000' + value;
693
- return value.substr(value.length - len);
694
- },
695
-
696
- /* Translate the format into flags for each period.
697
- @param inst (object) the current settings for this instance
698
- @return (string[7]) flags indicating which periods are requested (?) or
699
- required (!) by year, month, week, day, hour, minute, second */
700
- _determineShow: function(inst) {
701
- var format = this._get(inst, 'format');
702
- var show = [];
703
- show[Y] = (format.match('y') ? '?' : (format.match('Y') ? '!' : null));
704
- show[O] = (format.match('o') ? '?' : (format.match('O') ? '!' : null));
705
- show[W] = (format.match('w') ? '?' : (format.match('W') ? '!' : null));
706
- show[D] = (format.match('d') ? '?' : (format.match('D') ? '!' : null));
707
- show[H] = (format.match('h') ? '?' : (format.match('H') ? '!' : null));
708
- show[M] = (format.match('m') ? '?' : (format.match('M') ? '!' : null));
709
- show[S] = (format.match('s') ? '?' : (format.match('S') ? '!' : null));
710
- return show;
711
- },
712
-
713
- /* Calculate the requested periods between now and the target time.
714
- @param inst (object) the current settings for this instance
715
- @param show (string[7]) flags indicating which periods are requested/required
716
- @param significant (number) the number of periods with values to show, zero for all
717
- @param now (Date) the current date and time
718
- @return (number[7]) the current time periods (always positive)
719
- by year, month, week, day, hour, minute, second */
720
- _calculatePeriods: function(inst, show, significant, now) {
721
- // Find endpoints
722
- inst._now = now;
723
- inst._now.setMilliseconds(0);
724
- var until = new Date(inst._now.getTime());
725
- if (inst._since) {
726
- if (now.getTime() < inst._since.getTime()) {
727
- inst._now = now = until;
728
- }
729
- else {
730
- now = inst._since;
731
- }
732
- }
733
- else {
734
- until.setTime(inst._until.getTime());
735
- if (now.getTime() > inst._until.getTime()) {
736
- inst._now = now = until;
737
- }
738
- }
739
- // Calculate differences by period
740
- var periods = [0, 0, 0, 0, 0, 0, 0];
741
- if (show[Y] || show[O]) {
742
- // Treat end of months as the same
743
- var lastNow = $.countdown._getDaysInMonth(now.getFullYear(), now.getMonth());
744
- var lastUntil = $.countdown._getDaysInMonth(until.getFullYear(), until.getMonth());
745
- var sameDay = (until.getDate() == now.getDate() ||
746
- (until.getDate() >= Math.min(lastNow, lastUntil) &&
747
- now.getDate() >= Math.min(lastNow, lastUntil)));
748
- var getSecs = function(date) {
749
- return (date.getHours() * 60 + date.getMinutes()) * 60 + date.getSeconds();
750
- };
751
- var months = Math.max(0,
752
- (until.getFullYear() - now.getFullYear()) * 12 + until.getMonth() - now.getMonth() +
753
- ((until.getDate() < now.getDate() && !sameDay) ||
754
- (sameDay && getSecs(until) < getSecs(now)) ? -1 : 0));
755
- periods[Y] = (show[Y] ? Math.floor(months / 12) : 0);
756
- periods[O] = (show[O] ? months - periods[Y] * 12 : 0);
757
- // Adjust for months difference and end of month if necessary
758
- now = new Date(now.getTime());
759
- var wasLastDay = (now.getDate() == lastNow);
760
- var lastDay = $.countdown._getDaysInMonth(now.getFullYear() + periods[Y],
761
- now.getMonth() + periods[O]);
762
- if (now.getDate() > lastDay) {
763
- now.setDate(lastDay);
764
- }
765
- now.setFullYear(now.getFullYear() + periods[Y]);
766
- now.setMonth(now.getMonth() + periods[O]);
767
- if (wasLastDay) {
768
- now.setDate(lastDay);
769
- }
770
- }
771
- var diff = Math.floor((until.getTime() - now.getTime()) / 1000);
772
- var extractPeriod = function(period, numSecs) {
773
- periods[period] = (show[period] ? Math.floor(diff / numSecs) : 0);
774
- diff -= periods[period] * numSecs;
775
- };
776
- extractPeriod(W, 604800);
777
- extractPeriod(D, 86400);
778
- extractPeriod(H, 3600);
779
- extractPeriod(M, 60);
780
- extractPeriod(S, 1);
781
- if (diff > 0 && !inst._since) { // Round up if left overs
782
- var multiplier = [1, 12, 4.3482, 7, 24, 60, 60];
783
- var lastShown = S;
784
- var max = 1;
785
- for (var period = S; period >= Y; period--) {
786
- if (show[period]) {
787
- if (periods[lastShown] >= max) {
788
- periods[lastShown] = 0;
789
- diff = 1;
790
- }
791
- if (diff > 0) {
792
- periods[period]++;
793
- diff = 0;
794
- lastShown = period;
795
- max = 1;
796
- }
797
- }
798
- max *= multiplier[period];
799
- }
800
- }
801
- if (significant) { // Zero out insignificant periods
802
- for (var period = Y; period <= S; period++) {
803
- if (significant && periods[period]) {
804
- significant--;
805
- }
806
- else if (!significant) {
807
- periods[period] = 0;
808
- }
809
- }
810
- }
811
- return periods;
812
- }
813
- });
814
-
815
- /* jQuery extend now ignores nulls!
816
- @param target (object) the object to update
817
- @param props (object) the new settings
818
- @return (object) the updated object */
819
- function extendRemove(target, props) {
820
- $.extend(target, props);
821
- for (var name in props) {
822
- if (props[name] == null) {
823
- target[name] = null;
824
- }
825
- }
826
- return target;
827
- }
828
-
829
- /* Process the countdown functionality for a jQuery selection.
830
- @param command (string) the command to run (optional, default 'attach')
831
- @param options (object) the new settings to use for these countdown instances
832
- @return (jQuery) for chaining further calls */
833
- $.fn.countdown = function(options) {
834
- var otherArgs = Array.prototype.slice.call(arguments, 1);
835
- if (options == 'getTimes' || options == 'settings') {
836
- return $.countdown['_' + options + 'Countdown'].
837
- apply($.countdown, [this[0]].concat(otherArgs));
838
- }
839
- return this.each(function() {
840
- if (typeof options == 'string') {
841
- $.countdown['_' + options + 'Countdown'].apply($.countdown, [this].concat(otherArgs));
842
- }
843
- else {
844
- $.countdown._attachCountdown(this, options);
845
- }
846
- });
847
- };
848
-
849
- /* Initialise the countdown functionality. */
850
- $.countdown = new Countdown(); // singleton instance
851
-
852
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/jquery.countdown.js CHANGED
@@ -1,852 +1 @@
1
- /* http://keith-wood.name/countdown.html
2
- Countdown for jQuery v1.5.11.
3
- Written by Keith Wood (kbwood{at}iinet.com.au) January 2008.
4
- Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and
5
- MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses.
6
- Please attribute the author if you use it. */
7
-
8
- /* Display a countdown timer.
9
- Attach it with options like:
10
- $('div selector').countdown(
11
- {until: new Date(2009, 1 - 1, 1, 0, 0, 0), onExpiry: happyNewYear}); */
12
-
13
- (function($) { // Hide scope, no $ conflict
14
-
15
- /* Countdown manager. */
16
- function Countdown() {
17
- this.regional = []; // Available regional settings, indexed by language code
18
- this.regional[''] = { // Default regional settings
19
- // The display texts for the counters
20
- labels: ['Years', 'Months', 'Weeks', 'Days', 'Hours', 'Minutes', 'Seconds'],
21
- // The display texts for the counters if only one
22
- labels1: ['Year', 'Month', 'Week', 'Day', 'Hour', 'Minute', 'Second'],
23
- compactLabels: ['y', 'm', 'w', 'd'], // The compact texts for the counters
24
- whichLabels: null, // Function to determine which labels to use
25
- timeSeparator: ':', // Separator for time periods
26
- isRTL: false // True for right-to-left languages, false for left-to-right
27
- };
28
- this._defaults = {
29
- text_size: '35',
30
- animate_sec: false,
31
- color_down : '#3A3A3A',
32
- color_up : '#635b63',
33
- color_txt : '#ffffff',
34
- color_sw : '#000000',
35
- ujic_txt : true,
36
- ujic_url : false,
37
- until: null, // new Date(year, mth - 1, day, hr, min, sec) - date/time to count down to
38
- // or numeric for seconds offset, or string for unit offset(s):
39
- // 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
40
- since: null, // new Date(year, mth - 1, day, hr, min, sec) - date/time to count up from
41
- // or numeric for seconds offset, or string for unit offset(s):
42
- // 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
43
- timezone: null, // The timezone (hours or minutes from GMT) for the target times,
44
- // or null for client local
45
- serverSync: null, // A function to retrieve the current server time for synchronisation
46
- format: 'dHMS', // Format for display - upper case for always, lower case only if non-zero,
47
- // 'Y' years, 'O' months, 'W' weeks, 'D' days, 'H' hours, 'M' minutes, 'S' seconds
48
- layout: '', // Build your own layout for the countdown
49
- compact: false, // True to display in a compact format, false for an expanded one
50
- significant: 0, // The number of periods with values to show, zero for all
51
- description: '', // The description displayed for the countdown
52
- expiryUrl: '', // A URL to load upon expiry, replacing the current page
53
- expiryText: '', // Text to display upon expiry, replacing the countdown
54
- alwaysExpire: false, // True to trigger onExpiry even if never counted down
55
- onExpiry: null, // Callback when the countdown expires -
56
- // receives no parameters and 'this' is the containing division
57
- onTick: null, // Callback when the countdown is updated -
58
- // receives int[7] being the breakdown by period (based on format)
59
- // and 'this' is the containing division
60
- tickInterval: 1 // Interval (seconds) between onTick callbacks
61
- };
62
- $.extend(this._defaults, this.regional['']);
63
- this._serverSyncs = [];
64
- // Shared timer for all countdowns
65
- function timerCallBack(timestamp) {
66
- var drawStart = (timestamp || new Date().getTime());
67
- if (drawStart - animationStartTime >= 1000) {
68
- $.countdown._updateTargets();
69
- animationStartTime = drawStart;
70
- }
71
- requestAnimationFrame(timerCallBack);
72
- }
73
- var requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame ||
74
- window.mozRequestAnimationFrame || window.oRequestAnimationFrame ||
75
- window.msRequestAnimationFrame || null; // this is when we expect a fall-back to setInterval as it's much more fluid
76
- var animationStartTime = 0;
77
- if (!requestAnimationFrame) {
78
- setInterval(function() { $.countdown._updateTargets(); }, 980); // Fall back to good old setInterval
79
- }
80
- else {
81
- animationStartTime = window.mozAnimationStartTime || new Date().getTime();
82
- requestAnimationFrame(timerCallBack);
83
- }
84
- }
85
-
86
- var PROP_NAME = 'countdown';
87
-
88
- var Y = 0; // Years
89
- var O = 1; // Months
90
- var W = 2; // Weeks
91
- var D = 3; // Days
92
- var H = 4; // Hours
93
- var M = 5; // Minutes
94
- var S = 6; // Seconds
95
-
96
- $.extend(Countdown.prototype, {
97
- /* Class name added to elements to indicate already configured with countdown. */
98
- markerClassName: 'hasCountdown',
99
-
100
- /* List of currently active countdown targets. */
101
- _timerTargets: [],
102
-
103
- /* Override the default settings for all instances of the countdown widget.
104
- @param options (object) the new settings to use as defaults */
105
- setDefaults: function(options) {
106
- this._resetExtraLabels(this._defaults, options);
107
- extendRemove(this._defaults, options || {});
108
- },
109
-
110
- /* Convert a date/time to UTC.
111
- @param tz (number) the hour or minute offset from GMT, e.g. +9, -360
112
- @param year (Date) the date/time in that timezone or
113
- (number) the year in that timezone
114
- @param month (number, optional) the month (0 - 11) (omit if year is a Date)
115
- @param day (number, optional) the day (omit if year is a Date)
116
- @param hours (number, optional) the hour (omit if year is a Date)
117
- @param mins (number, optional) the minute (omit if year is a Date)
118
- @param secs (number, optional) the second (omit if year is a Date)
119
- @param ms (number, optional) the millisecond (omit if year is a Date)
120
- @return (Date) the equivalent UTC date/time */
121
- UTCDate: function(tz, year, month, day, hours, mins, secs, ms) {
122
- if (typeof year == 'object' && year.constructor == Date) {
123
- ms = year.getMilliseconds();
124
- secs = year.getSeconds();
125
- mins = year.getMinutes();
126
- hours = year.getHours();
127
- day = year.getDate();
128
- month = year.getMonth();
129
- year = year.getFullYear();
130
- }
131
- var d = new Date();
132
- d.setUTCFullYear(year);
133
- d.setUTCDate(1);
134
- d.setUTCMonth(month || 0);
135
- d.setUTCDate(day || 1);
136
- d.setUTCHours(hours || 0);
137
- d.setUTCMinutes((mins || 0) - (Math.abs(tz) < 30 ? tz * 60 : tz));
138
- d.setUTCSeconds(secs || 0);
139
- d.setUTCMilliseconds(ms || 0);
140
- return d;
141
- },
142
-
143
- /* Convert a set of periods into seconds.
144
- Averaged for months and years.
145
- @param periods (number[7]) the periods per year/month/week/day/hour/minute/second
146
- @return (number) the corresponding number of seconds */
147
- periodsToSeconds: function(periods) {
148
- return periods[0] * 31557600 + periods[1] * 2629800 + periods[2] * 604800 +
149
- periods[3] * 86400 + periods[4] * 3600 + periods[5] * 60 + periods[6];
150
- },
151
-
152
- /* Retrieve one or more settings values.
153
- @param name (string, optional) the name of the setting to retrieve
154
- or 'all' for all instance settings or omit for all default settings
155
- @return (any) the requested setting(s) */
156
- _settingsCountdown: function(target, name) {
157
- if (!name) {
158
- return $.countdown._defaults;
159
- }
160
- var inst = $.data(target, PROP_NAME);
161
- return (name == 'all' ? inst.options : inst.options[name]);
162
- },
163
-
164
- /* Attach the countdown widget to a div.
165
- @param target (element) the containing division
166
- @param options (object) the initial settings for the countdown */
167
- _attachCountdown: function(target, options) {
168
- var $target = $(target);
169
- if ($target.hasClass(this.markerClassName)) {
170
- return;
171
- }
172
- $target.addClass(this.markerClassName);
173
- var inst = {options: $.extend({}, options),
174
- _periods: [0, 0, 0, 0, 0, 0, 0]};
175
- $.data(target, PROP_NAME, inst);
176
- this._changeCountdown(target);
177
- },
178
-
179
- /* Add a target to the list of active ones.
180
- @param target (element) the countdown target */
181
- _addTarget: function(target) {
182
- if (!this._hasTarget(target)) {
183
- this._timerTargets.push(target);
184
- }
185
- },
186
-
187
- /* See if a target is in the list of active ones.
188
- @param target (element) the countdown target
189
- @return (boolean) true if present, false if not */
190
- _hasTarget: function(target) {
191
- return ($.inArray(target, this._timerTargets) > -1);
192
- },
193
-
194
- /* Remove a target from the list of active ones.
195
- @param target (element) the countdown target */
196
- _removeTarget: function(target) {
197
- this._timerTargets = $.map(this._timerTargets,
198
- function(value) { return (value == target ? null : value); }); // delete entry
199
- },
200
-
201
- /* Update each active timer target. */
202
- _updateTargets: function() {
203
- for (var i = this._timerTargets.length - 1; i >= 0; i--) {
204
- this._updateCountdown(this._timerTargets[i]);
205
- }
206
- },
207
-
208
- /* Redisplay the countdown with an updated display.
209
- @param target (jQuery) the containing division
210
- @param inst (object) the current settings for this instance */
211
- _updateCountdown: function(target, inst) {
212
- var $target = $(target);
213
- inst = inst || $.data(target, PROP_NAME);
214
- if (!inst) {
215
- return;
216
- }
217
- $target.html(this._generateHTML(inst));
218
- //ujimoto
219
-
220
- var ujic_url = this._get(inst, 'ujic_url');
221
- var ujic_until = this._get(inst, 'until');
222
- var foo = new Date; // Generic JS date object
223
- var unixtime = parseInt(foo.getTime() / 1000);
224
- var until_time = parseInt(ujic_until.getTime() / 1000)-2;
225
- /*delay 2 seconds for run process*/
226
- if(ujic_url == "false") ujic_url = false;
227
- if(ujic_url && (unixtime>until_time)){
228
- window.location.replace('ujic_url');
229
-
230
- }
231
-
232
- var color_down = this._get(inst, 'color_down');
233
- var color_up = this._get(inst, 'color_up');
234
- jQuery( '.countdown_amount').css("background-image", "linear-gradient(bottom, "+color_down+" 50%, "+color_up+" 50%)");
235
- jQuery( '.countdown_amount').css("background-image", "-o-linear-gradient(bottom, "+color_down+" 50%, "+color_up+" 50%)");
236
- jQuery( '.countdown_amount').css("background-image", "-moz-linear-gradient(bottom, "+color_down+" 50%, "+color_up+" 50%)");
237
- jQuery( '.countdown_amount').css("background-image", "-webkit-linear-gradient(bottom, "+color_down+" 50%, "+color_up+" 50%)");
238
- jQuery( '.countdown_amount').css("background-image", "-ms-linear-gradient(bottom, "+color_down+" 50%, "+color_up+" 50%)");
239
- jQuery( '.countdown_amount').css("filter", "progid:DXImageTransform.Microsoft.Gradient(startColorstr='"+color_down+"', endColorstr='"+color_up+"')");
240
-
241
- var color_txt = this._get(inst, 'color_txt');
242
- var color_sw = this._get(inst, 'color_sw');
243
- jQuery( '.countdown_amount').css("color", color_txt);
244
- jQuery( '.countdown_amount').css("text-shadow",'1px 1px 1px ' + color_sw);
245
-
246
-
247
- var ujic_txt = this._get(inst, 'ujic_txt');
248
- if(ujic_txt){
249
- jQuery('.countdown_txt').css("display","block");
250
- }else{
251
- jQuery('.countdown_txt').css("display","none");
252
- }
253
-
254
- var text_size = this._get(inst, 'text_size');
255
- jQuery( '.countdown_amount').css("font", text_size+"px/1.5 'Open Sans Condensed',sans-serif");
256
-
257
- var animate_sec = this._get(inst, 'animate_sec');
258
- if(animate_sec){
259
- var wsec = $("#uji_sec").find('.countdown_section').width();
260
- $("#uji_sec").find('.countdown_section').css({"width": wsec+"px"});
261
- $("#uji_sec").find('.countdown_amount').eq(1).css({"top": "-74px", "right": "0px", "position": "absolute", opacity:1});
262
- $("#uji_sec").find('.countdown_amount').eq(1).animate({"top": "0px", "right": "0px", opacity:1},700,function(){
263
- // Animation complete.
264
- // $("#uji_sec").find('.countdown_amount').eq(1).animate({ opacity:1}, 500);
265
- $("#uji_sec").find('.countdown_amount').eq(1).animate({opacity:0}, 300);
266
- });
267
- }
268
- //ujimoto
269
- $target[(this._get(inst, 'isRTL') ? 'add' : 'remove') + 'Class']('countdown_rtl');
270
- var onTick = this._get(inst, 'onTick');
271
- if (onTick) {
272
- var periods = inst._hold != 'lap' ? inst._periods :
273
- this._calculatePeriods(inst, inst._show, this._get(inst, 'significant'), new Date());
274
- var tickInterval = this._get(inst, 'tickInterval');
275
- if (tickInterval == 1 || this.periodsToSeconds(periods) % tickInterval == 0) {
276
- onTick.apply(target, [periods]);
277
- }
278
- }
279
- var expired = inst._hold != 'pause' &&
280
- (inst._since ? inst._now.getTime() < inst._since.getTime() :
281
- inst._now.getTime() >= inst._until.getTime());
282
- if (expired && !inst._expiring) {
283
- inst._expiring = true;
284
- if (this._hasTarget(target) || this._get(inst, 'alwaysExpire')) {
285
- this._removeTarget(target);
286
- var onExpiry = this._get(inst, 'onExpiry');
287
- if (onExpiry) {
288
- onExpiry.apply(target, []);
289
- }
290
- var expiryText = this._get(inst, 'expiryText');
291
- if (expiryText) {
292
- var layout = this._get(inst, 'layout');
293
- inst.options.layout = expiryText;
294
- this._updateCountdown(target, inst);
295
- inst.options.layout = layout;
296
- }
297
- var expiryUrl = this._get(inst, 'expiryUrl');
298
- if (expiryUrl) {
299
- window.location = expiryUrl;
300
- }
301
- }
302
- inst._expiring = false;
303
- }
304
- else if (inst._hold == 'pause') {
305
- this._removeTarget(target);
306
- }
307
- $.data(target, PROP_NAME, inst);
308
- },
309
-
310
- /* Reconfigure the settings for a countdown div.
311
- @param target (element) the containing division
312
- @param options (object) the new settings for the countdown or
313
- (string) an individual property name
314
- @param value (any) the individual property value
315
- (omit if options is an object) */
316
- _changeCountdown: function(target, options, value) {
317
- options = options || {};
318
- if (typeof options == 'string') {
319
- var name = options;
320
- options = {};
321
- options[name] = value;
322
- }
323
- var inst = $.data(target, PROP_NAME);
324
- if (inst) {
325
- this._resetExtraLabels(inst.options, options);
326
- extendRemove(inst.options, options);
327
- this._adjustSettings(target, inst);
328
- $.data(target, PROP_NAME, inst);
329
- var now = new Date();
330
- if ((inst._since && inst._since < now) ||
331
- (inst._until && inst._until > now)) {
332
- this._addTarget(target);
333
- }
334
- this._updateCountdown(target, inst);
335
- }
336
- },
337
-
338
- /* Reset any extra labelsn and compactLabelsn entries if changing labels.
339
- @param base (object) the options to be updated
340
- @param options (object) the new option values */
341
- _resetExtraLabels: function(base, options) {
342
- var changingLabels = false;
343
- for (var n in options) {
344
- if (n != 'whichLabels' && n.match(/[Ll]abels/)) {
345
- changingLabels = true;
346
- break;
347
- }
348
- }
349
- if (changingLabels) {
350
- for (var n in base) { // Remove custom numbered labels
351
- if (n.match(/[Ll]abels[0-9]/)) {
352
- base[n] = null;
353
- }
354
- }
355
- }
356
- },
357
-
358
- /* Calculate interal settings for an instance.
359
- @param target (element) the containing division
360
- @param inst (object) the current settings for this instance */
361
- _adjustSettings: function(target, inst) {
362
- var now;
363
- var serverSync = this._get(inst, 'serverSync');
364
- var serverOffset = 0;
365
- var serverEntry = null;
366
- for (var i = 0; i < this._serverSyncs.length; i++) {
367
- if (this._serverSyncs[i][0] == serverSync) {
368
- serverEntry = this._serverSyncs[i][1];
369
- break;
370
- }
371
- }
372
- if (serverEntry != null) {
373
- serverOffset = (serverSync ? serverEntry : 0);
374
- now = new Date();
375
- }
376
- else {
377
- var serverResult = (serverSync ? serverSync.apply(target, []) : null);
378
- now = new Date();
379
- serverOffset = (serverResult ? now.getTime() - serverResult.getTime() : 0);
380
- this._serverSyncs.push([serverSync, serverOffset]);
381
- }
382
- var timezone = this._get(inst, 'timezone');
383
- timezone = (timezone == null ? -now.getTimezoneOffset() : timezone);
384
- inst._since = this._get(inst, 'since');
385
- if (inst._since != null) {
386
- inst._since = this.UTCDate(timezone, this._determineTime(inst._since, null));
387
- if (inst._since && serverOffset) {
388
- inst._since.setMilliseconds(inst._since.getMilliseconds() + serverOffset);
389
- }
390
- }
391
- inst._until = this.UTCDate(timezone, this._determineTime(this._get(inst, 'until'), now));
392
- if (serverOffset) {
393
- inst._until.setMilliseconds(inst._until.getMilliseconds() + serverOffset);
394
- }
395
- inst._show = this._determineShow(inst);
396
- },
397
-
398
- /* Remove the countdown widget from a div.
399
- @param target (element) the containing division */
400
- _destroyCountdown: function(target) {
401
- var $target = $(target);
402
- if (!$target.hasClass(this.markerClassName)) {
403
- return;
404
- }
405
- this._removeTarget(target);
406
- $target.removeClass(this.markerClassName).empty();
407
- $.removeData(target, PROP_NAME);
408
- },
409
-
410
- /* Pause a countdown widget at the current time.
411
- Stop it running but remember and display the current time.
412
- @param target (element) the containing division */
413
- _pauseCountdown: function(target) {
414
- this._hold(target, 'pause');
415
- },
416
-
417
- /* Pause a countdown widget at the current time.
418
- Stop the display but keep the countdown running.
419
- @param target (element) the containing division */
420
- _lapCountdown: function(target) {
421
- this._hold(target, 'lap');
422
- },
423
-
424
- /* Resume a paused countdown widget.
425
- @param target (element) the containing division */
426
- _resumeCountdown: function(target) {
427
- this._hold(target, null);
428
- },
429
-
430
- /* Pause or resume a countdown widget.
431
- @param target (element) the containing division
432
- @param hold (string) the new hold setting */
433
- _hold: function(target, hold) {
434
- var inst = $.data(target, PROP_NAME);
435
- if (inst) {
436
- if (inst._hold == 'pause' && !hold) {
437
- inst._periods = inst._savePeriods;
438
- var sign = (inst._since ? '-' : '+');
439
- inst[inst._since ? '_since' : '_until'] =
440
- this._determineTime(sign + inst._periods[0] + 'y' +
441
- sign + inst._periods[1] + 'o' + sign + inst._periods[2] + 'w' +
442
- sign + inst._periods[3] + 'd' + sign + inst._periods[4] + 'h' +
443
- sign + inst._periods[5] + 'm' + sign + inst._periods[6] + 's');
444
- this._addTarget(target);
445
- }
446
- inst._hold = hold;
447
- inst._savePeriods = (hold == 'pause' ? inst._periods : null);
448
- $.data(target, PROP_NAME, inst);
449
- this._updateCountdown(target, inst);
450
- }
451
- },
452
-
453
- /* Return the current time periods.
454
- @param target (element) the containing division
455
- @return (number[7]) the current periods for the countdown */
456
- _getTimesCountdown: function(target) {
457
- var inst = $.data(target, PROP_NAME);
458
- return (!inst ? null : (!inst._hold ? inst._periods :
459
- this._calculatePeriods(inst, inst._show, this._get(inst, 'significant'), new Date())));
460
- },
461
-
462
- /* Get a setting value, defaulting if necessary.
463
- @param inst (object) the current settings for this instance
464
- @param name (string) the name of the required setting
465
- @return (any) the setting's value or a default if not overridden */
466
- _get: function(inst, name) {
467
- return (inst.options[name] != null ?
468
- inst.options[name] : $.countdown._defaults[name]);
469
- },
470
-
471
- /* A time may be specified as an exact value or a relative one.
472
- @param setting (string or number or Date) - the date/time value
473
- as a relative or absolute value
474
- @param defaultTime (Date) the date/time to use if no other is supplied
475
- @return (Date) the corresponding date/time */
476
- _determineTime: function(setting, defaultTime) {
477
- var offsetNumeric = function(offset) { // e.g. +300, -2
478
- var time = new Date();
479
- time.setTime(time.getTime() + offset * 1000);
480
- return time;
481
- };
482
- var offsetString = function(offset) { // e.g. '+2d', '-4w', '+3h +30m'
483
- offset = offset.toLowerCase();
484
- var time = new Date();
485
- var year = time.getFullYear();
486
- var month = time.getMonth();
487
- var day = time.getDate();
488
- var hour = time.getHours();
489
- var minute = time.getMinutes();
490
- var second = time.getSeconds();
491
- var pattern = /([+-]?[0-9]+)\s*(s|m|h|d|w|o|y)?/g;
492
- var matches = pattern.exec(offset);
493
- while (matches) {
494
- switch (matches[2] || 's') {
495
- case 's': second += parseInt(matches[1], 10); break;
496
- case 'm': minute += parseInt(matches[1], 10); break;
497
- case 'h': hour += parseInt(matches[1], 10); break;
498
- case 'd': day += parseInt(matches[1], 10); break;
499
- case 'w': day += parseInt(matches[1], 10) * 7; break;
500
- case 'o':
501
- month += parseInt(matches[1], 10);
502
- day = Math.min(day, $.countdown._getDaysInMonth(year, month));
503
- break;
504
- case 'y':
505
- year += parseInt(matches[1], 10);
506
- day = Math.min(day, $.countdown._getDaysInMonth(year, month));
507
- break;
508
- }
509
- matches = pattern.exec(offset);
510
- }
511
- return new Date(year, month, day, hour, minute, second, 0);
512
- };
513
- var time = (setting == null ? defaultTime :
514
- (typeof setting == 'string' ? offsetString(setting) :
515
- (typeof setting == 'number' ? offsetNumeric(setting) : setting)));
516
- if (time) time.setMilliseconds(0);
517
- return time;
518
- },
519
-
520
- /* Determine the number of days in a month.
521
- @param year (number) the year
522
- @param month (number) the month
523
- @return (number) the days in that month */
524
- _getDaysInMonth: function(year, month) {
525
- return 32 - new Date(year, month, 32).getDate();
526
- },
527
-
528
- /* Determine which set of labels should be used for an amount.
529
- @param num (number) the amount to be displayed
530
- @return (number) the set of labels to be used for this amount */
531
- _normalLabels: function(num) {
532
- return num;
533
- },
534
-
535
- /* Generate the HTML to display the countdown widget.
536
- @param inst (object) the current settings for this instance
537
- @return (string) the new HTML for the countdown display */
538
- _generateHTML: function(inst) {
539
- // Determine what to show
540
- var significant = this._get(inst, 'significant');
541
- inst._periods = (inst._hold ? inst._periods :
542
- this._calculatePeriods(inst, inst._show, significant, new Date()));
543
- // Show all 'asNeeded' after first non-zero value
544
- var shownNonZero = false;
545
- var showCount = 0;
546
- var sigCount = significant;
547
- var show = $.extend({}, inst._show);
548
- for (var period = Y; period <= S; period++) {
549
- shownNonZero |= (inst._show[period] == '?' && inst._periods[period] > 0);
550
- show[period] = (inst._show[period] == '?' && !shownNonZero ? null : inst._show[period]);
551
- showCount += (show[period] ? 1 : 0);
552
- sigCount -= (inst._periods[period] > 0 ? 1 : 0);
553
- }
554
- var showSignificant = [false, false, false, false, false, false, false];
555
- for (var period = S; period >= Y; period--) { // Determine significant periods
556
- if (inst._show[period]) {
557
- if (inst._periods[period]) {
558
- showSignificant[period] = true;
559
- }
560
- else {
561
- showSignificant[period] = sigCount > 0;
562
- sigCount--;
563
- }
564
- }
565
- }
566
- var compact = this._get(inst, 'compact');
567
- var layout = this._get(inst, 'layout');
568
- var labels = (compact ? this._get(inst, 'compactLabels') : this._get(inst, 'labels'));
569
- var whichLabels = this._get(inst, 'whichLabels') || this._normalLabels;
570
- var timeSeparator = this._get(inst, 'timeSeparator');
571
- var description = this._get(inst, 'description') || '';
572
- var showCompact = function(period) {
573
- var labelsNum = $.countdown._get(inst,
574
- 'compactLabels' + whichLabels(inst._periods[period]));
575
- return (show[period] ? inst._periods[period] +
576
- (labelsNum ? labelsNum[period] : labels[period]) + ' ' : '');
577
- };
578
- var showFull = function(period) {
579
- //ujimoto
580
- var labelsNum = $.countdown._get(inst, 'labels' + whichLabels(inst._periods[period]));
581
-
582
- if((!significant && show[period]) || (significant && showSignificant[period])){
583
- var ujinum ='';
584
- if(inst._periods[period].toString().length == 1){
585
- ujinum = '<span class="countdown_amount">' + 0+ '</span>' + '<span class="countdown_amount">' + inst._periods[period] + '</span>';
586
- } else{
587
- for (var i = 0; i < inst._periods[period].toString().length; i++) {
588
- ujinum += '<span class="countdown_amount">' + inst._periods[period].toString().charAt(i) + '</span>';
589
- }
590
- }
591
- return '<span class="countdown_section">' +
592
- ujinum + '<span class="countdown_txt">' +
593
- (labelsNum ? labelsNum[period] : labels[period]) + '</span></span>';
594
-
595
- }else {
596
- return '';
597
- }
598
- //ujimoto
599
- };
600
-
601
- return (layout ? this._buildLayout(inst, show, layout, compact, significant, showSignificant) :
602
- ((compact ? // Compact version
603
- '<span class="countdown_row countdown_amount' +
604
- (inst._hold ? ' countdown_holding' : '') + '">' +
605
- showCompact(Y) + showCompact(O) + showCompact(W) + showCompact(D) +
606
- (show[H] ? this._minDigits(inst._periods[H], 2) : '') +
607
- (show[M] ? (show[H] ? timeSeparator : '') +
608
- this._minDigits(inst._periods[M], 2) : '') +
609
- (show[S] ? (show[H] || show[M] ? timeSeparator : '') +
610
- this._minDigits(inst._periods[S], 2) : '') :
611
- // Full version
612
- '<span class="countdown_row countdown_show' + (significant || showCount) +
613
- (inst._hold ? ' countdown_holding' : '') + '">' +
614
- showFull(Y) + showFull(O) + showFull(W) + showFull(D) +
615
- showFull(H) + showFull(M) + '<span id="uji_sec">'+ showFull(S)) + '</span>' + '</span>' +
616
- (description ? '<span class="countdown_row countdown_descr">' + description + '</span>' : '')));
617
- },
618
-
619
- /* Construct a custom layout.
620
- @param inst (object) the current settings for this instance
621
- @param show (string[7]) flags indicating which periods are requested
622
- @param layout (string) the customised layout
623
- @param compact (boolean) true if using compact labels
624
- @param significant (number) the number of periods with values to show, zero for all
625
- @param showSignificant (boolean[7]) other periods to show for significance
626
- @return (string) the custom HTML */
627
- _buildLayout: function(inst, show, layout, compact, significant, showSignificant) {
628
- var labels = this._get(inst, (compact ? 'compactLabels' : 'labels'));
629
- var whichLabels = this._get(inst, 'whichLabels') || this._normalLabels;
630
- var labelFor = function(index) {
631
- return ($.countdown._get(inst,
632
- (compact ? 'compactLabels' : 'labels') + whichLabels(inst._periods[index])) ||
633
- labels)[index];
634
- };
635
- var digit = function(value, position) {
636
- return Math.floor(value / position) % 10;
637
- };
638
- var subs = {desc: this._get(inst, 'description'), sep: this._get(inst, 'timeSeparator'),
639
- yl: labelFor(Y), yn: inst._periods[Y], ynn: this._minDigits(inst._periods[Y], 2),
640
- ynnn: this._minDigits(inst._periods[Y], 3), y1: digit(inst._periods[Y], 1),
641
- y10: digit(inst._periods[Y], 10), y100: digit(inst._periods[Y], 100),
642
- y1000: digit(inst._periods[Y], 1000),
643
- ol: labelFor(O), on: inst._periods[O], onn: this._minDigits(inst._periods[O], 2),
644
- onnn: this._minDigits(inst._periods[O], 3), o1: digit(inst._periods[O], 1),
645
- o10: digit(inst._periods[O], 10), o100: digit(inst._periods[O], 100),
646
- o1000: digit(inst._periods[O], 1000),
647
- wl: labelFor(W), wn: inst._periods[W], wnn: this._minDigits(inst._periods[W], 2),
648
- wnnn: this._minDigits(inst._periods[W], 3), w1: digit(inst._periods[W], 1),
649
- w10: digit(inst._periods[W], 10), w100: digit(inst._periods[W], 100),
650
- w1000: digit(inst._periods[W], 1000),
651
- dl: labelFor(D), dn: inst._periods[D], dnn: this._minDigits(inst._periods[D], 2),
652
- dnnn: this._minDigits(inst._periods[D], 3), d1: digit(inst._periods[D], 1),
653
- d10: digit(inst._periods[D], 10), d100: digit(inst._periods[D], 100),
654
- d1000: digit(inst._periods[D], 1000),
655
- hl: labelFor(H), hn: inst._periods[H], hnn: this._minDigits(inst._periods[H], 2),
656
- hnnn: this._minDigits(inst._periods[H], 3), h1: digit(inst._periods[H], 1),
657
- h10: digit(inst._periods[H], 10), h100: digit(inst._periods[H], 100),
658
- h1000: digit(inst._periods[H], 1000),
659
- ml: labelFor(M), mn: inst._periods[M], mnn: this._minDigits(inst._periods[M], 2),
660
- mnnn: this._minDigits(inst._periods[M], 3), m1: digit(inst._periods[M], 1),
661
- m10: digit(inst._periods[M], 10), m100: digit(inst._periods[M], 100),
662
- m1000: digit(inst._periods[M], 1000),
663
- sl: labelFor(S), sn: inst._periods[S], snn: this._minDigits(inst._periods[S], 2),
664
- snnn: this._minDigits(inst._periods[S], 3), s1: digit(inst._periods[S], 1),
665
- s10: digit(inst._periods[S], 10), s100: digit(inst._periods[S], 100),
666
- s1000: digit(inst._periods[S], 1000)};
667
- var html = layout;
668
- // Replace period containers: {p<}...{p>}
669
- for (var i = Y; i <= S; i++) {
670
- var period = 'yowdhms'.charAt(i);
671
- var re = new RegExp('\\{' + period + '<\\}(.*)\\{' + period + '>\\}', 'g');
672
- html = html.replace(re, ((!significant && show[i]) ||
673
- (significant && showSignificant[i]) ? '$1' : ''));
674
- }
675
- // Replace period values: {pn}
676
- $.each(subs, function(n, v) {
677
- var re = new RegExp('\\{' + n + '\\}', 'g');
678
- html = html.replace(re, v);
679
- });
680
- return html;
681
- },
682
-
683
- /* Ensure a numeric value has at least n digits for display.
684
- @param value (number) the value to display
685
- @param len (number) the minimum length
686
- @return (string) the display text */
687
- _minDigits: function(value, len) {
688
- value = '' + value;
689
- if (value.length >= len) {
690
- return value;
691
- }
692
- value = '0000000000' + value;
693
- return value.substr(value.length - len);
694
- },
695
-
696
- /* Translate the format into flags for each period.
697
- @param inst (object) the current settings for this instance
698
- @return (string[7]) flags indicating which periods are requested (?) or
699
- required (!) by year, month, week, day, hour, minute, second */
700
- _determineShow: function(inst) {
701
- var format = this._get(inst, 'format');
702
- var show = [];
703
- show[Y] = (format.match('y') ? '?' : (format.match('Y') ? '!' : null));
704
- show[O] = (format.match('o') ? '?' : (format.match('O') ? '!' : null));
705
- show[W] = (format.match('w') ? '?' : (format.match('W') ? '!' : null));
706
- show[D] = (format.match('d') ? '?' : (format.match('D') ? '!' : null));
707
- show[H] = (format.match('h') ? '?' : (format.match('H') ? '!' : null));
708
- show[M] = (format.match('m') ? '?' : (format.match('M') ? '!' : null));
709
- show[S] = (format.match('s') ? '?' : (format.match('S') ? '!' : null));
710
- return show;
711
- },
712
-
713
- /* Calculate the requested periods between now and the target time.
714
- @param inst (object) the current settings for this instance
715
- @param show (string[7]) flags indicating which periods are requested/required
716
- @param significant (number) the number of periods with values to show, zero for all
717
- @param now (Date) the current date and time
718
- @return (number[7]) the current time periods (always positive)
719
- by year, month, week, day, hour, minute, second */
720
- _calculatePeriods: function(inst, show, significant, now) {
721
- // Find endpoints
722
- inst._now = now;
723
- inst._now.setMilliseconds(0);
724
- var until = new Date(inst._now.getTime());
725
- if (inst._since) {
726
- if (now.getTime() < inst._since.getTime()) {
727
- inst._now = now = until;
728
- }
729
- else {
730
- now = inst._since;
731
- }
732
- }
733
- else {
734
- until.setTime(inst._until.getTime());
735
- if (now.getTime() > inst._until.getTime()) {
736
- inst._now = now = until;
737
- }
738
- }
739
- // Calculate differences by period
740
- var periods = [0, 0, 0, 0, 0, 0, 0];
741
- if (show[Y] || show[O]) {
742
- // Treat end of months as the same
743
- var lastNow = $.countdown._getDaysInMonth(now.getFullYear(), now.getMonth());
744
- var lastUntil = $.countdown._getDaysInMonth(until.getFullYear(), until.getMonth());
745
- var sameDay = (until.getDate() == now.getDate() ||
746
- (until.getDate() >= Math.min(lastNow, lastUntil) &&
747
- now.getDate() >= Math.min(lastNow, lastUntil)));
748
- var getSecs = function(date) {
749
- return (date.getHours() * 60 + date.getMinutes()) * 60 + date.getSeconds();
750
- };
751
- var months = Math.max(0,
752
- (until.getFullYear() - now.getFullYear()) * 12 + until.getMonth() - now.getMonth() +
753
- ((until.getDate() < now.getDate() && !sameDay) ||
754
- (sameDay && getSecs(until) < getSecs(now)) ? -1 : 0));
755
- periods[Y] = (show[Y] ? Math.floor(months / 12) : 0);
756
- periods[O] = (show[O] ? months - periods[Y] * 12 : 0);
757
- // Adjust for months difference and end of month if necessary
758
- now = new Date(now.getTime());
759
- var wasLastDay = (now.getDate() == lastNow);
760
- var lastDay = $.countdown._getDaysInMonth(now.getFullYear() + periods[Y],
761
- now.getMonth() + periods[O]);
762
- if (now.getDate() > lastDay) {
763
- now.setDate(lastDay);
764
- }
765
- now.setFullYear(now.getFullYear() + periods[Y]);
766
- now.setMonth(now.getMonth() + periods[O]);
767
- if (wasLastDay) {
768
- now.setDate(lastDay);
769
- }
770
- }
771
- var diff = Math.floor((until.getTime() - now.getTime()) / 1000);
772
- var extractPeriod = function(period, numSecs) {
773
- periods[period] = (show[period] ? Math.floor(diff / numSecs) : 0);
774
- diff -= periods[period] * numSecs;
775
- };
776
- extractPeriod(W, 604800);
777
- extractPeriod(D, 86400);
778
- extractPeriod(H, 3600);
779
- extractPeriod(M, 60);
780
- extractPeriod(S, 1);
781
- if (diff > 0 && !inst._since) { // Round up if left overs
782
- var multiplier = [1, 12, 4.3482, 7, 24, 60, 60];
783
- var lastShown = S;
784
- var max = 1;
785
- for (var period = S; period >= Y; period--) {
786
- if (show[period]) {
787
- if (periods[lastShown] >= max) {
788
- periods[lastShown] = 0;
789
- diff = 1;
790
- }
791
- if (diff > 0) {
792
- periods[period]++;
793
- diff = 0;
794
- lastShown = period;
795
- max = 1;
796
- }
797
- }
798
- max *= multiplier[period];
799
- }
800
- }
801
- if (significant) { // Zero out insignificant periods
802
- for (var period = Y; period <= S; period++) {
803
- if (significant && periods[period]) {
804
- significant--;
805
- }
806
- else if (!significant) {
807
- periods[period] = 0;
808
- }
809
- }
810
- }
811
- return periods;
812
- }
813
- });
814
-
815
- /* jQuery extend now ignores nulls!
816
- @param target (object) the object to update
817
- @param props (object) the new settings
818
- @return (object) the updated object */
819
- function extendRemove(target, props) {
820
- $.extend(target, props);
821
- for (var name in props) {
822
- if (props[name] == null) {
823
- target[name] = null;
824
- }
825
- }
826
- return target;
827
- }
828
-
829
- /* Process the countdown functionality for a jQuery selection.
830
- @param command (string) the command to run (optional, default 'attach')
831
- @param options (object) the new settings to use for these countdown instances
832
- @return (jQuery) for chaining further calls */
833
- $.fn.countdown = function(options) {
834
- var otherArgs = Array.prototype.slice.call(arguments, 1);
835
- if (options == 'getTimes' || options == 'settings') {
836
- return $.countdown['_' + options + 'Countdown'].
837
- apply($.countdown, [this[0]].concat(otherArgs));
838
- }
839
- return this.each(function() {
840
- if (typeof options == 'string') {
841
- $.countdown['_' + options + 'Countdown'].apply($.countdown, [this].concat(otherArgs));
842
- }
843
- else {
844
- $.countdown._attachCountdown(this, options);
845
- }
846
- });
847
- };
848
-
849
- /* Initialise the countdown functionality. */
850
- $.countdown = new Countdown(); // singleton instance
851
-
852
- })(jQuery);
1
+ (function(e){function t(){function t(e){var i=e<1e12?i=performance.now?performance.now()+performance.timing.navigationStart:Date.now():e||(new Date).getTime();if(i-r>=1e3){c._updateTargets();r=i}n(t)}this.regional=[];this.regional[""]={labels:["Years","Months","Weeks","Days","Hours","Minutes","Seconds"],labels1:["Year","Month","Week","Day","Hour","Minute","Second"],compactLabels:["y","m","w","d"],whichLabels:null,digits:["0","1","2","3","4","5","6","7","8","9"],timeSeparator:":",isRTL:false};this._defaults={text_size:"35",animate_sec:false,color_down:"#3A3A3A",color_up:"#635b63",color_txt:"#ffffff",color_sw:"#000000",ujic_txt:true,ujic_url:false,until:null,since:null,timezone:null,serverSync:null,format:"dHMS",layout:"",compact:false,significant:0,description:"",expiryUrl:"",expiryText:"",alwaysExpire:false,onExpiry:null,onTick:null,tickInterval:1};e.extend(this._defaults,this.regional[""]);this._serverSyncs=[];var n=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||null;var r=0;if(!n||e.noRequestAnimationFrame){e.noRequestAnimationFrame=null;setInterval(function(){c._updateTargets()},980)}else{r=window.animationStartTime||window.webkitAnimationStartTime||window.mozAnimationStartTime||window.oAnimationStartTime||window.msAnimationStartTime||(new Date).getTime();n(t)}}function l(t,n){if(t=="option"&&(n.length==0||n.length==1&&typeof n[0]=="string")){return true}return e.inArray(t,f)>-1}var n=0;var r=1;var i=2;var s=3;var o=4;var u=5;var a=6;e.extend(t.prototype,{markerClassName:"hasCountdown",propertyName:"countdown",_rtlClass:"countdown_rtl",_sectionClass:"countdown_section",_amountClass:"countdown_amount",_rowClass:"countdown_row",_holdingClass:"countdown_holding",_showClass:"countdown_show",_descrClass:"countdown_descr",_timerTargets:[],setDefaults:function(t){this._resetExtraLabels(this._defaults,t);e.extend(this._defaults,t||{})},UTCDate:function(e,t,n,r,i,s,o,u){if(typeof t=="object"&&t.constructor==Date){u=t.getMilliseconds();o=t.getSeconds();s=t.getMinutes();i=t.getHours();r=t.getDate();n=t.getMonth();t=t.getFullYear()}var a=new Date;a.setUTCFullYear(t);a.setUTCDate(1);a.setUTCMonth(n||0);a.setUTCDate(r||1);a.setUTCHours(i||0);a.setUTCMinutes((s||0)-(Math.abs(e)<30?e*60:e));a.setUTCSeconds(o||0);a.setUTCMilliseconds(u||0);return a},periodsToSeconds:function(e){return e[0]*31557600+e[1]*2629800+e[2]*604800+e[3]*86400+e[4]*3600+e[5]*60+e[6]},_attachPlugin:function(t,n){t=e(t);if(t.hasClass(this.markerClassName)){return}var r={options:e.extend({},this._defaults),_periods:[0,0,0,0,0,0,0]};t.addClass(this.markerClassName).data(this.propertyName,r);this._optionPlugin(t,n)},_addTarget:function(e){if(!this._hasTarget(e)){this._timerTargets.push(e)}},_hasTarget:function(t){return e.inArray(t,this._timerTargets)>-1},_removeTarget:function(t){this._timerTargets=e.map(this._timerTargets,function(e){return e==t?null:e})},_updateTargets:function(){for(var e=this._timerTargets.length-1;e>=0;e--){this._updateCountdown(this._timerTargets[e])}},_optionPlugin:function(t,n,r){t=e(t);var i=t.data(this.propertyName);if(!n||typeof n=="string"&&r==null){var s=n;n=(i||{}).options;return n&&s?n[s]:n}if(!t.hasClass(this.markerClassName)){return}n=n||{};if(typeof n=="string"){var s=n;n={};n[s]=r}this._resetExtraLabels(i.options,n);e.extend(i.options,n);this._adjustSettings(t,i);var o=new Date;if(i._since&&i._since<o||i._until&&i._until>o){this._addTarget(t[0])}this._updateCountdown(t,i)},_updateCountdown:function(t,n){var r=e(t);n=n||r.data(this.propertyName);if(!n){return}r.html(this._generateHTML(n)).toggleClass(this._rtlClass,n.options.isRTL);var i=n.options.ujic_url;var s=n.options.until;var o=new Date;var u=parseInt(o.getTime()/1e3);var a=parseInt(s.getTime()/1e3)-2;if(i&&u>a){window.location.replace(i)}var f=n.options.color_down;var l=n.options.color_up;jQuery(".countdown_amount").css("background-image","linear-gradient(bottom, "+f+" 50%, "+l+" 50%)");jQuery(".countdown_amount").css("background-image","-o-linear-gradient(bottom, "+f+" 50%, "+l+" 50%)");jQuery(".countdown_amount").css("background-image","-moz-linear-gradient(bottom, "+f+" 50%, "+l+" 50%)");jQuery(".countdown_amount").css("background-image","-webkit-linear-gradient(bottom, "+f+" 50%, "+l+" 50%)");jQuery(".countdown_amount").css("background-image","-ms-linear-gradient(bottom, "+f+" 50%, "+l+" 50%)");jQuery(".countdown_amount").css("filter","progid:DXImageTransform.Microsoft.Gradient(startColorstr='"+f+"', endColorstr='"+l+"')");var c=n.options.color_txt;var h=n.options.color_sw;jQuery(".countdown_amount").css("color",c);jQuery(".countdown_amount").css("text-shadow","1px 1px 1px "+h);var p=n.options.ujic_txt;if(p){jQuery(".countdown_txt").css("display","block")}else{jQuery(".countdown_txt").css("display","none")}var d=n.options.text_size;jQuery(".countdown_amount").css("font",d+"px/1.5 'Open Sans Condensed',sans-serif");var v=n.options.animate_sec;if(v){var m=e("#uji_sec").find(".countdown_section").width();e("#uji_sec").find(".countdown_section").css({width:m+"px"});e("#uji_sec").find(".countdown_amount").eq(1).css({top:"-74px",right:"0px",position:"absolute",opacity:1});e("#uji_sec").find(".countdown_amount").eq(1).animate({top:"0px",right:"0px",opacity:1},700,function(){e("#uji_sec").find(".countdown_amount").eq(1).animate({opacity:0},300)})}if(e.isFunction(n.options.onTick)){var g=n._hold!="lap"?n._periods:this._calculatePeriods(n,n._show,n.options.significant,new Date);if(n.options.tickInterval==1||this.periodsToSeconds(g)%n.options.tickInterval==0){n.options.onTick.apply(t,[g])}}var y=n._hold!="pause"&&(n._since?n._now.getTime()<n._since.getTime():n._now.getTime()>=n._until.getTime());if(y&&!n._expiring){n._expiring=true;if(this._hasTarget(t)||n.options.alwaysExpire){this._removeTarget(t);if(e.isFunction(n.options.onExpiry)){n.options.onExpiry.apply(t,[])}if(n.options.expiryText){var b=n.options.layout;n.options.layout=n.options.expiryText;this._updateCountdown(t,n);n.options.layout=b}if(n.options.expiryUrl){window.location=n.options.expiryUrl}}n._expiring=false}else if(n._hold=="pause"){this._removeTarget(t)}r.data(this.propertyName,n)},_resetExtraLabels:function(e,t){var n=false;for(var r in t){if(r!="whichLabels"&&r.match(/[Ll]abels/)){n=true;break}}if(n){for(var r in e){if(r.match(/[Ll]abels[02-9]/)){e[r]=null}}}},_adjustSettings:function(t,n){var r;var i=0;var s=null;for(var o=0;o<this._serverSyncs.length;o++){if(this._serverSyncs[o][0]==n.options.serverSync){s=this._serverSyncs[o][1];break}}if(s!=null){i=n.options.serverSync?s:0;r=new Date}else{var u=e.isFunction(n.options.serverSync)?n.options.serverSync.apply(t,[]):null;r=new Date;i=u?r.getTime()-u.getTime():0;this._serverSyncs.push([n.options.serverSync,i])}var a=n.options.timezone;a=a==null?-r.getTimezoneOffset():a;n._since=n.options.since;if(n._since!=null){n._since=this.UTCDate(a,this._determineTime(n._since,null));if(n._since&&i){n._since.setMilliseconds(n._since.getMilliseconds()+i)}}n._until=this.UTCDate(a,this._determineTime(n.options.until,r));if(i){n._until.setMilliseconds(n._until.getMilliseconds()+i)}n._show=this._determineShow(n)},_destroyPlugin:function(t){t=e(t);if(!t.hasClass(this.markerClassName)){return}this._removeTarget(t[0]);t.removeClass(this.markerClassName).empty().removeData(this.propertyName)},_pausePlugin:function(e){this._hold(e,"pause")},_lapPlugin:function(e){this._hold(e,"lap")},_resumePlugin:function(e){this._hold(e,null)},_hold:function(t,n){var r=e.data(t,this.propertyName);if(r){if(r._hold=="pause"&&!n){r._periods=r._savePeriods;var i=r._since?"-":"+";r[r._since?"_since":"_until"]=this._determineTime(i+r._periods[0]+"y"+i+r._periods[1]+"o"+i+r._periods[2]+"w"+i+r._periods[3]+"d"+i+r._periods[4]+"h"+i+r._periods[5]+"m"+i+r._periods[6]+"s");this._addTarget(t)}r._hold=n;r._savePeriods=n=="pause"?r._periods:null;e.data(t,this.propertyName,r);this._updateCountdown(t,r)}},_getTimesPlugin:function(t){var n=e.data(t,this.propertyName);return!n?null:!n._hold?n._periods:this._calculatePeriods(n,n._show,n.options.significant,new Date)},_determineTime:function(e,t){var n=function(e){var t=new Date;t.setTime(t.getTime()+e*1e3);return t};var r=function(e){e=e.toLowerCase();var t=new Date;var n=t.getFullYear();var r=t.getMonth();var i=t.getDate();var s=t.getHours();var o=t.getMinutes();var u=t.getSeconds();var a=/([+-]?[0-9]+)\s*(s|m|h|d|w|o|y)?/g;var f=a.exec(e);while(f){switch(f[2]||"s"){case"s":u+=parseInt(f[1],10);break;case"m":o+=parseInt(f[1],10);break;case"h":s+=parseInt(f[1],10);break;case"d":i+=parseInt(f[1],10);break;case"w":i+=parseInt(f[1],10)*7;break;case"o":r+=parseInt(f[1],10);i=Math.min(i,c._getDaysInMonth(n,r));break;case"y":n+=parseInt(f[1],10);i=Math.min(i,c._getDaysInMonth(n,r));break}f=a.exec(e)}return new Date(n,r,i,s,o,u,0)};var i=e==null?t:typeof e=="string"?r(e):typeof e=="number"?n(e):e;if(i)i.setMilliseconds(0);return i},_getDaysInMonth:function(e,t){return 32-(new Date(e,t,32)).getDate()},_normalLabels:function(e){return e},_generateHTML:function(t){var f=this;t._periods=t._hold?t._periods:this._calculatePeriods(t,t._show,t.options.significant,new Date);var l=false;var c=0;var h=t.options.significant;var p=e.extend({},t._show);for(var d=n;d<=a;d++){l|=t._show[d]=="?"&&t._periods[d]>0;p[d]=t._show[d]=="?"&&!l?null:t._show[d];c+=p[d]?1:0;h-=t._periods[d]>0?1:0}var v=[false,false,false,false,false,false,false];for(var d=a;d>=n;d--){if(t._show[d]){if(t._periods[d]){v[d]=true}else{v[d]=h>0;h--}}}var m=t.options.compact?t.options.compactLabels:t.options.labels;var g=t.options.whichLabels||this._normalLabels;var y=function(e){var n=t.options["compactLabels"+g(t._periods[e])];return p[e]?f._translateDigits(t,t._periods[e])+(n?n[e]:m[e])+" ":""};var b=function(e){var n=t.options["labels"+g(t._periods[e])];if(!T&&p[e]||T&&v[e]){var r="";if(t._periods[e].toString().length==1){r='<span class="countdown_amount">'+0+"</span>"+'<span class="countdown_amount">'+t._periods[e]+"</span>"}else{for(var i=0;i<t._periods[e].toString().length;i++){r+='<span class="countdown_amount">'+t._periods[e].toString().charAt(i)+"</span>"}}return'<span class="countdown_section">'+r+'<span class="countdown_txt">'+(n?n[e]:m[e])+"</span></span>"}else{return""}};var w=t.options.ujic_style;var E=t.options.layout;var x=t.options.compact;var T=t.options.significant;var N=t.options.description;return E?this._buildLayout(t,p,E,x,T,v):(x?'<span class="countdown_row countdown_amount'+(t._hold?" countdown_holding":"")+'">'+y(n)+y(r)+y(i)+y(s)+(p[o]?this._minDigits(t._periods[o],2):"")+(p[u]?(p[o]?timeSeparator:"")+this._minDigits(t._periods[u],2):"")+(p[a]?(p[o]||p[u]?timeSeparator:"")+this._minDigits(t._periods[a],2):""):'<span class="countdown_row countdown_show'+(T||c)+(t._hold?" countdown_holding":"")+'">'+b(n)+b(r)+b(i)+b(s)+b(o)+b(u)+'<span id="uji_sec">'+b(a))+"</span>"+"</span>"+(N?'<span class="countdown_row countdown_descr">'+N+"</span>":"");var C=t.options.ujic_id;showFullNew(a,C)},_buildLayout:function(t,f,l,c,h,p){var d=t.options[c?"compactLabels":"labels"];var v=t.options.whichLabels||this._normalLabels;var m=function(e){return(t.options[(c?"compactLabels":"labels")+v(t._periods[e])]||d)[e]};var g=function(e,n){return t.options.digits[Math.floor(e/n)%10]};var y={desc:t.options.description,sep:t.options.timeSeparator,yl:m(n),yn:this._minDigits(t,t._periods[n],1),ynn:this._minDigits(t,t._periods[n],2),ynnn:this._minDigits(t,t._periods[n],3),y1:g(t._periods[n],1),y10:g(t._periods[n],10),y100:g(t._periods[n],100),y1000:g(t._periods[n],1e3),ol:m(r),on:this._minDigits(t,t._periods[r],1),onn:this._minDigits(t,t._periods[r],2),onnn:this._minDigits(t,t._periods[r],3),o1:g(t._periods[r],1),o10:g(t._periods[r],10),o100:g(t._periods[r],100),o1000:g(t._periods[r],1e3),wl:m(i),wn:this._minDigits(t,t._periods[i],1),wnn:this._minDigits(t,t._periods[i],2),wnnn:this._minDigits(t,t._periods[i],3),w1:g(t._periods[i],1),w10:g(t._periods[i],10),w100:g(t._periods[i],100),w1000:g(t._periods[i],1e3),dl:m(s),dn:this._minDigits(t,t._periods[s],1),dnn:this._minDigits(t,t._periods[s],2),dnnn:this._minDigits(t,t._periods[s],3),d1:g(t._periods[s],1),d10:g(t._periods[s],10),d100:g(t._periods[s],100),d1000:g(t._periods[s],1e3),hl:m(o),hn:this._minDigits(t,t._periods[o],1),hnn:this._minDigits(t,t._periods[o],2),hnnn:this._minDigits(t,t._periods[o],3),h1:g(t._periods[o],1),h10:g(t._periods[o],10),h100:g(t._periods[o],100),h1000:g(t._periods[o],1e3),ml:m(u),mn:this._minDigits(t,t._periods[u],1),mnn:this._minDigits(t,t._periods[u],2),mnnn:this._minDigits(t,t._periods[u],3),m1:g(t._periods[u],1),m10:g(t._periods[u],10),m100:g(t._periods[u],100),m1000:g(t._periods[u],1e3),sl:m(a),sn:this._minDigits(t,t._periods[a],1),snn:this._minDigits(t,t._periods[a],2),snnn:this._minDigits(t,t._periods[a],3),s1:g(t._periods[a],1),s10:g(t._periods[a],10),s100:g(t._periods[a],100),s1000:g(t._periods[a],1e3)};var b=l;for(var w=n;w<=a;w++){var E="yowdhms".charAt(w);var x=new RegExp("\\{"+E+"<\\}(.*)\\{"+E+">\\}","g");b=b.replace(x,!h&&f[w]||h&&p[w]?"$1":"")}e.each(y,function(e,t){var n=new RegExp("\\{"+e+"\\}","g");b=b.replace(n,t)});return b},_minDigits:function(e,t,n){t=""+t;if(t.length>=n){return this._translateDigits(e,t)}t="0000000000"+t;return this._translateDigits(e,t.substr(t.length-n))},_translateDigits:function(e,t){return(""+t).replace(/[0-9]/g,function(t){return e.options.digits[t]})},_determineShow:function(e){var t=e.options.format;var f=[];f[n]=t.match("y")?"?":t.match("Y")?"!":null;f[r]=t.match("o")?"?":t.match("O")?"!":null;f[i]=t.match("w")?"?":t.match("W")?"!":null;f[s]=t.match("d")?"?":t.match("D")?"!":null;f[o]=t.match("h")?"?":t.match("H")?"!":null;f[u]=t.match("m")?"?":t.match("M")?"!":null;f[a]=t.match("s")?"?":t.match("S")?"!":null;return f},_calculatePeriods:function(e,t,f,l){e._now=l;e._now.setMilliseconds(0);var h=new Date(e._now.getTime());if(e._since){if(l.getTime()<e._since.getTime()){e._now=l=h}else{l=e._since}}else{h.setTime(e._until.getTime());if(l.getTime()>e._until.getTime()){e._now=l=h}}var p=[0,0,0,0,0,0,0];if(t[n]||t[r]){var d=c._getDaysInMonth(l.getFullYear(),l.getMonth());var v=c._getDaysInMonth(h.getFullYear(),h.getMonth());var m=h.getDate()==l.getDate()||h.getDate()>=Math.min(d,v)&&l.getDate()>=Math.min(d,v);var g=function(e){return(e.getHours()*60+e.getMinutes())*60+e.getSeconds()};var y=Math.max(0,(h.getFullYear()-l.getFullYear())*12+h.getMonth()-l.getMonth()+(h.getDate()<l.getDate()&&!m||m&&g(h)<g(l)?-1:0));p[n]=t[n]?Math.floor(y/12):0;p[r]=t[r]?y-p[n]*12:0;l=new Date(l.getTime());var b=l.getDate()==d;var w=c._getDaysInMonth(l.getFullYear()+p[n],l.getMonth()+p[r]);if(l.getDate()>w){l.setDate(w)}l.setFullYear(l.getFullYear()+p[n]);l.setMonth(l.getMonth()+p[r]);if(b){l.setDate(w)}}var E=Math.floor((h.getTime()-l.getTime())/1e3);var x=function(e,n){p[e]=t[e]?Math.floor(E/n):0;E-=p[e]*n};x(i,604800);x(s,86400);x(o,3600);x(u,60);x(a,1);if(E>0&&!e._since){var T=[1,12,4.3482,7,24,60,60];var N=a;var C=1;for(var k=a;k>=n;k--){if(t[k]){if(p[N]>=C){p[N]=0;E=1}if(E>0){p[k]++;E=0;N=k;C=1}}C*=T[k]}}if(f){for(var k=n;k<=a;k++){if(f&&p[k]){f--}else if(!f){p[k]=0}}}return p}});var f=["getTimes"];e.fn.countdown=function(e){var t=Array.prototype.slice.call(arguments,1);if(l(e,t)){return c["_"+e+"Plugin"].apply(c,[this[0]].concat(t))}return this.each(function(){if(typeof e=="string"){if(!c["_"+e+"Plugin"]){throw"Unknown command: "+e}c["_"+e+"Plugin"].apply(c,[this].concat(t))}else{c._attachPlugin(this,e||{})}})};var c=e.countdown=new t})(jQuery)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: ujimoto
3
  Donate link: http://wpmanage.com/Uji-countdown
4
  Tags: countdown, counter, html5 countdown, animated countdown, countdown timer, count down, countdown clock, jQuery countdown, clock, timer
5
  Requires at least: 3.0
6
- Tested up to: 3.5
7
- Stable tag: 1.0.9
8
 
9
  Uji Countdown - HTML5 Customizable Countdown Timer
10
 
@@ -47,6 +47,10 @@ WPmanage [(http://www.wpmanage.com/uji-countdown/)](http://www.wpmanage.com/uji-
47
 
48
  == Changelog ==
49
 
 
 
 
 
50
  = 1.0.9 =
51
 
52
  * Important Fix: WP 3.5 links bug fix
3
  Donate link: http://wpmanage.com/Uji-countdown
4
  Tags: countdown, counter, html5 countdown, animated countdown, countdown timer, count down, countdown clock, jQuery countdown, clock, timer
5
  Requires at least: 3.0
6
+ Tested up to: 3.5.1
7
+ Stable tag: 1.1
8
 
9
  Uji Countdown - HTML5 Customizable Countdown Timer
10
 
47
 
48
  == Changelog ==
49
 
50
+ = 1.1 =
51
+
52
+ * Fix Chrome bug
53
+
54
  = 1.0.9 =
55
 
56
  * Important Fix: WP 3.5 links bug fix
uji-countdown-add.php CHANGED
@@ -172,38 +172,23 @@ function ujic_add_new(){
172
  <div class="metabox-holder">
173
  <div class="postbox">
174
  <div class="handlediv" title="Click to toggle"><br /></div>
175
- <h3 class="hndle"><span>Add Countdown in Post or Page</span></h3>
176
- <div class="inside">
177
- <img src="<?php echo UJI_PLUGIN_URL. '/images/ujic-ps.jpg'; ?>" />
178
- </div>
179
- </div>
180
- <div class="postbox">
181
- <div class="handlediv" title="Click to toggle"><br /></div>
182
- <h3 class="hndle"><span>Add Countdown From Widgets</span></h3>
183
  <div class="inside">
184
- <img src="<?php echo UJI_PLUGIN_URL. '/images/ujic-ps2.jpg'; ?>" />
185
  </div>
186
  </div>
187
  <div class="postbox">
188
  <div class="handlediv" title="Click to toggle"><br /></div>
189
- <h3 class="hndle"><span>Uji Countdown Premium</span></h3>
190
  <div class="inside">
191
- <a href="http://www.wpmanage.com/uji-countdown" target="_blank"><img src="<?php echo UJI_PLUGIN_URL. '/images/ujic-ps3.png'; ?>" style="padding-left:28px" /></a>
192
  </div>
193
  </div>
194
  <div class="postbox">
195
  <div class="handlediv" title="Click to toggle"><br /></div>
196
- <h3 class="hndle"><span>Support this plugin</span></h3>
197
  <div class="inside">
198
- <div id="donate">
199
- <form action="https://www.paypal.com/cgi-bin/webscr" method="post">
200
- <input type="hidden" name="cmd" value="_s-xclick">
201
- <input type="hidden" name="hosted_button_id" value="BHFJEZ6CFKSAJ">
202
- <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
203
- <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
204
- </form>
205
- </div>
206
- <a href="http://wpmanage.com/Contact-Us" target="_blank" id="hire">HIRE ME &#8250;</a>
207
  </div>
208
  </div>
209
 
172
  <div class="metabox-holder">
173
  <div class="postbox">
174
  <div class="handlediv" title="Click to toggle"><br /></div>
175
+ <h3 class="hndle"><span>Uji Countdown Premium</span></h3>
 
 
 
 
 
 
 
176
  <div class="inside">
177
+ <a href="http://www.wpmanage.com/uji-countdown" target="_blank"><img src="<?php echo UJI_PLUGIN_URL. '/images/ujic-ps3.png'; ?>" style="padding-left:28px" /></a>
178
  </div>
179
  </div>
180
  <div class="postbox">
181
  <div class="handlediv" title="Click to toggle"><br /></div>
182
+ <h3 class="hndle"><span>Add Countdown in Post or Page</span></h3>
183
  <div class="inside">
184
+ <img src="<?php echo UJI_PLUGIN_URL. '/images/ujic-ps.jpg'; ?>" />
185
  </div>
186
  </div>
187
  <div class="postbox">
188
  <div class="handlediv" title="Click to toggle"><br /></div>
189
+ <h3 class="hndle"><span>Add Countdown From Widgets</span></h3>
190
  <div class="inside">
191
+ <img src="<?php echo UJI_PLUGIN_URL. '/images/ujic-ps2.jpg'; ?>" />
 
 
 
 
 
 
 
 
192
  </div>
193
  </div>
194
 
uji-countdown-front.php CHANGED
@@ -20,7 +20,7 @@ function add_ujic_popup(){
20
  <script>
21
  jQuery(function() {
22
  jQuery('#dateujic').datetimepicker({
23
- timeFormat: 'hh:mm',
24
  dateFormat: 'yy/mm/dd'
25
  });
26
  jQuery("#ui-datepicker-div").wrap('<div id="ujicountdownadd" />');
20
  <script>
21
  jQuery(function() {
22
  jQuery('#dateujic').datetimepicker({
23
+ timeFormat: 'HH:mm',
24
  dateFormat: 'yy/mm/dd'
25
  });
26
  jQuery("#ui-datepicker-div").wrap('<div id="ujicountdownadd" />');
uji-countdown.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Uji Countdown
4
  Plugin URI: http://www.wpmanage.com/uji-countdown/
5
  Description: HTML5 Countdown.
6
- Version: 1.0.9
7
  Author: Ujog Raul
8
  Author URI: http://www.wpmanage.com
9
 
@@ -29,7 +29,7 @@ if (!defined('UJI_VERSION_KEY'))
29
  define('UJI_VERSION_KEY', 'UJI_version');
30
 
31
  if (!defined('UJI_VERSION_NUM'))
32
- define('UJI_VERSION_NUM', '1.0.9');
33
 
34
  ///////////////////////////////////DB///////////////////////////////////////
35
 
3
  Plugin Name: Uji Countdown
4
  Plugin URI: http://www.wpmanage.com/uji-countdown/
5
  Description: HTML5 Countdown.
6
+ Version: 1.1
7
  Author: Ujog Raul
8
  Author URI: http://www.wpmanage.com
9
 
29
  define('UJI_VERSION_KEY', 'UJI_version');
30
 
31
  if (!defined('UJI_VERSION_NUM'))
32
+ define('UJI_VERSION_NUM', '1.1');
33
 
34
  ///////////////////////////////////DB///////////////////////////////////////
35