PageSourceSearch

https://www.pwaworldtour.com/_assets/51de1a677f345ff06c2402785fad24c4/JavaScript/main.js?1781099282

js pwaworldtour.com collected 2026-10-02 10:34:53 UTC 15,247 bytes, 455 lines download raw bytes

1// smart debounced resize
2(function($,sr){
3
4    // debouncing function from John Hann
5    // http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
6    var debounce = function (func, threshold, execAsap) {
7        var timeout;
8
9        return function debounced () {
10            var obj = this, args = arguments;
11            function delayed () {
12                if (!execAsap)
13                    func.apply(obj, args);
14                timeout = null;
15            }
16
17            if (timeout)
18                clearTimeout(timeout);
19            else if (execAsap)
20                func.apply(obj, args);
21
22            timeout = setTimeout(delayed, threshold || 250);
23        };
24    };
25    // smartresize
26    jQuery.fn[sr] = function(fn){  return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); };
27
28})(jQuery,'smartresize');
29
30
31// usage:
32/*
33$(window).smartresize(function(){
34    // code that takes it easy...
35});
36*/
37
38
39// custom functions
40var FE = {
41	location: window.location,
42    disciplines: {
43        1: 'Wave',
44        2: 'Freestyle',
45        5: 'Slalom',
46        6: 'Foil',
47        10: 'Slalom Fin',
48        11: 'Slalom Foil',
49        12: 'Slalom X'
50    },
51
52    SelectBox: {
53        init: function() {
54            $('.select-box .label').click(function() {
55              $(this).next().slideToggle();
56            });
57            FE.SelectBox.showActive();
58        },
59        showActive: function () {
60            $('.select-box[data-show-active]').each(function () {
61                if ( $(this).find('a.active').length ) {
62                    $(this).find('.label').text( $(this).find('a.active').text() );
63                } else {
64                    $(this).find('.label').text( $(this).find('a').first().text() );
65                }
66            });
67        }
68    },
69
70    Lightbox: {
71      init: function () {
72          $('.lightbox').magnificPopup({
73              type:'image',
74              gallery:{enabled:true}
75          });
76      }
77    },
78
79	MobileMenu: {
80		init: function() {
81            //FE.MobileMenu.indicateSubMenu();
82			$('.burger-icon').click(function() {
83                $('.nav-main').slideToggle();
84            });
85		},
86        indicateSubMenu: function() {
87            $('.nav-mobile > ul > li').each(function() {
88                if ( $(this).find('ul').length ) {
89                    $(this).prepend('<span>&gt;</span>');
90                }
91                $(this).find('span').click(function() {
92                    $(this).siblings('ul').slideToggle();
93                });
94            });
95        }
96	},
97
98    OverallRankSlider: {
99        init: function() {
100            $('.world-ranking-compact h3').append(' <span />');
101            FE.OverallRankSlider.presetDiscipline();
102            $('.world-ranking-compact-group').slick({
103                slidesToShow: 1,
104                slidesToScroll: 1,
105                dots: false,
106                arrows: true,
107                infinite: true,
108                speed: 1000,
109                autoplaySpeed: 3000,
110                fade: false,
111                slide: '.pwaworldtour-plugin',
112                cssEase: 'linear',
113                autoplay: true,
114                centerMode: false,
115                focusOnSelect: false
116            });
117            $('.world-ranking-compact-group').on('afterChange', function (event, slick, currentSlide, nextSlide) {
118                FE.OverallRankSlider.updateDiscipline($(this));
119            });
120        },
121        presetDiscipline: function () {
122            $('.world-ranking-compact-group').each(function () {
123                var curDiscipline = $(this).find('.pwa-ranking-top10').data('discipline');
124                $(this).parent().find('span').text(FE.disciplines[curDiscipline]);
125            });
126        },
127        updateDiscipline: function (rankItem) {
128            var curDiscipline = $(rankItem).find('.slick-active .pwa-ranking-top10').data('discipline');
129            $(rankItem).parent().find('span').text(FE.disciplines[curDiscipline]);
130        }
131    },
132    
133    HeroSlider: {
134        init: function () {
135            $('.hero-image .news-list-view a').attr('target', '_self');
136            $('.hero-image .news-list-view').slick({
137                slidesToShow: 1,
138                slidesToScroll: 1,
139                dots: false,
140                arrows: false,
141                infinite: true,
142                speed: 1000,
143                autoplaySpeed: 5000,
144                fade: false,
145                slide: 'figure',
146                cssEase: 'linear',
147                autoplay: true,
148                centerMode: false,
149                focusOnSelect: false
150            });
151            if ($('.ce-hero-image figure').length > 1) {
152                $('.ce-hero-image').slick({
153                    slidesToShow: 1,
154                    slidesToScroll: 1,
155                    dots: false,
156                    arrows: false,
157                    infinite: true,
158                    speed: 1000,
159                    autoplaySpeed: 5000,
160                    fade: false,
161                    slide: 'figure',
162                    cssEase: 'linear',
163                    autoplay: true,
164                    centerMode: false,
165                    focusOnSelect: false
166                });
167            }
168        }
169    },
170
171    SailorListDeco: {
172        init: function() {
173            var i = -2;
174            $('.sailor-list li').each(function() {
175                if ( i % 4 === 0 || i % 3 === 0 ) {
176                    $(this).addClass('colored');
177                }
178                i++;
179            });
180        }
181    },
182
183    PwaEvent: {
184        init: function () {
185            FE.PwaEvent.setupAjaxEventInfo();
186        },
187        setupAjaxEventInfo: function () {
188            $('.pwa-event-additional').on('click', 'a.get-from-ajax', function (e) {
189                e.preventDefault();
190                var action = $(this).data('action');
191                $('.nav-pwa-event a').removeClass('active');
192                $(this).addClass('active');
193                $.ajax({
194                    url: $(this).attr('href'),
195                    dataType: "html",
196                    cache: "false",
197                    error: function () {
198                    },
199                    success: function (data) {
200                        $('#pwa-event-additional-content').html(data);
201                        FE.SelectBox.init();
202                        if ( action == 'ladders' ) {
203                            initLadder();
204                            setTimeout('FE.PwaEvent.scrollToEventAddtionalSection()', 500);
205                        }
206                    }
207                });
208            });
209
210            var hash = window.location.hash.substring(1);
211            if ( hash === 'ladders' ) {
212                $('.nav-pwa-event li:nth-child(1) a').trigger('click');
213            }
214            if ( hash === 'entrylist' ) {
215                $('.nav-pwa-event li:nth-child(2) a').trigger('click');
216            }
217            if ( hash === 'results' ) {
218                $('.nav-pwa-event li:nth-child(3) a').trigger('click');
219            }
220            if ( hash === 'ticker' ) {
221                $('.nav-pwa-event li:nth-child(4) a').trigger('click');
222            }
223        },
224        scrollToEventAddtionalSection: function() {
225            $('html, body').animate({ scrollTop: ($('.pwa-event-additional').offset().top) - 80}, 'slow');
226        }
227    },
228
229    HeaderShrink: {
230        init: function () {
231            window.addEventListener('scroll', function(e){
232                var distanceY = window.pageYOffset || document.documentElement.scrollTop,
233                    shrinkOn = 200;
234                if (distanceY > shrinkOn) {
235                    $('.page').addClass('small-header');
236                } else {
237                    if ( $('.page').hasClass('small-header') ) {
238                        $('.page').removeClass('small-header');
239                    }
240                }
241            })
242        }
243    },
244
245    Sponsors: {
246        init: function() {
247
248            const sponsorsMain = $('.sponsors-industry ul').slick({
249                slidesToShow: 1,
250                slidesToScroll: 1,
251                dots: false,
252                arrows: false,
253                infinite: true,
254                speed: 500,
255                autoplaySpeed: 4000,
256                fade: true,
257                slide: 'li',
258                cssEase: 'linear',
259                autoplay: true,
260                centerMode: false,
261                focusOnSelect: false
262            });
263
264            sponsorsMain.on('init', function(event, slick, currentSlide, nextSlide){
265                // not working yet
266                let activeSlide = $('.sponsors-industry ul li.slick-active');
267                //console.log(activeSlide);
268                //console.log(activeSlide.data('sponsorLabel'));
269            });
270
271            sponsorsMain.on('afterChange', function(event, slick, currentSlide, nextSlide){
272                //console.log(event);
273                //console.log(currentSlide);
274                //console.log(nextSlide);
275
276                let activeSlide = $('.sponsors-industry ul li.slick-active');
277                //console.log(activeSlide);
278                //console.log(activeSlide.data('sponsorLabel'));
279
280                document.querySelector('.sponsors-industry h3 span').innerHTML = activeSlide.data('sponsorLabel');
281
282            });
283        }
284
285    },
286
287    LiveTicker: {
288        showTime: false,
289        init: function () {
290            $('.liveticker-refresh').click(function(){
291                clearInterval(FE.LiveTicker.showTime);
292                FE.LiveTicker.loadData();
293                FE.LiveTicker.showTime = setInterval("FE.LiveTicker.loadData()", 5*60000);
294            });
295
296            // open external version of ticker as popup
297            $('.liveticker-new-window').click(function(e){
298                e.preventDefault();
299                console.log($(this).attr('href'));
300                window.open( $(this).attr('href'), "LiveTicker", "width=500,height=700");
301            });
302
303            FE.LiveTicker.showtime = setInterval("FE.LiveTicker.loadData()", 5*60000);
304            FE.LiveTicker.loadData();
305        },
306        loadData: function () {
307            $.ajax({
308                url: "/typo3temp/tx_pwaliveticker/" + tickerxml,
309                dataType: "xml",
310                cache: "false",
311                data: "stamp=" + new Date().getTime(),
312                error: function () {
313                    // error handling in case needed
314                },
315                success: function (data) {
316                    //alert ("reload" + window.location);
317                    $(data).find('liveticker').each(function () {
318
319                        $('.liveticker-headline').text( $(this).find('headline').text() );
320                        $('.liveticker-text').html( $(this).find('tickertext').text() );
321                        $('.liveticker-discipline').text('Current discipline: ' + $(this).find('discipline').text() );
322                        if ( parseInt($(this).find('status').text()) === 0) {
323                            clearInterval(FE.LiveTicker.showTime);
324                            $('.liveticker-refresh').addClass('inactive');
325                        }
326                        /*
327                        if (typeof $tickerscroller !== "undefined") {
328                            $tickerscroller.tinyscrollbar_update();
329                        }*/
330
331                    });
332                }
333            });
334        }
335        /*
336        reGenerateXml: function () {
337            $.ajax({
338                url: "index.php?id=919",
339                cache: "false",
340                success: function(){
341                    FE.LiveTicker.loadData();
342                }
343            });
344        }
345        */
346    },
347
348    Newsletter: {
349        formInjected: false,
350        init: function () {
351            const KEY = 'newsletterSignupShowed';
352            const DAYS = 10;    // days until show again
353            const now = Date.now();
354
355            const last = Number(localStorage.getItem(KEY) || 0);
356            const diffDays = (now - last) / (1000 * 60 * 60 * 24);
357
358            if (diffDays >= DAYS) {
359                // Unfortunately, we need to inject the form early without delay or google captcha won't work
360                if (FE.Newsletter.formInjected === false) {
361                    FE.Newsletter.injectNewsletterForm();
362                }
363                setTimeout(function () {
364                    FE.Newsletter.openNewsletterPoup(KEY, now);
365                }, 5000);
366            }
367            // use direct link instead
368            //document.getElementById('btn-newsletter-signup').addEventListener('click', FE.Newsletter.openNewsletterPoup);
369        },
370        openNewsletterPoup: function (KEY, now) {
371            $.magnificPopup.open({
372                items: {
373                    src: '#newsletter-signup',
374                    type: 'inline'
375                },
376                closeBtnInside: true,
377                closeOnBgClick: true,
378                enableEscapeKey: true,
379                preloader: false,
380                modal: false,
381                callbacks: {
382                    close: function() {
383                        localStorage.setItem(KEY, String(now));
384                    }
385                }
386            });
387        },
388        injectNewsletterForm: function () {
389            const newsletterPopup = document.querySelector('#icontactSignupFormWrapper287');
390            const newScript = document.createElement('script');
391            newScript.src = "https://app.icontact.com/icp/core/mycontacts/signup/designer/form/automatic?id=287&cid=1472522&lid=8847&divid=icontactSignupFormWrapper287";
392            newScript.setAttribute('type', "text/javascript");
393            newsletterPopup.appendChild(newScript);
394            FE.Newsletter.formInjected = true;
395        }
396    }
397
398};
399
400// init custom functions
401(function ($, window, document, undefined) {
402
403	$(function () {
404
405        if ( $('.select-box').length ) {
406            FE.SelectBox.init();
407        }
408        FE.Lightbox.init();
409		FE.MobileMenu.init();
410        FE.HeaderShrink.init();
411
412        if ( $('.world-ranking-compact-group .pwaworldtour-plugin').length > 1 ) {
413            FE.OverallRankSlider.init();
414        }
415
416        if ( $('.sailor-list').length ) {
417            //FE.SailorListDeco.init();
418        }
419
420        if ( $('.hero-image figure').length ) {
421            FE.HeroSlider.init();
422        }
423
424        if ( $('.nav-pwa-event').length ) {
425            FE.PwaEvent.init();
426        }
427
428        if ( $('.ticker-detail').length ) {
429            FE.LiveTicker.init();
430        }
431
432        if ( $('.sponsors-industry').length ) {
433            FE.Sponsors.init();
434        }
435
436        var hash = window.location.hash.substring(1);
437        if ( hash === 'livestream' ) {
438            $('body').addClass('livestream-view');
439        }
440
441        // newsletter modal on start page
442        if (document.getElementById('newsletter-signup')) {
443            FE.Newsletter.init();
444        }
445
446        // temp hide / show news block on start page
447        /*
448        var hash = window.location.hash.substring(1);
449        if ( hash == 'overlay' ) {
450            $('.hero-image').addClass('alternative');
451        }*/
452
453	});
454
455}(jQuery, window, document));

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.