PageSourceSearch

https://klmopen.nl/wp-content/themes/clean-wp-child/assets/js/rolex-core-1.4.2.js?ver=1.4.2

js klmopen.nl collected 2026-10-02 20:05:02 UTC 95,578 bytes, 2,048 lines download raw bytes

1/**
2 * Package: buildClock
3 *
4 * Description:
5 * this file is the javascript to generate the watch.
6 *
7 * Files:
8 *  - rolex-core-1.3.5.js
9 *
10 * License:
11 * Copyright (c) 2012, matchbox France http://www.matchbox.fr
12 * This program is dual licensed under the GNU General Public License
13 * and Simplified BSD license.
14 */
15(function($) {
16    // image folder
17    var imgFolder = "img";
18    if (Modernizr.retina == true) {
19        // TODO
20//        imgFolder = "imgRetina";
21    }
22
23    // get hands images extension
24    var imageExtension = "png";
25    if (Modernizr.svg == true) {
26        imageExtension = "svg";
27    }
28
29    /**
30     * Build clock.
31     * @param {object} options
32     * @returns {undefined}
33     */
34    $.fn.rolexClock = function(options) {
35        // default params
36        var params = {
37            // CONFIGS
38            LANG: 'en', // Language
39            contentWidth: 0, // px Width of the content
40            contentHeight: 0, // px Height of the content
41            flashname: '', // flash filename
42            fallback: '', // image filename
43            trackingurl: '', /* set the tracking url */
44            leadingZeros: false, // Display with leading zero.
45            amPm: false, /* set custom offset if city doesn't exist in the list */
46            time24hours: true, /* show time in 24 hours format with true */
47            showText: true, /* show/hide text and time */
48            showTime: false, /* show time only without city */
49            showDay: false, /* show day of a week */
50            // CLOCKS
51            clockWidth: 0, /* width of the clock to be set on top the html file */
52            clockHeight: 0, /* height of the clock to be set on top the html file */
53            globalXcenter: 0, // center of clock X
54            globalYcenter: 0, // center of clock Y
55            globalXscale: 0, // scale of clock X
56            globalYscale: 0, // scale of clock Y
57            handsFolder: 'css/images/hands/green/', // assets folder
58            watchContainerID: 'clock', // ID of watch container
59            // hands parameters
60            handsParams: {
61                // imagetype SVG
62                svg: {
63                    hour: {width: 8}, minute: {width: 6.5}, second: {width: 5, xrotation: 2.5}
64                },
65                // imagetype PNG
66                png: {
67                    hour: {width: 9}, minute: {width: 6.5}, second: {width: 5, xrotation: 2.5}
68                }
69            },
70            forceFlash: false,
71            blockcontrollerVisible: false,
72            forceFallback: false,
73            clocktimeAtEvent: false, //Tells whether we display the time at the event location, defined in listofdates.js or not (not tested yet)
74            isCountdownClock: false, // Whether it is a countdown. Defaults to false.
75            countdownNumbersOnly: false, // Display only numbers in count
76            onclickCity: function() {
77                // callback here when "city" is clicked
78            },
79            onclickYourtime: function() {
80                // callback here when "your time" is clicked
81            },
82            showDefaultCity: false, // Show the default city if no configurable city is currently active
83            showLocalOnly: false, // Whether we show the local time only. Defaults to false.
84            dateList: undefined, // List of date
85            // COMPETITION
86            isCompetitionWithCarousel: false, // Whether it's a competition. Defaults to false.
87            competitionParams: {// Competition params.
88                interval: 1000, // carousel interval in ms
89                tag: 'div' // tagname used
90            },
91            // CLASSNAME
92            blockClass: 'block', // default block class name
93            activeClass: 'active'// active block class name
94        };
95        // methods
96        var methods = {
97            /**
98             * Activate a block time.
99             * args:
100             * - ID of block
101             */
102            activeBlock: function() {
103                if (typeof arguments[0] === 'string') {
104                    var target = $('.block#' + arguments[0]);
105                    if (target.length > 0) {
106                        target.trigger('click');
107                    }
108                }
109            }
110        }
111        var _competition = {
112            index: -1, // index de départ
113            isAnimationActive: true,
114            timer: undefined, // timer
115            data: [] // event data
116        };
117
118        // options calls
119        if (options && typeof options === 'string' && methods[options]) {
120            return methods[ options ].apply(this, Array.prototype.slice.call(arguments, 1));
121        } else if (options && typeof options === 'object') {
122            params = $.extend({}, params, options);
123        }
124
125        function init() {
126
127            // init default event
128            var defaultEvent;
129            if (params.isCountdownClock) {
130
131                defaultEvent = {
132                    city: 'GMT', // {string} city name
133                    local: 'Your Time', // {string} local text
134                    startDate: "19700101", // {string} start date yyyymmdd
135                    endDate: "99990101",
136                    offset: 0, // {float} Difference to Greenwich time (GMT) in hours. Ex: -4 for NYC, 5.3 for NewDelhi, 5.45 for Katmandu
137                    dst: 0, // {string} Daylight saving time zone
138                    cdtext: 'ROLEX COUNTDOWN', // CD text
139                    cdyear: "1970", // CD year
140                    cdmonth: "11", // CD month
141                    cdday: "29", // CD day
142                    cdhour: "09", // CD hour
143                    cdmin: "00", // CD min
144                };
145
146            } else {
147                defaultEvent = {
148                    city: 'GMT', // {string} city name
149                    local: 'Your Time', // {string} local text
150                    startDate: "19700101", // {string} start date yyyymmdd
151                    endDate: "99990101", // {string} end date yyyymmdd
152                    offset: 0, // {float} Difference to Greenwich time (GMT) in hours. Ex: -4 for NYC, 5.3 for NewDelhi, 5.45 for Katmandu
153                    dst: 0// {string} Daylight saving time zone
154                };
155            }
156
157            // si compet, add new property
158            if (params.isCompetitionWithCarousel) {
159                defaultEvent.competition = {};
160            }
161
162            // Add default event.
163            if (params.dateList === undefined) {
164                params.dateList = [
165                    defaultEvent
166                ];
167            } else {
168                // push a default city
169                params.dateList.push(defaultEvent);
170            }
171        }
172
173        init();
174
175        // if NO-JS, fallback static image is shown by default.
176        // if JS, fallback static image is hidden and grid is shown.
177        function showClock() {
178            $('.ui-loader').hide();
179            $('#fallback').hide();
180            $('.content').show();
181        }
182
183        window.requestAnimFrame = (function() {
184            return  window.requestAnimationFrame ||
185                    window.webkitRequestAnimationFrame ||
186                    window.mozRequestAnimationFrame ||
187                    window.oRequestAnimationFrame ||
188                    window.msRequestAnimationFrame ||
189                    function(callback) {
190                        window.setTimeout(callback, 1000 / 10);
191                    };
192        })();
193
194        var image_folder = params.handsFolder;
195        var all_parts = new Array("hours", "minutes", "seconds", "top_center");//, "minutes", "seconds", "top_center"
196
197        var hours_p = new Array;
198        hours_p["url"] = "hours." + imageExtension + "";
199        hours_p["update_mode"] = "hours_base_12";
200        hours_p["width"] = params.handsParams[imageExtension].hour.width;
201        hours_p["height"] = 64;
202        hours_p["xrotation"] = params.handsParams[imageExtension].hour.width / 2;
203        hours_p["yrotation"] = 52;
204        hours_p["xcenteroffset"] = 0;
205        hours_p["ycenteroffset"] = 0;
206
207        var minutes_p = new Array;
208        minutes_p["url"] = "minutes." + imageExtension + "";
209        minutes_p["update_mode"] = "minutes_base_60";
210        minutes_p["width"] = params.handsParams[imageExtension].minute.width;
211        minutes_p["height"] = 80;
212        minutes_p["xrotation"] = params.handsParams[imageExtension].minute.width / 2;
213        minutes_p["yrotation"] = 64;
214        minutes_p["xcenteroffset"] = 0;
215        minutes_p["ycenteroffset"] = 0;
216
217        var seconds_p = new Array;
218        seconds_p["url"] = "seconds." + imageExtension + "";
219        seconds_p["update_mode"] = "seconds_base_60";
220        seconds_p["width"] = params.handsParams[imageExtension].second.width;
221        seconds_p["height"] = 93;
222        seconds_p["xrotation"] = params.handsParams[imageExtension].second.xrotation;
223        seconds_p["yrotation"] = 72;
224        seconds_p["xcenteroffset"] = -1;
225        seconds_p["ycenteroffset"] = 0;
226        seconds_p["watch_x_center"] = 0;
227        seconds_p["watch_y_center"] = 0;
228
229        var top_center_p = new Array;
230        top_center_p["url"] = "center.png";
231        top_center_p["update_mode"] = "seconds_base_60";
232        top_center_p["width"] = 7;
233        top_center_p["height"] = 7;
234        top_center_p["xcenteroffset"] = -.5;
235        top_center_p["ycenteroffset"] = 0;
236        top_center_p["xrotation"] = top_center_p["width"]/2;
237        top_center_p["yrotation"] = top_center_p["height"]/2;
238        top_center_p["watch_x_center"] = 0;
239        top_center_p["watch_y_center"] = 0;
240
241        var cyclop_mask_p = new Array;
242
243        var global_watch_p = new Array;
244        global_watch_p["rotation_angle"] = 0;
245        global_watch_p["width"] = params.clockWidth;
246        global_watch_p["height"] = params.clockHeight;
247        global_watch_p["xscale"] = params.globalXscale;
248        global_watch_p["yscale"] = params.globalYscale;
249
250        function countProperties(a) {
251            var b = 0;
252            for (var c in a) {
253                if (a.hasOwnProperty(c))
254                    ++b
255            }
256            return b
257        }
258//        function onImageLoaded(a) {
259////            console.log(all_p_to_be_loaded)
260//            all_p_to_be_loaded--;
261//            if (all_p_to_be_loaded == 0) {
262//            }
263//        }
264
265        var partsContainer = document.createElement('div');
266        partsContainer.style.position = "absolute";
267        partsContainer.style.width = "1px";
268        partsContainer.style.height = "1px";
269        partsContainer.style.padding = "0";
270        partsContainer.style.margin = "-2px";
271        partsContainer.style.overflow = "hidden";
272        partsContainer.style.clip = "rect(0, 0, 0, 0)";
273        partsContainer.style.border = "0";
274        document.getElementsByTagName('body')[0].appendChild(partsContainer);
275
276        /* load sprite */
277        var loadSpriteErrors = [];
278        function loadSprite(i, src) {
279//            console.log("i=" + i + "; src=" + src);
280            var deferred = $.Deferred();
281            all_p[i]["image"] = document.createElement('img');
282            all_p[i]["image"].id = "p_" + all_parts[i];
283            all_p[i]["image"].onload = function() {
284                deferred.resolve();
285            };
286            all_p[i]["image"].onerror = function() {
287                loadSpriteErrors.push(src);
288                $('.content').hide();
289                $('.fallback').show();
290            }
291            partsContainer.appendChild(all_p[i]["image"]);
292            all_p[i]["image"].src = src;
293            return deferred.promise();
294        }
295        var all_p = new Array;
296        var all_p_to_be_loaded = all_parts.length;
297        for (i = 0; i < all_parts.length; i++) {
298            all_p[i] = eval(all_parts[i] + "_p");
299        }
300        var loaders = [];
301        for (var i = 0; i < all_parts.length; i++) {
302            if (all_p[i]["url"] != null) {
303                // loads img
304                loaders.push(loadSprite(i, image_folder + all_p[i]["url"]));
305                if (!all_p[i]["fileformat"]) {
306                    all_p[i]["fileformat"] = all_p[i]["url"].substring(all_p[i]["url"].length - 3, all_p[i]["url"].length)
307                }
308            } else {
309                all_p_to_be_loaded--
310            }
311            if (!all_p[i]["xcenteroffset"]) {
312                all_p[i]["xcenteroffset"] = 0
313            }
314            if (!all_p[i]["ycenteroffset"]) {
315                all_p[i]["ycenteroffset"] = 0
316            }
317            if (!all_p[i]["xoriginoffset"]) {
318                all_p[i]["xoriginoffset"] = null
319            }
320            if (!all_p[i]["yoriginoffset"]) {
321                all_p[i]["yoriginoffset"] = null
322            }
323            if (!all_p[i]["xcenter"]) {
324                all_p[i]["xcenter"] = 0
325            }
326            if (!all_p[i]["ycenter"]) {
327                all_p[i]["ycenter"] = 0
328            }
329            if (!all_p[i]["update_mode"]) {
330                all_p[i]["update_mode"] = null
331            }
332            if (!all_p[i]["watch_x_center"]) {
333                all_p[i]["offset_alternate_x_center"] = 0
334            } else {
335                all_p[i]["offset_alternate_x_center"] = global_watch_p[all_p[i]["watch_x_center"]] - global_watch_p["xcenter"]
336            }
337            if (!all_p[i]["watch_y_center"]) {
338                all_p[i]["offset_alternate_y_center"] = -4
339            } else {
340                all_p[i]["offset_alternate_y_center"] = global_watch_p[all_p[i]["watch_y_center"]] 
340- global_watch_p["ycenter"]
341            }
342        }
343
344        /* load simultaneously all sprites */
345        $.when.apply(null, loaders).done(function() {
346            // callback when everything was loaded
347            all_p_to_be_loaded -= loaders.length;// decrement the number of images to load.
348        });
349
350        function f_calculate_additional_vars() {
351            if (GLOBAL_LIGHT_SOURCE != undefined) {
352                TOP_LIGHT_START = GLOBAL_LIGHT_SOURCE - 90;
353                TOP_LIGHT_END = GLOBAL_LIGHT_SOURCE + 90;
354                BOTTOM_LIGHT_START = GLOBAL_LIGHT_SOURCE - 90;
355                BOTTOM_LIGHT_END = GLOBAL_LIGHT_SOURCE + 90;
356                TOP_SHADE_START = GLOBAL_LIGHT_SOURCE + 90;
357                TOP_SHADE_END = GLOBAL_LIGHT_SOURCE - 90;
358                BOTTOM_SHADE_START = GLOBAL_LIGHT_SOURCE + 90;
359                BOTTOM_SHADE_END = GLOBAL_LIGHT_SOURCE - 90;
360                LEFT_LIGHT_START = GLOBAL_LIGHT_SOURCE;
361                LEFT_LIGHT_END = GLOBAL_LIGHT_SOURCE + 180;
362                RIGHT_LIGHT_START = GLOBAL_LIGHT_SOURCE + 180;
363                RIGHT_LIGHT_END = GLOBAL_LIGHT_SOURCE;
364                LEFT_SHADE_START = GLOBAL_LIGHT_SOURCE + 180;
365                LEFT_SHADE_END = GLOBAL_LIGHT_SOURCE;
366                RIGHT_SHADE_START = GLOBAL_LIGHT_SOURCE;
367                RIGHT_SHADE_END = GLOBAL_LIGHT_SOURCE + 180
368            }
369            if (GLOBAL_MIN_ALPHA != undefined) {
370                TOP_LIGHT_MIN = BOTTOM_LIGHT_MIN = TOP_SHADE_MIN = BOTTOM_SHADE_MIN = LEFT_LIGHT_MIN = RIGHT_LIGHT_MIN = LEFT_SHADE_MIN = RIGHT_SHADE_MIN = GLOBAL_MIN_ALPHA
371            }
372            if (GLOBAL_MAX_ALPHA != undefined) {
373                TOP_LIGHT_MAX = BOTTOM_LIGHT_MAX = TOP_SHADE_MAX = BOTTOM_SHADE_MAX = LEFT_LIGHT_MAX = RIGHT_LIGHT_MAX = LEFT_SHADE_MAX = RIGHT_SHADE_MAX = GLOBAL_MAX_ALPHA
374            }
375            while (TOP_LIGHT_START > TOP_LIGHT_END) {
376                TOP_LIGHT_END += 360
377            }
378            while (BOTTOM_LIGHT_START > BOTTOM_LIGHT_END) {
379                BOTTOM_LIGHT_END += 360
380            }
381            while (TOP_SHADE_START > TOP_SHADE_END) {
382                TOP_SHADE_END += 360
383            }
384            while (BOTTOM_SHADE_START > BOTTOM_SHADE_END) {
385                BOTTOM_SHADE_END += 360
386            }
387            while (LEFT_LIGHT_START > LEFT_LIGHT_END) {
388                LEFT_LIGHT_END += 360
389            }
390            while (RIGHT_LIGHT_START > RIGHT_LIGHT_END) {
391                RIGHT_LIGHT_END += 360
392            }
393            while (LEFT_SHADE_START > LEFT_SHADE_END) {
394                LEFT_SHADE_END += 360
395            }
396            while (RIGHT_SHADE_START > RIGHT_SHADE_END) {
397                RIGHT_SHADE_END += 360
398            }
399            while (TOP_LIGHT_END > 360) {
400                TOP_LIGHT_START -= 360;
401                TOP_LIGHT_END -= 360
402            }
403            while (BOTTOM_LIGHT_END > 360) {
404                BOTTOM_LIGHT_START -= 360;
405                BOTTOM_LIGHT_END -= 360
406            }
407            while (TOP_SHADE_END > 360) {
408                TOP_SHADE_START -= 360;
409                TOP_SHADE_END -= 360
410            }
411            while (BOTTOM_SHADE_END > 360) {
412                BOTTOM_SHADE_START -= 360;
413                BOTTOM_SHADE_END -= 360
414            }
415            while (LEFT_LIGHT_END > 360) {
416                LEFT_LIGHT_START -= 360;
417                LEFT_LIGHT_END -= 360
418            }
419            while (RIGHT_LIGHT_END > 360) {
420                RIGHT_LIGHT_START -= 360;
421                RIGHT_LIGHT_END -= 360
422            }
423            while (LEFT_SHADE_END > 360) {
424                LEFT_SHADE_START -= 360;
425                LEFT_SHADE_END -= 360
426            }
427            while (RIGHT_SHADE_END > 360) {
428                RIGHT_SHADE_START -= 360;
429                RIGHT_SHADE_END -= 360
430            }
431            if (TOP_LIGHT_START < TOP_LIGHT_END) {
432                top_light_max_point = (TOP_LIGHT_START + TOP_LIGHT_END) / 2 % 360;
433                top_light_range = TOP_LIGHT_END - TOP_LIGHT_START
434            } else {
435                top_light_max_point = (TOP_LIGHT_START + TOP_LIGHT_END) % 360 / 2;
436                top_light_range = 360 + TOP_LIGHT_END - TOP_LIGHT_START
437            }
438            top_light_mid_range = top_light_range / 2;
439            if (BOTTOM_LIGHT_START < BOTTOM_LIGHT_END) {
440                bottom_light_max_point = (BOTTOM_LIGHT_START + BOTTOM_LIGHT_END) / 2 % 360;
441                bottom_light_range = BOTTOM_LIGHT_END - BOTTOM_LIGHT_START
442            } else {
443                bottom_light_max_point = (BOTTOM_LIGHT_START + BOTTOM_LIGHT_END) % 360 / 2;
444                bottom_light_range = 360 + BOTTOM_LIGHT_END - BOTTOM_LIGHT_START
445            }
446            bottom_light_mid_range = bottom_light_range / 2;
447            if (TOP_SHADE_START < TOP_SHADE_END) {
448                top_shade_max_point = (TOP_SHADE_START + TOP_SHADE_END) / 2 % 360;
449                top_shade_range = TOP_SHADE_END - TOP_SHADE_START
450            } else {
451                top_shade_max_point = (TOP_SHADE_START + TOP_SHADE_END) % 360 / 2;
452                top_shade_range = 360 + TOP_SHADE_END - TOP_SHADE_START
453            }
454            top_shade_mid_range = top_shade_range / 2;
455            if (BOTTOM_SHADE_START < BOTTOM_SHADE_END) {
456                bottom_shade_max_point = (BOTTOM_SHADE_START + BOTTOM_SHADE_END) / 2 % 360;
457                bottom_shade_range = BOTTOM_SHADE_END - BOTTOM_SHADE_START
458            } else {
459                bottom_shade_max_point = (BOTTOM_SHADE_START + BOTTOM_SHADE_END) % 360 / 2;
460                bottom_shade_range = 360 + BOTTOM_SHADE_END - BOTTOM_SHADE_START
461            }
462            bottom_shade_mid_range = bottom_shade_range / 2;
463            if (LEFT_LIGHT_START < LEFT_LIGHT_END) {
464                left_light_max_point = (LEFT_LIGHT_START + LEFT_LIGHT_END) / 2 % 360;
465                left_light_range = LEFT_LIGHT_END - LEFT_LIGHT_START
466            } else {
467                left_light_max_point = (LEFT_LIGHT_START + LEFT_LIGHT_END) % 360 / 2;
468                left_light_range = 360 + LEFT_LIGHT_END - LEFT_LIGHT_START
469            }
470            left_light_mid_range = left_light_range / 2;
471            if (RIGHT_LIGHT_START < RIGHT_LIGHT_END) {
472                right_light_max_point = (RIGHT_LIGHT_START + RIGHT_LIGHT_END) / 2 % 360;
473                right_light_range = RIGHT_LIGHT_END - RIGHT_LIGHT_START
474            } else {
475                right_light_max_point = (RIGHT_LIGHT_START + RIGHT_LIGHT_END) % 360 / 2;
476                right_light_range = 360 + RIGHT_LIGHT_END - RIGHT_LIGHT_START
477            }
478            right_light_mid_range = right_light_range / 2;
479            if (LEFT_SHADE_START < LEFT_SHADE_END) {
480                left_shade_max_point = (LEFT_SHADE_START + LEFT_SHADE_END) / 2 % 360;
481                left_shade_range = LEFT_SHADE_END - LEFT_SHADE_START
482            } else {
483                left_shade_max_point = (LEFT_SHADE_START + LEFT_SHADE_END) % 360 / 2;
484                left_shade_range = 360 + LEFT_SHADE_END - LEFT_SHADE_START
485            }
486            left_shade_mid_range = left_shade_range / 2;
487            if (RIGHT_SHADE_START < RIGHT_SHADE_END) {
488                right_shade_max_point = (RIGHT_SHADE_START + RIGHT_SHADE_END) / 2 % 360;
489                right_shade_range = RIGHT_SHADE_END - RIGHT_SHADE_START
490            } else {
491                right_shade_max_point = (RIGHT_SHADE_START + RIGHT_SHADE_END) % 360 / 2;
492                right_shade_range = 360 + RIGHT_SHADE_END - RIGHT_SHADE_START
493            }
494            right_shade_mid_range = right_shade_range / 2
495        }
496        function getAlphaForRotation(a, b, c) {
497            b = 180 * b / Math.PI + 90;
498            subf_find_distance_to_max_point = function(a) {
499                var c = Math.abs(a - b);
500                if (c > 180) {
501                    c = Math.abs(180 - (c - 180))
502                }
503                return c
504            };
505            var d;
506            if (a == "top_light") {
507                if (c == "reverse") {
508                    this_hand_distance_to_top_light_point = subf_find_distance_to_max_point(-top_light_max_point)
509                } else {
510                    this_hand_distance_to_top_light_point = subf_find_distance_to_max_point(top_light_max_point)
511                }
512                if (this_hand_distance_to_top_light_point <= top_light_mid_range) {
513                    d = TOP_LIGHT_MIN + (1 - this_hand_distance_to_top_light_point / top_light_mid_range) * (TOP_LIGHT_MAX - TOP_LIGHT_MIN)
514                } else {
515                    d = TOP_LIGHT_MIN
516                }
517            } else if (a == "bottom_light") {
518                if (c == "reverse") {
519                    this_hand_distance_to_bottom_light_point = subf_find_distance_to_max_point(-bottom_light_max_point)
520                } else {
521                    this_hand_distance_to_bottom_light_point = subf_find_distance_to_max_point(bottom_light_max_point)
522                }
523                if (180 - this_hand_distance_to_bottom_light_point <= bottom_light_mid_range) {
524                    d = BOTTOM_LIGHT_MIN + (1 - (180 - this_hand_distance_to_bottom_light_point) / bottom_light_mid_range) * (BOTTOM_LIGHT_MAX - BOTTOM_LIGHT_MIN)
525                } else {
526                    d = BOTTOM_LIGHT_MIN
527                }
528            } else if (a == "top_shade") {
529                if (c == "reverse") {
530                    this_hand_distance_to_top_shade_point = subf_find_distance_to_max_point(-top_shade_max_point)
531                } else {
532                    this_hand_distance_to_top_shade_point = subf_find_distance_to_max_point(top_shade_max_point)
533                }
534                if (this_hand_distance_to_top_shade_point <= top_shade_mid_range) {
535                    d = TOP_SHADE_MIN + (1 - this_hand_distance_to_top_shade_point / top_shade_mid_range) * (TOP_SHADE_MAX - TOP_SHADE_MIN)
536                } else {
537                    d = TOP_SHADE_MIN
538                }
539            } else if (a == "bottom_shade") {
540                if (c == "reverse") {
541                    this_hand_distance_to_bottom_shade_point = subf_find_distance_to_max_point(-bottom_shade_max_point)
542                } else {
543                    this_hand_distance_to_bottom_shade_point = subf_find_distance_to_max_point(bottom_shade_max_point)
544                }
545                if (180 - this_hand_distance_to_bottom_shade_point <= bottom_shade_mid_range) {
546                    d = BOTTOM_SHADE_MIN + (1 - (180 - this_hand_distance_to_bottom_shade_point) / bottom_shade_mid_range) * (BOTTOM_SHADE_MAX - BOTTOM_SHADE_MIN)
547                } else {
548                    d = BOTTOM_SHADE_MIN
549                }
550            }
551            if (c == "reverse") {
552                if (a == "left_light") {
553                    this_hand_distance_to_left_light_point = subf_find_distance_to_max_point(-left_light_max_point);
554                    if (this_hand_distance_to_left_light_point <= left_light_mid_range) {
555                        d = LEFT_LIGHT_MIN + (1 - this_hand_distance_to_left_light_point / left_light_mid_range) * (LEFT_LIGHT_MAX - LEFT_LIGHT_MIN)
556                    } else {
557                        d = LEFT_LIGHT_MIN
558                    }
559                } else if (a == "right_light") {
560                    if (this_hand_distance_to_right_light_point <= right_light_mid_range) {
561                        d = RIGHT_LIGHT_MIN + (1 - this_hand_distance_to_right_light_point / right_light_mid_range) * (RIGHT_LIGHT_MAX - RIGHT_LIGHT_MIN)
562                    } else {
563                        d = RIGHT_LIGHT_MIN
564                    }
565                } else if (a == "left_shade") {
566                    this_hand_distance_to_left_shade_point = subf_find_distance_to_max_point(-left_shade_max_point);
567                    if (this_hand_distance_to_left_shade_point <= left_shade_mid_range) {
568                        d = (1 - this_hand_distance_to_left_shade_point / left_shade_mid_range) * (LEFT_SHADE_MAX - LEFT_SHADE_MIN)
569                    } else {
570                        d = LEFT_SHADE_MIN
571                    }
572                } else if (a == "right_shade") {
573                    this_hand_distance_to_right_shade_point = subf_find_distance_to_max_point(-right_shade_max_point);
574                    if (this_hand_distance_to_right_shade_point <= right_shade_mid_range) {
575                        d = (1 - this_hand_distance_to_right_shade_point / right_shade_mid_range) * (RIGHT_SHADE_MAX - RIGHT_SHADE_MIN)
576                    } else {
577                        d = RIGHT_SHADE_MIN
578                    }
579                }
580            } else {
581                if (a == "left_light") {
582                    this_hand_distance_to_left_light_point = subf_find_distance_to_max_point(left_light_max_point);
583                    if (this_hand_distance_to_left_light_point <= left_light_mid_range) {
584                        d = LEFT_LIGHT_MIN + (1 - this_hand_distance_to_left_light_point / left_light_mid_range) * (LEFT_LIGHT_MAX - LEFT_LIGHT_MIN)
585                    } else {
586                        d = LEFT_LIGHT_MIN
587                    }
588                } else if (a == "right_light") {
589                    this_hand_distance_to_right_light_point = subf_find_distance_to_max_point(-right_light_max_point);
590                    this_hand_distance_to_right_light_point = subf_find_distance_to_max_point(right_light_max_point);
591                    if (this_hand_distance_to_right_light_point <= right_light_mid_range) {
592                        d = RIGHT_LIGHT_MIN + (1 - this_hand_distance_to_right_light_point / right_light_mid_range) * (RIGHT_LIGHT_MAX - RIGHT_LIGHT_MIN)
593                    } else {
594                        d = RIGHT_LIGHT_MIN
595                    }
596                } else if (a == "left_shade") {
597                    this_hand_distance_to_left_shade_point = subf_find_distance_to_max_point(left_shade_max_point);
598                    if (this_hand_distance_to_left_shade_point <= left_shade_mid_range) {
599                        d = LEFT_SHADE_MIN + (1 - this_hand_distance_to_left_shade_point / left_shade_mid_range) * (LEFT_SHADE_MAX - LEFT_SHADE_MIN)
600                    } else {
601                        d = LEFT_SHADE_MIN
602                    }
603                } else if (a == "right_shade") {
604                    this_hand_distance_to_right_shade_point = subf_find_distance_to_max_point(right_shade_max_point);
605                    if (this_hand_distance_to_right_shade_point <= right_shade_mid_range) {
606                        d = RIGHT_SHADE_MIN + (1 - this_hand_distance_to_right_shade_point / right_shade_mid_range) * (RIGHT_SHADE_MAX - RIGHT_SHADE_MIN)
607                    } else {
608                        d = RIGHT_SHADE_MIN
609                    }
610                }
611            }
612            return d / 100
613        }
614        var GLOBAL_LIGHT_SOURCE = 360;
615        var GLOBAL_MIN_ALPHA = 0;
616        var GLOBAL_MAX_ALPHA = 100;
617        var TOP_LIGHT_START = 0;
618        var TOP_LIGHT_END = 0;
619        var BOTTOM_LIGHT_START = 0;
620        var BOTTOM_LIGHT_END = 0;
621        var TOP_SHADE_START = 0;
622        var TOP_SHADE_END = 0;
623        var BOTTOM_SHADE_START = 0;
624        var BOTTOM_SHADE_END = 0;
625        var LEFT_LIGHT_START = 0;
626        var LEFT_LIGHT_END = 0;
627        var RIGHT_LIGHT_START = 0;
628        var RIGHT_LIGHT_END = 0;
629        var LEFT_SHADE_START = 0;
630        var LEFT_SHADE_END = 0;
631        var RIGHT_SHADE_START = 0;
632        var RIGHT_SHADE_END = 0;
633        var TOP_LIGHT_MIN = 0;
634        var TOP_LIGHT_MAX = 0;
635        var BOTTOM_LIGHT_MIN = 0;
636        var BOTTOM_LIGHT_MAX = 0;
637        var TOP_SHADE_MIN = 0;
638        var TOP_SHADE_MAX = 0;
639        var BOTTOM_SHADE_MIN = 0;
640        var BOTTOM_SHADE_MAX = 0;
641        var LEFT_LIGHT_MIN = 0;
642        var LEFT_LIGHT_MAX = 0;
643        var RIGHT_LIGHT_MIN = 0;
644        var RIGHT_LIGHT_MAX = 0;
645        var LEFT_SHADE_MIN = 0;
646        var LEFT_SHADE_MAX = 0;
647        var RIGHT_SHADE_MIN = 0;
648        var RIGHT_SHADE_MAX = 0;
649        var top_light_max_point = 0;
650        var top_light_range = 0;
651        var top_light_mid_range = 0;
652        var bottom_light_max_point = 0;
653        var bottom_light_range = 0;
654        var bottom_light_mid_range = 0;
655        var top_shade_max_point = 0;
656        var top_shade_range = 0;
657        var top_shade_mid_range = 0;
658        var bottom_shade_max_point = 0;
659        var bottom_shade_range = 0;
660        var bottom_shade_mid_range = 0;
661        f_calculate_additional_vars();
662        var updated;
663        function getHiddenProp() {
664            var prefixes = ['webkit', 'moz', 'ms', 'o'];
665
666            // if 'hidden' is natively supported just return it
667            if ('hidden' in document)
668                return 'hidden';
669
670            // otherwise loop over all the known prefixes until we find one
671            for (var i = 0; i < prefixes.length; i++) {
672                if ((prefixes[i] + 'Hidden') in document)
673                    return prefixes[i] + 'Hidden';
674            }
675
676            // otherwise it's not supported
677            return null;
678        }
679        function isHidden() {
680            var prop = getHiddenProp();
681            if (!prop)
682                return false;
683
684            return document[prop];
685        }
686        var visProp = getHiddenProp();
687        if (visProp) {
688            var evtname = visProp.replace(/[H|h]idden/, '') + 'visibilitychange';
689            document.addEventListener(evtname, visChange);
690        }
691
692        function visChange() {
693            if (isHidden())
694                updated = false;
695            else
696                updateTime();
697        }
698
699
700// self.onblur = function() { updated = false; }
701// self.onfocus = function() { updateTime() }
702
703        function updateTime() {
704            if (params.isCountdownClock) {
705                if (updated == true) {
706                    current_seconds += 1000 / 10;
707
708                    if (current_seconds >= 60) {
709                        //console.log(current_seconds)
710                        currentTime = new Date;
711                        currentTime.setHours(currentTime.getHours() + hoursOffset);
712                        currentTime.setMinutes(currentTime.getMinutes() + minutesOffset);
713                        currentTime.setSeconds(currentTime.getSeconds() + secondsOffset);
714                        current_hours = currentTime.getHours();
715                        current_minutes = currentTime.getMinutes();
716                        current_seconds = currentTime.getSeconds();
717                        current_milliseconds = currentTime.getMilliseconds();
718                    }
719                    //console.log(currentTime)
720                } else {
721                    currentTime = new Date;
722                    // console.log(current_seconds)
723                    currentTime.setHours(currentTime.getHours() + hoursOffset);
724                    currentTime.setMinutes(currentTime.getMinutes() + minutesOffset);
725                    currentTime.setSeconds(currentTime.getSeconds() + secondsOffset);
726                    monthdate = currentTime.getDate();// n° du jour local: 0..31
727                    weekday_num = currentTime.getDay();// jour de la semaine local: 0=> sun, ..., 6=> sat
728                    current_hours = currentTime.getHours();
729                    current_minutes = currentTime.getMinutes();
730                    current_seconds = currentTime.getSeconds();
731                    current_milliseconds = currentTime.getMilliseconds();
732                    // console.log(current_seconds,currentTime.getMilliseconds())
733                    // console.log(monthdate,weekday_num,current_hours,current_minutes,current_seconds)
734                    updated = true;
735                }
736            } else {
737                currentTime = new Date;
738                currentTime.setHours(currentTime.getHours() + hoursOffset);
739                currentTime.setMinutes(currentTime.getMinutes() + minutesOffset);
740                currentTime.setSeconds(currentTime.getSeconds() + secondsOffset);
741                monthdate = currentTime.getDate();
742                weekday_num = currentTime.getDay();
743                current_seconds = currentTime.getSeconds();
744                current_minutes = currentTime.getMinutes();
745                current_hours = currentTime.getHours();
746                current_milliseconds = currentTime.getMilliseconds();
747            }
748        }
749        function setTimeToDefaultTime() {
750            currentTime = new Date;
751            currentTime.setHours(10);
752            currentTime.setMinutes(11);
753            currentTime.setSeconds(31);
754            monthdate = currentTime.getDate();
755            weekday_num = currentTime.getDay();
756            current_seconds = currentTime.getSeconds();
757            current_minutes = currentTime.getMinutes();
758            current_hours = currentTime.getHours();
759            current_milliseconds = currentTime.getMilliseconds()
760        }
761        function updateTimeCalculations() {
762            var a = current_hours;
763            weekday_num++;
764            if (a > 12) {
765                a -= 12
766            }
767            display_calculation["seconds_base_60"] = current_seconds * timeSlice;
768            display_calculation["seconds_base_60"] += current_milliseconds * timeSlice / 1e3;
769            display_calculation["seconds_base_60"] += rotCorrect;
770            display_calculation["minutes_base_60"] = current_minutes * timeSlice;
771            display_calculation["minutes_base_60"] += current_seconds * timeSlice / 60;
772            display_calculation["minutes_base_60"] += rotCorrect;
773            display_calculation["minutes_base_30"] = current_minutes * timeSlice * 2;
774            display_calculation["minutes_base_30"] += current_seconds * timeSlice * 2 / 60;
775            display_calculation["minutes_base_30"] += rotCorrect;
776            display_calculation["hours_base_12"] = a * timeSlice * 5;
777            display_calculation["hours_base_12"] += current_minutes * timeSlice / 12;
778            display_calculation["hours_base_12"] += rotCorrect;
779            display_calculation["monthdate_base_31"] = monthdate * (timeSlice / 6) * (360 / 31);
780            display_calculation["monthdate_base_31"] += rotCorrect
781        }
782        function easeInOutQuad(a, b, c, d) {
783            if (a < d / 2)
784                return 2 * c * a * a / (d * d) + b;
785            ts = a - d / 2;
786            return -2 * c * ts * ts / (d * d) + 2 * c * ts / d + c / 2 + b
787        }
788        function setHoursOffset(a) {
789            hoursOffset = a
790        }
791        function setMinutesOffset(a) {
792            minutesOffset = a
793        }
794        function setSecondsOffset(a) {
795            secondsOffset = a
796        }
797        function getCurrentShownTime() {
798            var a = "";
799            if (current_hours < 10) {
800                a += "0"
801            }
802            a += current_hours;
803            a += ":";
804            if (current_minutes < 10) {
805                a += "0"
806            }
807            a += current_minutes;
808            return a
809        }
810        function updateOnTimeDisplayOnce() {
811            updateTimeCalculations();
812            updateDisplay()
813        }
814        function updateOnTimeDisplayOvertime() {
815            updateTime();
816            updateOnTimeDisplayOnce();
817            timeoutID = window.setTimeout(updateOnTimeDisplayOvertime, tickDelay)
818        }
819        var ticks_per_seconds = 10;
820        var parts_starting_z_index = 23;
821        var tickDelay = 1e3 / ticks_per_seconds;
822        var timeSlice = Math.PI * 2 / 60;
823        var rotCorrect = global_watch_p["rotation_angle"] * (timeSlice / 6);
824        var display_calculation = new Array;
825        var currentTime = null;
826        var hoursOffset = 0;
827        var minutesOffset = 0;
828        var secondsOffset = 0;
829        var monthdate = null;
830        var weekday_num = null;
831        var current_seconds = null;
832        var current_minutes = null;
833        var current_hours = null;
834        var current_milliseconds = null;
835        var canvasId = 'regular_timepiece_canvas';
836        var watchContainer = params.watchContainerID;
837        var canvasParent = document.getElementById(canvasId);
838        function prepareTimepieceElements() {
839            if (prepareTimepieceElementsIsDone == false) {
840                for (i = 0; i < all_parts.length; i++) {
841                    if (all_p[i]["update_mode"] == "monthdate" || all_p[i]["update_mode"] == "weekday") {
842                        if (all_p[i]["url"] == null) {
843                            var a = document.createElement("DIV")
844                        } else {
845                            var a = document.createElement("CANVAS")
846                        }
847                        document.getElementById(watchContainer).appendChild(a);
848                        if (typeof G_vmlCanvasManager != "undefined") {
849                            a = G_vmlCanvasManager.initElement(a)
850                        }
851                        a.setAttribute("id", all_parts[i] + "_div");
852                        a.style.position = "absolute";
853                        a.style.width = all_p[i]["width"] + "px";
854                        a.style.height = all_p[i]["height"] + "px";
855                        a.style.left = all_p[i]["xoriginoffset"] + "px";
856                        a.style.top = all_p[i]["yoriginoffset"] + "px";
857                        if (all_p[i]["url"] == null) {
858                            a.style.color = "#" + all_p[i]["txt_color"];
859                            a.style.fontSize = all_p[i]["txt_fontSize"];
860                            a.style.fontFamily = "Arial";
861                            a.style.textAlign = "center"
862                        }
863                        parts_starting_z_index += i;
864                        a.style.zIndex = parts_starting_z_index
865                    }
866                }
867                var b = document.createElement("CANVAS");
868                document.getElementById(watchContainer).appendChild(b);
869                if (typeof G_vmlCanvasManager != "undefined") {
870                    b = G_vmlCanvasManager.initElement(b)
871                }
872                b.setAttribute("id", "regular_timepiece_canvas");
873                b.style.position = "absolute";
874                b.setAttribute("width", global_watch_p["width"]);
875                b.setAttribute("height", global_watch_p["height"]);
876                b.style.zIndex = parts_starting_z_index;
877                if (cyclop_mask_p["url"]) {
878                    var b = document.createElement("CANVAS");
879                    document.getElementById(watchContainer).appendChild(b);
880                    if (typeof G_vmlCanvasManager != "undefined") {
881                        b = G_vmlCanvasManager.initElement(b)
882                    }
883                    b.setAttribute("id", "magnified_timepiece_canvas");
884                    b.style.position = "absolute";
885                    b.setAttribute("width", global_watch_p["width"]);
886                    b.setAttribute("height", global_watch_p["height"]);
887                    b.style.zIndex = parts_starting_z_index + 1
888                }
889                prepareTimepieceElementsIsDone = true
890            }
891        }
892        function placeCanvas(a, b, c) {
893            a.clearRect(-global_watch_p["width"], -global_watch_p["height"], global_watch_p["width"] * 2, global_watch_p["height"] * 2);
894            if (b == false) {
895            } else {
896                a.save();
897                if (c) {
898                    a.translate(global_watch_p[c["watch_x_center"]], global_watch_p[c["watch_y_center"]])
899                } else {
900                    a.translate(global_watch_p["xcenter"], global_watch_p["ycenter"])
901                }
902            }
903        }
904        function updateDisplay() {
905            if (cyclop_mask_p["url"]) {
906                var a = document.getElementById(canvasId);
907                var b = a.getContext("2d");
908                placeCanvas(b, true);
909                drawTimepiece(b, true);
910                b.save();
911                b.translate(-global_watch_p["xcenter"], -global_watch_p["ycenter"]);
912                b.globalCompositeOperation = "destination-in";
913                b.drawImage(cyclop_mask_p["image"], 0, 0, cyclop_mask_p["width"], cyclop_mask_p["height"]);
914                b.restore();
915                b.restore()
916            }
917            var a = document.getElementById(canvasId);
918            if (a.getContext) {
919                var b = a.getContext("2d");
920                placeCanvas(b, true);
921                drawTimepiece(b, false);
922                if (cyclop_mask_p["url"]) {
923                    b.save();
924                    b.translate(-global_watch_p["xcenter"], -global_watch_p["ycenter"]);
925                    b.globalCompositeOperation = "destination-out";
926                    b.drawImage(cyclop_mask_p["image"], 0, 0, cyclop_mask_p["width"], cyclop_mask_p["height"]);
927                    b.restore()
928                }
929                b.restore();
930            } else {
931                alert('no context')
932            }
933        }
934        function drawTimepiece(a, b) {
935            magnify_x_offset = 0;
936            magnify_y_offset = 0;
937            magnify_x_scale = 1;
938            magnify_y_scale = 1;
939            if (b == true) {
940                magnify_x_offset = cyclop_mask_p["xcenteroffset"];
941                magnify_y_offset = cyclop_mask_p["ycenteroffset"];
942                magnify_x_scale = cyclop_mask_p["xscale"];
943                magnify_y_scale = cyclop_mask_p["yscale"];
944            }
945            a.globalCompositeOperation = "source-over";
946            for (var i = 0; i < all_parts.length; i++) {
947                var c = all_p[i];
948                a.save();
949                if (all_p[i]["update_mode"] != null) {
950                    if (all_p[i]["update_mode"] == "monthdate") {
951                        if (all_p[i]["url"] == null) {
952                            document.getElementById(all_parts[i] + "_div").innerHTML = monthdate
953                        } else {
954                            document.getElementById(all_parts[i] + "_div").style.background = "url('" + image_folder + "num_" + monthdate + "." + all_p[i]["fileformat"] + "')"
955                        }
956                    } else if (all_p[i]["update_mode"] == "weekday") {
957                        document.getElementById(all_parts[i] + "_div").style.background = "url('" + image_folder + "weekday_" + weekday_num + "." + all_p[i]["fileformat"] + "')"
958                    } else {
959                        a.translate(c["xcenteroffset"], c["ycenteroffset"]);
960                        a.translate(magnify_x_offset, magnify_y_offset);
961                        a.translate(c["offset_alternate_x_center"], c["offset_alternate_y_center"]);
962                        a.scale(global_watch_p["xscale"] * magnify_x_scale, global_watch_p["yscale"] * magnify_y_scale);
963                        a.rotate(display_calculation[c["update_mode"]]);
964                        a.translate(-c["xrotation"], -c["yrotation"]);
965
966//                        var img = c["image"];
967//                        console.log(img, c["width"],c["height"])
968                        var img = document.getElementById("p_" + all_parts[i]);
969//                        console.log("p_" + all_parts[i]);
970//                        canvas = document.getElementById(canvasId)
971//                        ctx = canvas.getContext('2d')                        
972//                        ctx.drawImage(img, 0, 0, c["width"], c["height"]);
973                        a.drawImage(img, 0, 0, c["width"], c["height"]);
974                        for (var d in all_p[i]["__lightEffects"]) {
975                            if (all_p[i]["__lightEffects"][d].height > 0) {
976                                a.globalAlpha = getAlphaForRotation(d, display_calculation[c["update_mode"]], "normal");
977                                a.drawImage(c["__lightEffects"][d], 0, 0, c["width"], c["height"])
978                            }
979                        }
980                    }
981                } else {
982                    a.translate(all_p[i]["xcenteroffset"], all_p[i]["ycenteroffset"]);
983                    a.translate(-all_p[i]["xcenter"], -all_p[i]["ycenter"]);
984                    a.drawImage(all_p[i]["image"], 0, 0, all_p[i]["width"], all_p[i]["height"])
985                }
986                a.restore()
987            }
988        }
989        function startWatchEngineWhenReady() {
990            if (all_p_to_be_loaded < 1) {
991                prepareTimepieceElements();
992//                updateOnTimeDisplayOvertime();
993                window.setTimeout(updateOnTimeDisplayOvertime, 0);
994            } else {
995                requestAnimFrame(startWatchEngineWhenReady);
996            }
997        }
998        function startWatchEngine() {
999//            if (window.addEventListener) {
1000//                window.addEventListener("load", function() {
1001            startWatchEngineWhenReady()
1002//                }, false)
1003//            } else if (window.attachEvent) {
1004//                window.attachEvent("onload", function() {
1005//                    startWatchEngineWhenReady()
1006//                })
1007//            }
1008        }
1009        function showStaticWatchOnTime() {
1010            if (all_p_to_be_loaded < 1) {
1011                prepareTimepieceElements();
1012                setTimeToDefaultTime();
1013                updateOnTimeDisplayOnce()
1014            } else {
1015                timeoutID = window.setTimeout(showStaticWatchOnTime, tickDelay)
1016            }
1017        }
1018        function spinToCurrentTimeAfterDelay(a) {
1019        }
1020        var prepareTimepieceElementsIsDone = false;
1021        var weekday_displayed = false;
1022        var magnify_x_offset = 0;
1023        var magnify_y_offset = 0;
1024
1025        var blockLocal = document.getElementById("yourtime");
1026        var blockCity = document.getElementById("city");
1027
1028        var oldIE;
1029        if ($('html').is('.ie6, .ie7, .ie8, .ie9')) {
1030            oldIE = true;
1031        }
1032
1033        /* vars for countdown  */
1034        var liftoffTime = new Date();
1035        liftoffTime.setDate(liftoffTime.getDate());
1036        var rolexClockCountdownCalc;
1037
1038        function removeElement(id) {
1039            var element = document.getElementById(id);
1040            element.parentNode.removeChild(element);
1041        }
1042
1043        function loadListofdates() {
1044
1045            var language = params.LANG;
1046            var language = language.toLowerCase();
1047            var now_date = new Date();
1048
1049
1050            var year = now_date.getFullYear();
1051            var month = now_date.getMonth() + 1;
1052            var day = now_date.getDate();
1053            if (month < 10) {
1054                month = "0" + month;
1055            }
1056            if (day < 10) {
1057                day = "0" + day;
1058            }
1059
1060            var names = [];
1061            var timezones = [];
1062            var timezone_dst = [];
1063            var timeText = [];
1064
1065            var cdYear = [];
1066            var cdMonth = [];
1067            var cdDay = [];
1068            var cdHour = [];
1069            var cdMin = [];
1070            var ClockRacetext = [];
1071
1072            var todayfull = Number(year + "" + month + "" + day);
1073            var index = null;
1074            for (var i = 0; i < params.dateList.length; i++) {
1075                if (todayfull >= params.dateList[i].startDate && todayfull <= params.dateList[i].endDate) {
1076                    index = i;
1077                    if (language == '' || i == params.dateList.length - 1) {
1078                        names.push(params.dateList[index].city);
1079                        timeText.push(params.dateList[index].local)
1080                    } else {
1081                        names.push(params.dateList[index].city);
1082                        timeText.push(params.dateList[index].local)
1083                    }
1084                    timezones.push(params.dateList[index].offset);
1085                    timezone_dst.push(params.dateList[index].dst);
1086
1087                    if (params.isCountdownClock) {
1088                        cdYear.push(params.dateList[index].cdyear);
1089                        cdMonth.push(params.dateList[index].cdmonth);
1090                        cdDay.push(params.dateList[index].cdday);
1091                        cdHour.push(params.dateList[index].cdhour);
1092                        cdMin.push(params.dateList[index].cdmin)
1093
1094                        ClockRacetext.push(params.dateList[index].cdtext);
1095                    }
1096
1097                    if (params.isCompetitionWithCarousel) {
1098                        _competition.data.push(params.dateList[index]);
1099                    }
1100                }
1101            }
1102
1103            return {
1104                names: names,
1105                timezones: timezones,
1106                timezone_dst: timezone_dst,
1107                timeText: timeText,
1108                cdYear: cdYear,
1109                cdMonth: cdMonth,
1110                cdDay: cdDay,
1111                cdHour: cdHour,
1112                cdMin: cdMin,
1113                ClockRacetext: ClockRacetext
1114            }
1115        }
1116        // Update the competition module
1117        var competitionBlock = document.getElementById('competition');
1118        function updateCompetition() {
1119
1120            if (_competition.isAnimationActive) { // si animation toujours active, on rappel
1121                var index = _competition.index >
1121= (_competition.data.length - 2) ? 0 : _competition.index + 1;// -2 because of default element GMT.
1122                // pour chaque propriete, on update crée les éléments
1123                var cur = _competition.data[index];// si le suivant existe
1124                if (cur) {
1125                    _competition.index = index;
1126                    // removing any child nodes
1127                    while (competitionBlock.lastChild) {
1128                        competitionBlock.removeChild(competitionBlock.lastChild);
1129                    }
1130                    // update texts
1131//                    console.log(cur);
1132                    var c = cur.competition;
1133                    for (var n in c) {
1134                        var e = document.createElement(params.competitionParams.tag);
1135                        e.className = 'competition-' + n;
1136                        e.innerHTML = c[n];
1137                        competitionBlock.appendChild(e);
1138                    }
1139
1140                    updateClock(cur);
1141                    updateAllTextBlock();
1142
1143                    _competition.timer = window.setTimeout(updateCompetition, params.competitionParams.interval);
1144                }
1145            }
1146
1147        }
1148        // Activate/Desactivate animation. Defaults to FALSE.
1149        function activateCompetition(flag) {
1150            flag = (typeof flag == 'boolean') ? flag : false;
1151            _competition.isAnimationActive = flag;
1152        }
1153        // Update clock
1154        function updateClock(data) {
1155
1156            params.theLocalText = data.timeText[params.LANG];
1157            params.theCityText = data.city[params.LANG];
1158            params.customOffset = data.timezone;
1159            params.theCity = ((data.city[params.LANG]).toLowerCase()).trim();
1160            params.customDST = data.dst;
1161            if ($(blockCity).hasClass(params.activeClass))
1162                showTimeIn('city', params.theCity, params.customOffset, params.customDST);
1163        }
1164        // update texts for each block
1165        function updateAllTextBlock() {
1166            // update all text block
1167            document.getElementById("cityText").innerHTML = params.theCityText;
1168            document.getElementById("localtext").innerHTML = params.theLocalText;
1169            document.getElementById("city-link").title = params.theCityText.replace('"', '&quot;');
1170            document.getElementById("local-link").title = params.theLocalText.replace('"', '&quot;');
1171            document.getElementById("city-link").href = '#' + params.theCityText.replace('"', '&quot;').replace(' ', '_');
1172            document.getElementById("local-link").href = '#' + params.theLocalText.replace('"', '&quot;').replace(' ', '_');
1173        }
1174
1175        // Set times to clock
1176        var _cityParam = {
1177            tempOffset: 0,
1178            cityOffset: 0
1179        }
1180        function showTimeIn(selectorID, cityname, offset, timezone, cdYear, cdMonth, cdDay, cdHour, cdMin) {
1181            if (params.isCountdownClock) {
1182                if (cityname !== '') {
1183                    var now = new Date;
1184                    var tempOffset = now.getTimezoneOffset();
1185                    tempOffset += 60 * offset;
1186                    var gettimezoneDST = getDST(new Date(), timezone);
1187                    if (gettimezoneDST == 100) {
1188                        // Si heure
1189                        tempOffset += 60;// on ajoute 1h du DST
1190                    }
1191
1192                    if (params.clocktimeAtEvent) {
1193                        // si fuseau horaire local est en DST, on ajoute 1h
1194                        var dstMinutes = now.dst() ? 60 : 0;
1195                        rolexClockCountdown = new Date(cdYear, parseInt(cdMonth) - 1, cdDay, parseInt(cdHour), parseInt(cdMin) + dstMinutes);
1196                        _cityParam.tempOffset = tempOffset;
1197                        _cityParam.cityOffset = offset;
1198                        cityTime();
1199                        rolexClockCountdownCalc = foreignToLocal(rolexClockCountdown, offset * 100, timezone);
1200                        setMinutesOffset(_cityParam.tempOffset); // Correct to time at event location
1201                    } else {
1202                        // on test la date de l'event du visiteur
1203                        var event = foreignToLocal(new Date(cdYear, parseInt(cdMonth) - 1, cdDay, parseInt(cdHour), parseInt(cdMin)), offset * 100, timezone);
1204                        // on retient la difference entre l'offset courant et le std offset à la date de l'event
1205                        var dstMinutes = now.dst() && !event.dst() ? -60 :
1206                                !now.dst() && event.dst() ? -60 : 0;
1207                        _cityParam.tempOffset = tempOffset;
1208                        _cityParam.cityOffset = offset;
1209                        cityTime();
1210                        // on recupere le bon countdown
1211                        rolexClockCountdownCalc = foreignToLocal(new Date(cdYear, parseInt(cdMonth) - 1, cdDay, parseInt(cdHour), parseInt(cdMin) + dstMinutes), offset * 100, timezone);
1212                        //setMinutesOffset(tempOffset);
1213                        setMinutesOffset(_cityParam.tempOffset);
1214                    }
1215                }
1216            } else {
1217                // Autres...
1218                var now = new Date;
1219                var tempOffset = now.getTimezoneOffset();
1220//                var today = b.getFullYear() + "-" + b.getMonth() + "-" + b.getDate() + "-" + b.getHours();
1221                if (params.theCityText !== '') {
1222                    if (cityname) {
1223                        tempOffset += 60 * offset;
1224                        var gettimezoneDST = getDST(new Date(), timezone);
1225                        if (gettimezoneDST == 100) {
1226                            tempOffset += 60;
1227                        }
1228                        setMinutesOffset(tempOffset);
1229                        _cityParam.tempOffset = tempOffset;
1230                        _cityParam.cityOffset = offset;
1231                        cityTime();
1232                    }
1233                }
1234            }
1235        }
1236
1237        /* yourTime text clock */
1238        function yourTime() {
1239            var a = new Date;
1240            a.setHours(a.getHours());
1241            a.setMinutes(a.getMinutes());
1242            a.setSeconds(a.getSeconds());
1243            var b = a.getSeconds();
1244            var c = a.getMinutes();
1245            var d = a.getHours();
1246            var e = a.getDay();
1247            if (params.LANG === 'en') {
1248                if (e == 0) {
1249                    var f = "Sun"
1250                } else if (e == 1) {
1251                    var f = "Mon"
1252                } else if (e == 2) {
1253                    var f = "Tue"
1254                } else if (e == 3) {
1255                    var f = "Wed"
1256                } else if (e == 4) {
1257                    var f = "Thu"
1258                } else if (e == 5) {
1259                    var f = "Fri"
1260                } else if (e == 6) {
1261                    var f = "Sat"
1262                }
1263            } else if (params.LANG === 'fr') {
1264                if (e == 0) {
1265                    var f = "Dim"
1266                } else if (e == 1) {
1267                    var f = "Lun"
1268                } else if (e == 2) {
1269                    var f = "Mar"
1270                } else if (e == 3) {
1271                    var f = "Mer"
1272                } else if (e == 4) {
1273                    var f = "Jeu"
1274                } else if (e == 5) {
1275                    var f = "Ven"
1276                } else if (e == 6) {
1277                    var f = "Sam"
1278                }
1279            }
1280            
1281            if (params.amPm == true) {
1282                var g = " ";
1283                if (d >= 12) {
1284                    g = " PM"
1285                } else {
1286                    g = " AM"
1287                }
1288            } else {
1289                g = ""
1290            }
1291            if (params.time24hours == true) {
1292                g = ""
1293            } else {
1294                if (d >= 13) {
1295                    d -= 12
1296                } else if (d == 0) {
1297                    d = 12
1298                }
1299            }
1300            if (params.leadingZeros == true) {
1301                if (d < 10) {
1302                    d = "0" + d
1303                }
1304            }
1305            if (params.leadingZeros == false && params.time24hours == true) {
1306                if (d < 10) {
1307                    d = "0" + d
1308                }
1309            }
1310            if (c < 10)
1311                c = "0" + c;
1312
1313            if (params.showText == true) {
1314                if (params.showDay == true) {
1315                    f = f;
1316                } else {
1317                    f = "";
1318                }
1319                if (!params.showTime) {
1320                    update = document.getElementById("rolexClockYourTime").innerHTML = f + " " + d + ":" + c + "" + g;
1321                }
1322            }
1323        }
1324        function cityTime() {
1325            var cityTime = new Date();
1326//            console.log(_cityParam.cityOffset , _cityParam.tempOffset)
1327            cityTime.setHours(cityTime.getHours());
1328            cityTime.setMinutes(cityTime.getMinutes() + _cityParam.tempOffset);
1329            cityTime.setSeconds(cityTime.getSeconds());
1330            var cityTime_millisecondes = cityTime.getMilliseconds();
1331            var cityTime_seconds = cityTime.getSeconds();
1332            var cityTime_minutes = cityTime.getMinutes();
1333            var cityTime_hours = cityTime.getHours();
1334            var cityTime_day = cityTime.getDay();
1335            if (params.LANG === 'en') {
1336                if (cityTime_day == 0) {
1337                    var f = "Sun"
1338                } else if (cityTime_day == 1) {
1339                    var f = "Mon"
1340                } else if (cityTime_day == 2) {
1341                    var f = "Tue"
1342                } else if (cityTime_day == 3) {
1343                    var f = "Wed"
1344                } else if (cityTime_day == 4) {
1345                    var f = "Thu"
1346                } else if (cityTime_day == 5) {
1347                    var f = "Fri"
1348                } else if (cityTime_day == 6) {
1349                    var f = "Sat"
1350                }
1351            } else if (params.LANG === 'fr') {
1352                if (cityTime_day == 0) {
1353                    var f = "Dim"
1354                } else if (cityTime_day == 1) {
1355                    var f = "Lun"
1356                } else if (cityTime_day == 2) {
1357                    var f = "Mar"
1358                } else if (cityTime_day == 3) {
1359                    var f = "Mer"
1360                } else if (cityTime_day == 4) {
1361                    var f = "Jeu"
1362                } else if (cityTime_day == 5) {
1363                    var f = "Ven"
1364                } else if (cityTime_day == 6) {
1365                    var f = "Sam"
1366                }
1367            }
1368            // console.log(cityTime_hours)
1369            if (params.amPm == true) {
1370                var g = " ";
1371                if (cityTime_hours >= 12) {
1372                    g = " PM"
1373                } else {
1374                    g = " AM"
1375                }
1376            } else {
1377                g = ""
1378            }
1379            if (params.time24hours == true) {
1380                g = ""
1381            } else {
1382                if (cityTime_hours >= 13) {
1383                    cityTime_hours -= 12
1384                } else if (cityTime_hours == 0) {
1385                    cityTime_hours = 12
1386                }
1387            }
1388            if (params.leadingZeros == true) {
1389                if (cityTime_hours < 10) {
1390                    cityTime_hours = "0" + cityTime_hours
1391                }
1392            }
1393            if (params.leadingZeros == false && params.time24hours == true) {
1394                if (cityTime_hours < 10) {
1395                    cityTime_hours = "0" + cityTime_hours
1396                }
1397            }
1398            if (cityTime_minutes < 10)
1399                cityTime_minutes = "0" + cityTime_minutes;
1400
1401            if (params.showText == true) {
1402                if (params.showDay == true) {
1403                    f = f;
1404                } else {
1405                    f = "";
1406                }
1407            }
1408
1409            if (cityTime_seconds >= 0 && cityTime_seconds < 1) {
1410                update = document.getElementById("rolexClockCityTime").innerHTML = f + " " + cityTime_hours + ":" + cityTime_minutes + "" + g;
1411
1412            } else {
1413                if (checked === undefined && params.showTime == false) {
1414                    update = document.getElementById("rolexClockCityTime").innerHTML = f + " " + cityTime_hours + ":" + cityTime_minutes + "" + g;
1415                    var checked = 1;
1416                }
1417
1418            }
1419        }
1420        function getSeconds() {
1421            var now = new Date;
1422            var theSeconds = now.getSeconds()
1423            if (theSeconds === 0) {
1424                    requestAnimFrame(roundTime);
1425            }
1426        }
1427        setInterval(function() {
1428            getSeconds()
1429        },1000)
1430        function roundTime() {
1431            cityTime();
1432            yourTime();
1433        }
1434
1435        function getOffsetBase10(offset) {
1436//            console.log(typeof offset)
1437            var hours = parseInt(offset); // +/- N
1438            var decimal = offset - hours; // 0.xx
1439            var newDecimal = decimal / .60;
1440//            console.log(hours, decimal, newDecimal, hours + newDecimal);
1441            return hours + newDecimal;
1442        }
1443
1444
1445        var flashMode = false;
1446        /**
1447         * Build the clock.
1448         * @param {object} options Options or method name
1449         * @returns {unresolved}
1450         */
1451        function buildClock() {
1452            $('body').addClass(params.LANG);
1453
1454            $('.image-fallback').attr('src', 'img/' + params.fallback);
1455
1456            var container = document.getElementById("rolexClockWim-container");
1457
1458            if (Modernizr.retina == true) {
1459//                global_watch_p["xscale"] = params.retinaXscale;
1460//                global_watch_p["yscale"] = params.retinaYscale;
1461            }
1462
1463            var blockLocal = document.getElementById("local");
1464            var blockCity = document.getElementById("city");
1465
1466            // render view
1467            function changeBg(bg) {
1468                if (params.isCountdownClock) {
1469                    if (bg == 'full') {
1470                        // When Countdown is present
1471                        //document.getElementById("rolexClockWim-container").style.background = "#fff url(''" + imgFolder + "/bg.jpg') no-repeat";
1472                        global_watch_p["xcenter"] = params.globalXcenter;
1473                        global_watch_p["ycenter"] = params.globalYcenter;
1474//                        blockCity.style.display = "block";
1475                        if (Modernizr.retina == true) {
1476                            //document.getElementById("rolexClockWim-container").style.background = "transparent url('" + imgFolder + "/bg.jpg') no-repeat";
1477                            //document.getElementById("rolexClockWim-container").style.backgroundSize = "auto 100%";
1478                        }
1479                    } else {
1480
1481                        //document.getElementById("rolexClockWim-container").style.background = "transparent url('" + imgFolder + "/bg.jpg') no-repeat";
1482                        global_watch_p["xcenter"] = params.globalXcenter;
1483                        global_watch_p["ycenter"] = params.globalYcenter;
1484//                        blockCity.style.display = "block";
1485                        if (Modernizr.retina == true) {
1486                            //document.getElementById("rolexClockWim-container").style.background = "transparent url('" + imgFolder + "/bg.jpg') no-repeat";
1487                            //document.getElementById("rolexClockWim-container").style.backgroundSize = "auto 100%";
1488
1489                        }
1490
1491                    }
1492                } else {
1493                    global_watch_p["xscale"] = params.globalXscale;
1494                    global_watch_p["yscale"] = params.globalYscale;
1495                    global_watch_p["xcenter"] = params.globalXcenter;
1496                    global_watch_p["ycenter"] = params.globalYcenter;
1497                    if (bg == 'full') {
1498                        //document.getElementById("rolexClockWim-container").style.background = "#fff url(''" + imgFolder + "/bg.jpg') no-repeat";
1499//                        blockCity.style.display = "block";
1500//                        blockLocal.style.display = "block";
1501                        if (Modernizr.retina == true) {
1502                            //document.getElementById("rolexClockWim-container").style.background = "transparent url('" + imgFolder + "/bg.jpg') no-repeat";
1503                            //document.getElementById("rolexClockWim-container").style.backgroundSize = "auto 100%";
1504                        }
1505                    } else {
1506                        //document.getElementById("rolexClockWim-container").style.background = "transparent url('" + imgFolder + "/bg.jpg') no-repeat";
1507                        blockLocal.style.display = "none";
1508                        blockCity.style.display = "none";
1509                        if (Modernizr.retina == true) {
1510                            //document.getElementById("rolexClockWim
1510-container").style.background = "transparent url('" + imgFolder + "/bg.jpg') no-repeat";
1511                            //document.getElementById("rolexClockWim-container").style.backgroundSize = "auto 100%";
1512
1513                        }
1514                    }
1515                }
1516
1517            }
1518
1519            if (!params.forceFallback && !params.forceFlash && Modernizr.canvas == true && document.compatMode != 'Quirks' && oldIE != true) {
1520                // Canvas can be used                
1521                $('.fallback').remove();
1522                $('.tracker').attr('href', params.trackingurl);
1523
1524                if (!params.showText) {
1525                    $(blockCity).hide();
1526                    $(blockLocal).hide();
1527                    changeBg('full');
1528                } else {
1529
1530                    var e = loadListofdates();
1531//                    console.log(e);
1532//                    console.log(_competition);
1533                    var names = e.names,
1534                            timezones = e.timezones,
1535                            timezone_dst = e.timezone_dst,
1536                            timeText = e.timeText;
1537                    var cdYear = e.cdYear,
1538                            cdMonth = e.cdMonth,
1539                            cdDay = e.cdDay,
1540                            cdHour = e.cdHour,
1541                            cdMin = e.cdMin,
1542                            ClockRacetext = e.ClockRacetext;
1543
1544                    if (names.length > 0) {
1545
1546                        if (params.isCountdownClock) {
1547                            rolexClockRacetext = ClockRacetext[0];
1548                            $('#racetext').html(rolexClockRacetext);
1549                        }
1550                        changeBg('full');
1551
1552                        // Sets all string to text for each block
1553                        if (params.isCompetitionWithCarousel) {
1554                            // compet.
1555                            if (names.length > 1) {
1556                                updateCompetition();
1557                            } else {
1558                                // fallback
1559                                $('.ui-loader').hide();
1560                                $('.fallback').show();
1561                                return;
1562                            }
1563                        } else {
1564                            params.theLocalText = timeText[0];
1565                            params.theCityText = names[0];
1566                            params.customOffset = getOffsetBase10(timezones[0]);
1567                            params.theCity = (names[0].toLowerCase()).trim();
1568                            params.customDST = timezone_dst[0];
1569                        }
1570
1571                        updateAllTextBlock();
1572
1573                    } else {
1574                        // si aucun actif
1575                        if (params.isCompetitionWithCarousel) {
1576                            // compet.
1577                            competitionBlock.style.display = 'none';
1578                        } else if (params.isCountdownClock) {
1579
1580                            document.getElementById("cityText").innerHTML = '&nbsp;';
1581                            document.getElementById("localtext").innerHTML = '&nbsp;';
1582                            document.getElementById("city-link").title = '&nbsp;';
1583                            document.getElementById("local-link").title = '&nbsp;';
1584                            document.getElementById("city-link").href = '#';
1585                            document.getElementById("local-link").href = '#';
1586                        } else {
1587
1588                            changeBg();
1589                            if (params.showTime == true) {
1590                                document.getElementById("block-control").removeChild(blockCity);
1591                                document.getElementById("block-control").removeChild(blockLocal);
1592                            } else {
1593                                document.getElementById("cityText").innerHTML = params.theCityText;
1594                                document.getElementById("localtext").innerHTML = params.theLocalText;
1595                                document.getElementById("city-link").title = params.theCityText.replace('"', '&quot;');
1596                                document.getElementById("local-link").title = params.theLocalText.replace('"', '&quot;');
1597                                document.getElementById("city-link").href = '#' + params.theCityText.replace('"', '&quot;').replace(' ', '_');
1598                                document.getElementById("local-link").href = '#' + params.theLocalText.replace('"', '&quot;').replace(' ', '_');
1599                            }
1600                        }
1601                    }
1602
1603
1604                    var thenewOffset,
1605                            customOffset,
1606                            elem;
1607
1608                    blockLocal.onclick = function() {
1609
1610                        $('.' + params.blockClass + '.' + params.activeClass).removeClass(params.activeClass);
1611                        $(this).addClass(params.activeClass);
1612
1613                        showCurrentTime();
1614
1615                        // callback
1616                        return params.onclickYourtime();
1617                    };
1618                    blockCity.onclick = function() {
1619
1620                        $('.' + params.blockClass + '.' + params.activeClass).removeClass(params.activeClass);
1621                        $(this).addClass(params.activeClass);
1622
1623                        showTimeIn('city', params.theCity, params.customOffset, params.customDST, cdYear, cdMonth, cdDay, cdHour, cdMin);
1624
1625                        // callback
1626                        return params.onclickCity();
1627                    };
1628
1629                    function updateShownTimeInHTMLComponentOvertime() {
1630                        updateShownTimeInHTMLComponent();
1631                        // timeoutID = window.setTimeout("updateShownTimeInHTMLComponentOvertime()", 100)
1632                        requestAnimFrame(updateShownTimeInHTMLComponentOvertime());
1633                    }
1634
1635                    function showCurrentTime() {
1636                        setMinutesOffset(0)
1637                    }
1638
1639                    function updateShownTimeInHTMLComponent() {
1640                        tempString = getCurrentShownTime()
1641                    }
1642                    if (params.theCity != '') {
1643
1644                        if (params.isCountdownClock) {
1645                            //cdYear, cdMonth, cdDay, cdHour, cdMin are Arrays! There's still a default datetime, which is always the last index.
1646                            showTimeIn('city', params.theCity, params.customOffset, params.customDST, cdYear[0], cdMonth[0], cdDay[0], cdHour[0], cdMin[0]);
1647                            // start countdown
1648                            startCountdownPlugin(rolexClockLanguage, rolexClockCountdownCalc);
1649                        } else {
1650
1651                            showTimeIn('city', params.theCity, params.customOffset, params.customDST);
1652                        }
1653                    }
1654
1655                    if (params.showLocalOnly) {
1656                        showCurrentTime();
1657                    }
1658                    roundTime();
1659                }
1660
1661                startWatchEngine();
1662
1663                showClock();
1664
1665
1666            } else {
1667                // fallback
1668                $('.ui-loader').hide();
1669                $('.tracker').attr('href', params.trackingurl);
1670                $('.content').remove();
1671                $('.fallback').show();
1672            }
1673        }
1674
1675
1676        /**
1677         * Callback function called when countdown has expired
1678         * @returns {undefined}
1679         */
1680        function expiration() {
1681            // add class for triggering styles without CD
1682            $('.container').addClass('end-countdown');
1683            params.showLocalOnly = false;
1684            $('.block-city a').click();
1685        }
1686
1687        /**
1688         * Start countdown plugin.
1689         * @param {string} lang The language (ex: "en")
1690         * @returns {undefined}
1691         */
1692        function startCountdownPlugin(lang, expirationTime)
1693        {
1694
1695            if (params.LANG == "fr") {
1696                $.countdown.regional['fr'] = {
1697                    labels: ['Années','Mois','Semaines','Jours','Heures','Mins','Secs'],
1698                    labels1: ['Année','Mois','Semaine','Jour','Heure','Min','Sec'],
1699                    compactLabels: ['a','m','s','j'],
1700                    whichLabels: function(amount) {
1701                        return (amount > 1 ? 0 : 1);
1702                    },
1703                    digits: ['0','1','2','3','4','5','6','7','8','9'],
1704                    timeSeparator: ':',
1705                    isRTL: false
1706                };
1707                $.countdown.setDefaults($.countdown.regional['fr']);
1708            } else if (params.LANG == "zhs") {
1709                $.countdown.regional['zhs'] = {
1710                    labels: ['年','月','周','天','时','分','秒'],
1711                    labels1: ['年','月','周','天','时','分','秒'],
1712                    compactLabels: ['年','月','周','天'],
1713                    compactLabels1: ['年','月','周','天'],
1714                    whichLabels: null,
1715                    digits: ['0','1','2','3','4','5','6','7','8','9'],
1716                    timeSeparator: ':',
1717                    isRTL: false
1718                };
1719                $.countdown.setDefaults($.countdown.regional['zhs']);
1720            } else if (params.LANG == "ja") {
1721                $.countdown.regional['ja'] = {
1722                    labels: ['年','月','週','日','時','分','秒'],
1723                    labels1: ['年','月','週','日','時','分','秒'],
1724                    compactLabels: ['年','月','週','日'],
1725                    whichLabels: null,
1726                    digits: ['0','1','2','3','4','5','6','7','8','9'],
1727                    timeSeparator: ':',
1728                    isRTL: false};
1729                $.countdown.setDefaults($.countdown.regional['ja']);
1730
1731            } else if (params.LANG == "de") {
1732                $.countdown.regional['de'] = {
1733                    labels: ['Jahre', 'Monate', 'Wochen', 'Tage', 'Stunden', 'Min', 'Sek'],
1734                    labels1: ['Jahr', 'Monat', 'Woche', 'Tag', 'Stunde', 'Min', 'Sek'],
1735                    compactLabels: ['J', 'M', 'W', 'T'],
1736                    whichLabels: null,
1737                    digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
1738                    timeSeparator: ':', isRTL: false};
1739                $.countdown.setDefaults($.countdown.regional['de']);
1740            } else if (params.LANG == "br") {
1741                $.countdown.regional['br'] = {
1742                    labels: ['Anos','Meses','Semanas','Dias','Horas','Mins','Segs'],
1743                    labels1: ['Ano','Mês','Semana','Dia','Hora','Min','Seg'],
1744                    compactLabels: ['a','m','s','d'],
1745                    whichLabels: null,
1746                    digits: ['0','1','2','3','4','5','6','7','8','9'],
1747                    timeSeparator: ':',
1748                    isRTL: false};
1749                $.countdown.setDefaults($.countdown.regional['bra']);
1750            } else if (params.LANG == "es") {
1751                $.countdown.regional['es'] = {
1752                    labels: ['Años','Meses','Semanas','Días','Horas','Mins','Segs'],
1753                    labels1: ['Año','Mes','Semana','Día','Hora','Min','Seg'],
1754                    compactLabels: ['a','m','s','d'],
1755                    whichLabels: null,
1756                    digits: ['0','1','2','3','4','5','6','7','8','9'],
1757                    timeSeparator: ':',
1758                    isRTL: false};
1759                $.countdown.setDefaults($.countdown.regional['es']);
1760            } else if (params.LANG == "it") {
1761                $.countdown.regional['it'] = {
1762                    labels: ['Anni','Mesi','Settimane','Giorni','Ore','Min','Sec'],
1763                    labels1: ['Anno','Mese','Settimana','Giorno','Ora','Min','Sec'],
1764                    compactLabels: ['a','m','s','g'],
1765                    whichLabels: null,
1766                    digits: ['0','1','2','3','4','5','6','7','8','9'],
1767                    timeSeparator: ':',
1768                    isRTL: false};
1769                $.countdown.setDefaults($.countdown.regional['it']);
1770            } else if (params.LANG == "ru") {
1771                $.countdown.regional['ru'] = {
1772                    labels: ['Лет','Месяцев','Недель','Дней','Часов','Минут','Секунд'],
1773                    labels1: ['Год','Месяц','Неделя','День','Час','Минута','Секунда'],
1774                    labels2: ['Года','Месяца','Недели','Дня','Часа','Минуты','Секунды'],
1775                    compactLabels: ['л','м','н','д'],
1776                    compactLabels1: ['г','м','н','д'],
1777                    whichLabels: function(amount) {
1778                        var units = amount % 10;
1779                        var tens = Math.floor((amount % 100) / 10);
1780                        return (amount === 1 ? 1 : (units >= 2 && units <= 4 && tens !== 1 ? 2 :
1781                            (units === 1 && tens !== 1 ? 1 : 0)));
1782                    },
1783                    digits: ['0','1','2','3','4','5','6','7','8','9'],
1784                    timeSeparator: ':',
1785                    isRTL: false};
1786                $.countdown.setDefaults($.countdown.regional['ru']);
1787            } else if (params.LANG == "sv") {
1788                $.countdown.regional['sv'] = {
1789                    labels: ['År','Månader','Veckor','Dagar','Timmar','Min','Sek'],
1790                    labels1: ['År','Månad','Vecka','Dag','Timme','Min','Sek'],
1791                    compactLabels: ['Å','M','V','D'],
1792                    whichLabels: null,
1793                    digits: ['0','1','2','3','4','5','6','7','8','9'],
1794                    timeSeparator: ':',
1795                    isRTL: false};
1796                $.countdown.setDefaults($.countdown.regional['sv']);
1797            } else if (params.LANG == "zh-TW") {
1798                $.countdown.regional['zh-TW'] = {
1799                    labels: ['年','月','周','天','時','分','秒'],
1800                    labels1: ['年','月','周','天','時','分','秒'],
1801                    compactLabels: ['年','月','周','天'],
1802                    compactLabels1: ['年','月','周','天'],
1803                    whichLabels: null,
1804                    digits: ['0','1','2','3','4','5','6','7','8','9'],
1805                    timeSeparator: ':',
1806                    isRTL: false};
1807                $.countdown.setDefaults($.countdown.regional['zh-TW']);
1808            } else if (params.LANG == "ar") {
1809                $.countdown.regional['ar'] = {
1810                    labels: ['سنوات','أشهر','أسابيع','أيام','ساعات','دقائق','ثواني'],
1811                    labels1: ['سنة','شهر','أسبوع','يوم','ساعة','دقيقة','ثانية'],
1812                    compactLabels: ['س','ش','أ','ي'],
1813                    whichLabels: null,
1814                    digits: ['Ù ','Ù¡','Ù¢','Ù£','Ù¤','Ù¥','Ù¦','Ù§','Ù¨','Ù©'],
1815                    timeSeparator: ':',
1816                    isRTL: true};
1817                $.countdown.setDefaults($.countdown.regional['ar']);
1818            }
1819            else {
1820
1821            }
1822            // console.log(expirationTime)
1823            if (expirationTime !== undefined) {
1824                $('.container').addClass('has-countdown').removeClass('no-countdown');
1825                var ctdays = '';
1826                var cthours = '';
1827                var ctmins = '';
1828                var ctsecs = '';
1829                var tpl = '';
1830                var tpl2 = '';
1831                // $('.days').countdown({
1832                //     until: expirationTime,
1833                //     significant: 0,
1834                //     format: 'DHMS',
1835                //     alwaysExpire: true,
1836                //     layout: ctdays});
1837                // $('.hours').countdown({
1838                //     until: expirationTime,
1839                //     significant: 0,
1840                //     format: 'DHMS',
1841                //     alwaysExpire: true,
1842                //     layout: cthours});
1843                // $('.mins').countdown({
1844                //     until: expirationTime,
1845                //     significant: 0,
1846                //     format: 'DHMS',
1847                //     alwaysExpire: true,
1848                //     layout: ctmins});
1849                // $('.secs').countdown({
1850                //     until: expirationTime,
1851                //     significant: 0,
1852                //     format: 'DHMS',
1853                //     alwaysExpire: true,
1854                //     layout: ctsecs});
1855                if (!params.countdownNumbersOnly && $('.container').hasClass('ctdwn-twolines-h
1855orizontal')) {
1856                    tpl = '<ul class="cd-listview">'
1857                            + '<li class="cd-days">{dnn}</li><span></span><li class="cd-hours">{hnn}</li><span></span>'
1858                            + '<li class="cd-minutes">{mnn}</li><span></span><li class="cd-seconds">{snn}</li></ul>'
1859                    tpl2 = '<ul class="cd-listview">'
1860                            + '{d<}<li class="days">{dl}</li>{d>}{h<}<li class="hours">{hl}</li>{h>}'
1861                            + '{m<}<li class="minutes">{ml}</li>{m>}{s<}<li class="seconds">{sl}</li>{s>}</ul>';
1862
1863                    $('#watch_countdown_text').countdown({
1864                        until: expirationTime,
1865                        significant: 0,
1866                        format: 'DHMS',
1867                        alwaysExpire: true,
1868                        layout: tpl2
1869                    });
1870                    $('#watch_countdown').countdown({
1871                        until: expirationTime,
1872                        significant: 0,
1873                        format: 'DHMS',
1874                        alwaysExpire: true,
1875                        layout: tpl,
1876                        onExpiry: expiration
1877                    });
1878                } else if (!params.countdownNumbersOnly && $('.container').hasClass('ctdwn-oneline-horizontal')) {
1879                    ctdays = '{d<}{dl}{d>}';
1880                    cthours = '{d<}{hl}{d>}';
1881                    ctmins = '{d<}{ml}{d>}';
1882                    ctsecs = '{d<}{sl}{d>}';
1883                    tpl = '<ul class="cd-listview">{y<}<li class="cd-years"><span></span>{yn} {yl}</li>{y>}{o<}<li class="cd-month"><span></span>{on} {ol}</li>{o>}'
1884                            + '{d<}<li class="cd-days"><span></span>{dnn} {dl}</li>{d>}{h<}<li class="cd-hours"><span></span>{hnn} {hl}</li>{h>}'
1885                            + '{m<}<li class="cd-minutes"><span></span>{mnn} {ml}</li>{m>}{s<}<li class="cd-seconds"><span></span>{snn} {sl}</li>{s>}</ul>';
1886                    $('#watch_countdown').countdown({
1887                        until: expirationTime,
1888                        significant: 0,
1889                        format: 'DHMS',
1890                        alwaysExpire: true,
1891                        layout: tpl,
1892                        onExpiry: expiration
1893                    });
1894                 } else if (params.countdownNumbersOnly && $('.container').hasClass('ctdwn-oneline-horizontal')) {
1895                    // console.log("here")
1896                    ctdays = '{d<}{dl}{d>}';
1897                    cthours = '{d<}{hl}{d>}';
1898                    ctmins = '{d<}{ml}{d>}';
1899                    ctsecs = '{d<}{sl}{d>}';
1900                    tpl = '<ul class="cd-listview">{y<}<li class="cd-years"><span></span>{yn} </li>{y>}{o<}<li class="cd-months"><span></span>{on} </li>{o>}'
1901                            + '{d<}<li class="cd-days"><span></span>{dnn} </li>{d>}{h<}<li class="cd-hours"><span></span>{hnn} </li>{h>}'
1902                            + '{m<}<li class="cd-minutes"><span></span>{mnn} </li>{m>}{s<}<li class="cd-seconds"><span></span>{snn} </li>{s>}</ul>';
1903                    $('#watch_countdown').countdown({
1904                        until: expirationTime,
1905                        significant: 0,
1906                        format: 'DHMS',
1907                        alwaysExpire: true,
1908                        layout: tpl,
1909                        onExpiry: expiration
1910                    });
1911                 } else if (!params.countdownNumbersOnly && $('.container').hasClass('ctdwn-twolinesText-horizontal')) {
1912                    
1913                    ctdays = '{d<}{dl}{d>}';
1914                    cthours = '{d<}{hl}{d>}';
1915                    ctmins = '{d<}{ml}{d>}';
1916                    ctsecs = '{d<}{sl}{d>}';
1917                    tpl = '<ul class="cd-listview">{y<}<li class="cd-years"><span></span>{yn} {yl}</li>{y>}{o<}<li class="cd-month"><span></span>{on} {ol}</li>{o>}'
1918                            + '{d<}<li class="cd-days"><span></span>{dnn} {dl}</li>{d>}{h<}<li class="cd-hours"><span></span>{hnn} {hl}</li>{h>}'
1919                            + '{m<}<li class="cd-minutes"><span></span>{mnn} {ml}</li>{m>}{s<}<li class="cd-seconds"><span></span>{snn} {sl}</li>{s>}</ul>';
1920                    $('#watch_countdown').countdown({
1921                        until: expirationTime,
1922                        significant: 0,
1923                        format: 'DHMS',
1924                        alwaysExpire: true,
1925                        layout: tpl,
1926                        onExpiry: expiration
1927                    });
1928                    $('.has-countdown #logo').css({"display": 'block'})
1929                 } else if (!params.countdownNumbersOnly && $('.container').hasClass('ctdwn-threelines-horizontal')) {
1930                    // console.log("ctdwn-twolinesNew-horizontal")
1931                    tpl = '<ul class="cd-listview">'
1932                            + '<li class="cd-days">{dnn}</li><span></span><li class="cd-hours">{hnn}</li><span></span>'
1933                            + '<li class="cd-minutes">{mnn}</li><span></span><li class="cd-seconds">{snn}</li></ul>'
1934                    tpl2 = '<ul class="cd-listview">'
1935                            + '{d<}<li class="days">{dl}</li>{d>}{h<}<li class="hours">{hl}</li>{h>}'
1936                            + '{m<}<li class="minutes">{ml}</li>{m>}{s<}<li class="seconds">{sl}</li>{s>}</ul>';
1937                    $('#watch_countdown').countdown({
1938                        until: expirationTime,
1939                        significant: 0,
1940                        format: 'DHMS',
1941                        alwaysExpire: true,
1942                        layout: tpl,
1943                        onExpiry: expiration
1944                    });
1945                    $('#watch_countdown_text').countdown({
1946                        until: expirationTime,
1947                        significant: 0,
1948                        format: 'DHMS',
1949                        alwaysExpire: true,
1950                        layout: tpl2
1951                    });
1952
1953                } else if (!params.countdownNumbersOnly && $('.container').hasClass('ctdwn-twolinesNew-horizontal')) {
1954                    // console.log("ctdwn-twolinesNew-horizontal")
1955                    tpl = '<ul class="cd-listview">'
1956                            + '<li class="cd-days">{dnn}</li><span>:</span><li class="cd-hours">{hnn}</li><span>:</span>'
1957                            + '<li class="cd-minutes">{mnn}</li><span>:</span><li class="cd-seconds">{snn}</li></ul>'
1958                    tpl2 = '<ul class="cd-listview">'
1959                            + '{d<}<li class="days">{dl}</li>{d>}{h<}<li class="hours">{hl}</li>{h>}'
1960                            + '{m<}<li class="minutes">{ml}</li>{m>}{s<}<li class="seconds">{sl}</li>{s>}</ul>';
1961                    $('#watch_countdown').countdown({
1962                        until: expirationTime,
1963                        significant: 0,
1964                        format: 'DHMS',
1965                        alwaysExpire: true,
1966                        layout: tpl,
1967                        onExpiry: expiration
1968                    });
1969                    $('#watch_countdown_text').countdown({
1970                        until: expirationTime,
1971                        significant: 0,
1972                        format: 'DHMS',
1973                        alwaysExpire: true,
1974                        layout: tpl2
1975                    });
1976                 } else if (!params.countdownNumbersOnly && $('.container').hasClass('ctdwn-threelinesNew-horizontal')) {
1977                    // console.log("ctdwn-twolinesNew-horizontal")
1978                    tpl = '<ul class="cd-listview">'
1979                            + '<li class="cd-days">{dnn}</li><span>:</span><li class="cd-hours">{hnn}</li><span>:</span>'
1980                            + '<li class="cd-minutes">{mnn}</li><span>:</span><li class="cd-seconds">{snn}</li></ul>'
1981                    tpl2 = '<ul class="cd-listview">'
1982                            + '{d<}<li class="days">{dl}</li>{d>}{h<}<li class="hours">{hl}</li>{h>}'
1983                            + '{m<}<li class="minutes">{ml}</li>{m>}{s<}<li class="seconds">{sl}</li>{s>}</ul>';
1984                    $('#watch_countdown').countdown({
1985                        until: expirationTime,
1986                        significant: 0,
1987                        format: 'DHMS',
1988                        alwaysExpire: true,
1989                        layout: tpl,
1990                        onExpiry: expiration
1991                    });
1992                    $('#watch_countdown_text').countdown({
1993                        until: expirationTime,
1994                        significant: 0,
1995                        format: 'DHMS',
1996                        alwaysExpire: true,
1997                        layout: tpl2
1998                    });
1999                 } else if (params.countdownNumbersOnly && $('.container').hasClass('ctdwn-twolinesNew-horizontal')) {
2000                    // console.log("ctdwn-twolinesNew-horizontal")
2001                    tpl = '<ul class="cd-listview">{y<}<li class="cd-years"><span></span>{yn} </li>{y>}{o<}<li class="cd-months"><span></span>{on} </li>{o>
2001}'
2002                            + '{d<}<li class="cd-days"><span></span>{dnn} </li>{d>}{h<}<li class="cd-hours"><span></span>{hnn} </li>{h>}'
2003                            + '{m<}<li class="cd-minutes"><span></span>{mnn} </li>{m>}{s<}<li class="cd-seconds"><span></span>{snn} </li>{s>}</ul>';
2004                    $('#watch_countdown').countdown({
2005                        until: expirationTime,
2006                        significant: 0,
2007                        format: 'DHMS',
2008                        alwaysExpire: true,
2009                        layout: tpl,
2010                        onExpiry: expiration
2011                    });
2012
2013                 } else {
2014                    tpl = '<ul class="cd-listview">{y<}<li class="cd-years"><span></span>{yn} {yl}</li>{y>}{o<}<li class="cd-month"><span></span>{on} {ol}</li>{o>}'
2015                            + '{d<}<li class="cd-days"><span></span>{dnn} {dl}</li>{d>}{h<}<li class="cd-hours"><span></span>{hnn} {hl}</li>{h>}'
2016                            + '{m<}<li class="cd-minutes"><span></span>{mnn} {ml}</li>{m>}{s<}<li class="cd-seconds"><span></span>{snn} {sl}</li>{s>}</ul>';
2017                    $('#watch_countdown').countdown({
2018                        until: expirationTime,
2019                        significant: 0,
2020                        format: 'DHMS',
2021                        alwaysExpire: true,
2022                        layout: tpl,
2023                        onExpiry: expiration
2024                    });
2025                }                
2026            }
2027        }
2028        // build the clock
2029        buildClock(params);
2030    };
2031}(jQuery));
2032
2033/**
2034 * Get Standard Timezone Offset
2035 * @returns {integer} Returns offset in minutes
2036 */
2037Date.prototype.stdTimezoneOffset = function() {
2038    var jan = new Date(this.getFullYear(), 0, 1);
2039    var jul = new Date(this.getFullYear(), 6, 1);
2040    return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
2041}
2042/**
2043 * Tells whether it is in Daylight Saving Time (Summer Time)
2044 * @returns {Boolean} DST or not
2045 */
2046Date.prototype.dst = function() {
2047    return this.getTimezoneOffset() < this.stdTimezoneOffset();
2048}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.