PageSourceSearch

https://www.umgcatalog.com/wp-content/plugins/umg-aal/js/umg-aal-wp.js?ver=1.2

js umgcatalog.com collected 2026-10-02 10:44:23 UTC 41,339 bytes, 1,110 lines download raw bytes

1/********************************************
2 *
3 * umgAALWP
4 * JS bridge between 3rd party plugins and umgAAL
5 *
6 */
7
8//
9// implement a wait state to check mainly for when/if the 'evidon'/Transcend (airgap) variable is available (helps solve async loading)
10//
11var totalWaitAttempts = 10; // roughly 1 seconds
12var currentWaitAttempts = 0;
13
14// There are multiple ways the scripts can be added to page, variable to ensure it's only output once
15var youTubeScriptsOutput = false;
16
17/**
18 * Function to wait until a variable is found - limited to totalWaitAttemps until it stops
19 * @param {*} variable // the name of the variable to check for
20 * @param {*} callback // the function called when variable found
21 * @param {*} triggerOnFail // the function called when variable not found
22 */
23function waitFor(variable,callback,triggerOnFail){
24	var interval=setInterval(function(){
25        switch(variable) {
26            case 'evidon.notice' :
27                if(window['evidon'].notice){
28                    clearInterval(interval);
29                    callback();
30                }else if(currentWaitAttempts<totalWaitAttempts){
31                    currentWaitAttempts++;
32                }else{
33                    clearInterval(interval);
34                    triggerOnFail();
35                }
36                break;
37            // Default case catering for Transcend 'airgap' check - CH 2025-04-03
38            default :
39                if(window[variable]){
40                    clearInterval(interval);
41                    callback();
42                }else if(currentWaitAttempts<totalWaitAttempts){
43                    currentWaitAttempts++;
44                }else{
45                    clearInterval(interval);
46                    triggerOnFail();
47                }
48                break;
49        }
50	},200);
51}
52
53var lsTotalWaitAttempts = 25; // roughly 5 seconds
54var lsCurrentWaitAttempts = 0;
55
56function waitForLocalStorage(partialKey, cb, timer) {
57
58	var keyFound = false;
59	for (var i = 0; i < localStorage.length; i++){
60	    if ( localStorage.key(i).indexOf(partialKey) != -1 ) {
61	        keyFound = true;
62	        break;
63	    } else {
64            UMGAALWP.helpers.debugOutput('AAL: Not found evidon storage item');
65	    }
66	}
67
68	lsCurrentWaitAttempts++;
69	
70	if (lsCurrentWaitAttempts < lsTotalWaitAttempts) {
71  		if (!keyFound) return (timer = setTimeout(waitForLocalStorage.bind(null, partialKey), 100))
72  		clearTimeout(timer)
73  		if (typeof cb !== 'function') return keyFound
74  		return cb(keyFound)
75  	} else {
76  		clearTimeout(timer)
77  		if (typeof cb !== 'function') return keyFound
78  		return cb(keyFound)
79  	}
80}
81
82var tagYTPlayerAPI, firstScriptTag, tagIframeAPI, secondScriptTag;
83//
84// document init
85//
86jQuery(document).ready(function() {
87
88    if(UMGAALWP.party_service_id){
89        // Push Party Service ID to the dataLayer
90        window.dataLayer = window.dataLayer || [];
91        window.dataLayer.push({
92        'partyserviceID': UMGAALWP.party_service_id
93        });
94    }
95
96  if(typeof(umgAAL) != 'undefined') {
97
98    //
99    // init
100    //
101    if(parseInt(UMGAALWP.debug_enabled)) {
102      UMGAALWP.helpers.debug = true;
103      umgAAL.helpers.debug_enabled = true;
104      UMGAALWP.helpers.debugOutput('Debug output enabled');
105    }else{
106        UMGAALWP.helpers.debug = 0;
107        umgAAL.helpers.debug_enabled = 0;
108    }
109
110    //
111    // set default values for WP platform
112    //
113    umgAAL.platform = umgAAL.standardized.PLATFORMS.WORDPRESS;
114    umgAAL.user.loginPlatform = 'site';   // assume standard site reg (NB: if AE connect enabled, it's init function will set this to AE instead)
115
116    //
117    // iterate over all enabled plugins and run any init needed for it
118    //
119    for(var plugin_identifier in UMGAALWP.plugins) {
120      if(UMGAALWP.plugins[plugin_identifier]) {
121        // plugin is enabled, run any initialization code - will call a function 'UMGAALWP.plugins.{plugin_idenifier}_init'
122        // eg: 'UMGAALWP.plugins.ae_connect_init' or 'UMGAALWP.plugins.umg_ecrm_init'
123        UMGAALWP.helpers.executeFunctionByName('UMGAALWP.plugins.' + plugin_identifier + '_init', window);
124      }
125    }
126
127  } else {
128
129    //  umgAAL object not found - output this error regardless of debug setting to facilitate debugging on prod servers
130    console.log('UMGAALWP: umgAAL object not found on page, init functions have not been run');
131
132  }
133
134});
135
136//
137// helpers
138//
139UMGAALWP.helpers = {
140  debug: false,   // default off
141
142  debugOutput: function(message, object) {
143  	if(UMGAALWP.helpers.debug) {
144  		if(typeof(object) != 'undefined') {
145  			console.log('UMGAALWP: ' + message, object);
146  		} else {
147  			console.log('UMGAALWP: ' + message);
148  		}
149  	}
150  },
151
152  // execute a function by name (handles namespaced function names, eg "My.Namespace.functionName")
153  executeFunctionByName: function(functionName, context /*, args */) {
154  	var args = Array.prototype.slice.call(arguments, 2);
155    var namespaces = functionName.split(".");
156    var func = namespaces.pop();
157  	for (var i = 0; i < namespaces.length; i++) {
158  		if(typeof context != "undefined") {
159  	  		context = context[namespaces[i]];
160  		} else {
161  				return false;
162  		}
163  	}
164  	if(typeof context != "undefined" && typeof context[func] != "undefined") {
165  		return context[func].apply(context, args);
166  	}
167  	return false;
168  }
169};
170
171
172
173/********************************************
174 *
175 * Plugin integrations
176 *
177 */
178
179//
180// AE Connect
181//
182// init function
183UMGAALWP.plugins.ae_connect_init = function() {
184  // set user login platform
185  umgAAL.user.loginPlatform = 'AE';
186
187  // set user details if available
188  if(typeof(AEJSWP) != 'undefined' && typeof(AEJSWP.aeJS) != 'undefined' && typeof(AEJSWP.aeJS.user.data) != 'undefined') {
189    umgAAL.user.loginStatus = 'yes';
190    if(typeof(AEJSWP.aeJS.user.data.ID) != 'undefined') {
191      umgAAL.user.loginPlatformUserID = AEJSWP.aeJS.user.data.ID;
192    }
193    if(typeof(AEJSWP.aeJS.user.data.Email) != 'undefined') {
194      umgAAL.user.email = AEJSWP.aeJS.user.data.Email;
195    }
196    if(typeof(AEJSWP.aeJS.user.data.VerifiedEmail) != 'undefined') {
197      umgAAL.user.email = AEJSWP.aeJS.user.data.VerifiedEmail;
198    }
199    if(typeof(AEJSWP.aeJS.user.data.BirthDate) != 'undefined') {
200      umgAAL.user.birthDate = AEJSWP.aeJS.user.data.BirthDate;
201    }
202    if(typeof(AEJSWP.aeJS.user.data.BirthDate) != 'undefined') {
203      umgAAL.user.zip = AEJSWP.aeJS.user.data.PostCode;
204    }
205    if(typeof(AEJSWP.aeJS.user.data.BirthDate) != 'undefined') {
206      umgAAL.user.state = AEJSWP.aeJS.user.data.State;
207    }
208    if(typeof(AEJSWP.aeJS.user.data.BirthDate) != 'undefined') {
209      umgAAL.user.country = AEJSWP.aeJS.user.data.Country;
210    }
211  } else {
212    umgAAL.user.loginStatus = 'no';
213  }
214};
215// AE Connect uses a trackingDelegate.AEConnect object to fire events
216var trackingDelegate = window.trackingDelegate || {};
217trackingDelegate.AEConnect = {
218  is_enabled: function() {
219    return UMGAALWP.plugins.ae_connect && typeof(umgAAL) != 'undefined';
220  },
221  loginModalShown: function(call_to_action) {
222    if(trackingDelegate.AEConnect.is_enabled) {
223      umgAAL.track.account_login_modal_shown( call_to_action );
224    }
225	},
226  registrationModalShown: function(call_to_action) {
227    if(trackingDelegate.AEConnect.is_enabled) {
228      umgAAL.track.account_registration_modal_shown( call_to_action );
229    }
230	},
231	login: function(data) {
232    if(trackingDelegate.AEConnect.is_enabled) {
233      UMGAALWP.plugins.ae_connect_init(); // call the  init function just before firing event to capture any updated user details
234      umgAAL.user.loginProvider = (data.service_name == 'email') ? umgAAL.user.loginProvider = umgAAL.standardized.SOCIAL_PLATFORMS.SITE : data.service_name; // happy coincedence: ae social service names === umgAAL.standardized.SOCIAL_PLATFORMS
235      umgAAL.track.login_success( umgAAL.standardized.SOURCES.PLATFORM_LOGIN );
236    }
237	},
238  registration: function(data) {
239    if(trackingDelegate.AEConnect.is_enabled) {
240      UMGAALWP.plugins.ae_connect_init();
241
242      umgAAL.track.register_success( umgAAL.standardized.SOURCES.PLATFORM_REGISTRATION );
243    }
244	},
245    newsletterRegistration: function(data) {
246        if(trackingDelegate.AEConnect.is_enabled) {
247            delete umgAAL.user.birthDate;
248            UMGAALWP.plugins.ae_connect_init();
249            umgAAL.user.loginProvider = (data.service_name == 'email') ? umgAAL.user.loginProvider = umgAAL.standardized.SOCIAL_PLATFORMS.SITE : data.service_name; // happy coincedence: ae social service names === umgAAL.standardized.SOCIAL_PLATFORMS
250            Object.assign(umgAAL.user, data);
251            umgAAL.track.register_success( 'WordPress Newsletter Registration' );
252        }
253    },
254  formErrors: function(data) {
255    if(trackingDelegate.AEConnect.is_enabled) {
256      UMGAALWP.plugins.ae_connect_init();
257      var form_type;
258      switch(data.form_type) {
259        case 'registration':
260          form_type = umgAAL.standardized.FORM_TYPES.REGISTRATION;
261          break;
262        case 'login':
263          form_type = umgAAL.standardized.FORM_TYPES.LOGIN;
264          break;
265        case 'mailinglist':
266          form_type = umgAAL.standardized.FORM_TYPES.COMMUNICATIONS;
267          break;
268      }
269      umgAAL.track.form_errors( form_type, data.form_errors );
270    }
271	},
272  accountConnect: function(data) {
273    if(trackingDelegate.AEConnect.is_enabled) {
274      UMGAALWP.plugins.ae_connect_init();
275      var social_provider = ( data.service_name == 'email' ) ? umgAAL.standardized.SOCIAL_PLATFORMS.SITE : data.service_name;
276      umgAAL.track.account_social_connect_success( umgAAL.standardized.SOURCES.PLATFORM_REGISTRATION, social_provider );
277    }
278  }
279};
280
281
282//
283// UMG eCRM
284//
285trackingDelegate.UMGECRM = {
286    is_enabled: function() {
287      return UMGAALWP.plugins.umg_ecrm && typeof(umgAAL) != 'undefined';
288    },
289    optin_success: function(data) {
290        if(trackingDelegate.UMGECRM.is_enabled) {
291            umgAAL.track.comm_optin_success( umgAAL.standardized.SOURCES.PLATFORM_COMMUNICATIONS, data.list_id, data.list_name, data.business_unit );
292        }
293    }
294};
295//
296// AE Social Follow
297trackingDelegate.AESocialFollow = {
298  is_enabled: function() {
299    return UMGAALWP.plugins.ae_social_follow && typeof(umgAAL) != 'undefined';
300  },
301  followToggle:function(data) {
302        if(trackingDelegate.AESocialFollow.is_enabled) {
303
304        }
305  },
306  follow:function(data){
307        if(trackingDelegate.AESocialFollow.is_enabled) {
308
309        }
310  },
311  unFollow:function(data){
312        if(trackingDelegate.AESocialFollow.is_enabled) {
313
314        }
315  },
316  followLoginClicked:function(data){
317        if(trackingDelegate.AESocialFollow.is_enabled) {
318
319        }
320  },
321  socialAccountConnect:function(data){
322        if(trackingDelegate.AESocialFollow.is_enabled) {
323            data = JSON.parse(data);
324            var social_provider;
325            switch(data.account_type) {
326                case 'spotify':
327                    social_provider = umgAAL.standardized.SOCIAL_PLATFORMS.SPOTIFY;
328                break;
329                case 'youtube':
330                    social_provider = umgAAL.standardized.SOCIAL_PLATFORMS.YOUTUBE;
331                break;
332                case 'twitter':
333                    social_provider = umgAAL.standardized.SOCIAL_PLATFORMS.TWITTER;
334                break;
335                case 'instagram':
336                    social_provider = umgAAL.standardized.SOCIAL_PLATFORMS.INSTAGRAM;
337                break;
338            }
339            var form_type = umgAAL.standardized.FORM_TYPES.LOGIN;
340            umgAAL.track.account_social_connect_success( form_type, social_provider );
341        }
342  },
343  formErrors:function(data){
344        if(trackingDelegate.AESocialFollow.is_enabled) {
345
346        }
347  }
348};
349
350
351// Login for content
352trackingDelegate.LoginForContent = {
353  is_enabled: function() {
354    return UMGAALWP.plugins.login_for_content && typeof(umgAAL) != 'undefined';
355  },
356  contentUnlocking:function(data){
357        data = JSON.parse(data);
358        if(trackingDelegate.LoginForContent.is_enabled) {
359            umgAAL.track.unlock_content_success( data.media_type, data.media_id, data.title, umgAAL.user )
360        }
361  }
362};
363// Subscribtions
364trackingDelegate.Subscriptions = {
365  is_enabled: function() {
366    return UMGAALWP.plugins.subscriptions && typeof(umgAAL) != 'undefined';
367  },
368  //COMMUNICATION_OPTIN
369  communicationOptin:function(data){
370        if(trackingDelegate.subscriptions.is_enabled) {
371            data = JSON.parse(data);
372            umgAAL.track.comm_optin_success( data.source,data.list_id,data.business_unit,data.subscriber_list_name );
373        }
374  }
375};
376
377// UMG Live
378trackingDelegate.UMGLive = {
379  is_enabled: function() {
380    return UMGAALWP.plugins.umg_live && typeof(umgAAL) != 'undefined';
381  },
382  //COMMUNICATION_OPTIN
383  buyTicketsLink:function(data){
384        if(trackingDelegate.UMGLive.is_enabled) {
385            data = JSON.parse(data);
386            umgAAL.track.tour_store_link(data.platform,data.date,data.location,data.tier,data.link);
387        }
388  },
389  externalLink:function(data){
390      if(trackingDelegate.UMGLive.is_enabled) {
391            data = JSON.parse(data);
392            umgAAL.track.outbound_link(data.location);
393      }
394  }
395};
396
397//BANDs In Town
398(function($) {
399    "use strict";
400    if (UMGAALWP.plugins.bands_in_town && typeof(umgAAL) != 'undefined' )
401    {
402        $( document ).on( "click", ".bit-event-data, .bit-rsvp", function() {
403            umgAAL.track.share('facebook','page','',document.title);
404        });
405        $( document ).on( "click", ".bit-track-artist-header", function() {
406            var dest_url = $(this).attr('href');
407            umgAAL.track.outbound_link( dest_url );
408        });
409        $( document ).on( "click", ".bit-fb-share", function() {
410            umgAAL.track.share('facebook','page','',document.title);
411        });
412        $( document ).on( "click", ".bit-twitter-share", function() {
413            umgAAL.track.share('twitter','page','',document.title);
414        });
415
416        $( document ).on( "click", ".bit-buy-tix", function() {
417            var date = '', location = '', ticket_tier = 'N/A', dest_url = '', platform = 'TourDates';
418            var $table_row = $(this).closest('tr');
419            dest_url = $(this).attr('href');
420
421            location = $table_row.find('.bit-location').text();
422
423            var fmt = new DateFormatter();
424            date = fmt.parseDate(new Date().getFullYear() + ' ' +  $table_row.find('.bit-date').text(), 'Y M d');
425            var month = ("0" + (date.getMonth() + 1)).slice(-2)
426            var day = ("0" + (date.getDate())).slice(-2);
427            var year = date.getFullYear();
428            if(new Date(date).getTime() < new Date().getTime())
429            {
430                year = year +1;
431            }
432            if ( isNaN(new Date(date)) === false)
433            {
434                date = year+'-'+month+'-'+day;
435            }
436            else
437            {
438                date = '';
439            }
440            umgAAL.track.tour_store_link(platform,date,location,ticket_tier,dest_url);
441        });
442    }
443})(jQuery);
444//GIGPress
445(function($) {
446    "use strict";
447    if (UMGAALWP.plugins.gigpress && typeof(umgAAL) != 'undefined' )
448    {
449        $( document ).on( "click", ".gigpress-related-item a", function() {
450            umgAAL.track.outbound_link( $(this).attr('href') );
451        });
452
453        $( document ).on( "click", ".gigpress-venue a", function() {
454            umgAAL.track.outbound_link( $(this).attr('href') );
455        });
456        $( document ).on( "click", ".gigpress-address", function() {
457            umgAAL.track.outbound_link( $(this).attr('href') );
458        });
459        $( document ).on( "click", ".gigpress-show-related a", function() {
460            umgAAL.track.outbound_link( $(this).attr('href') );
461        });
462        $( document ).on( "click", ".gigpress-tickets-link", function() {
463            var date = '',month = '',day = '',year = '', location = '', ticket_tier = 'N/A', dest_url = '', platform = 'gigpress';
464            dest_url = $(this).attr('href');
465            if (UMGAALWP.data.gigpress.shows && typeof(UMGAALWP.data.gigpress.shows) !== 'undefined')
466            {
467                if (UMGAALWP.data.gigpress.shows.venue_city !== null)
468                {
469                    location = UMGAALWP.data.gigpress.shows.venue_city + ',';
470                }
471                if (UMGAALWP.data.gigpress.shows.venue_state !== null)
472                {
473                    location = location + UMGAALWP.data.gigpress.shows.venue_state + ',';
474                }
475                if (UMGAALWP.data.gigpress.shows.venue_country !== null)
476                {
477                    location = location + UMGAALWP.data.gigpress.shows.venue_country + ',';
478                }
479                date = UMGAALWP.data.gigpress.shows.show_date;
480            }
481            else
482            {
483                    var fmt = new DateFormatter();
484                    var $table_row = $(this).closest('tr');
485                    var $table_row_data = $table_row.prev('tr');
486
487                    if($table_row.length>0 && $table_row_data.length>0)
488                    {
489                        date = fmt.parseDate($table_row_data.find('.gigpress-date').text(), UMGAALWP.data.gigpress.options.date_format);
490
491                        location = $table_row_data.find('.gigpress-city').text() + ',' + $table_row_data.find('.gigpress-country').text();
492                        month = ("0" + (date.getMonth() + 1)).slice(-2)
493                        day = ("0" + (date.getDate())).slice(-2);
494                        year = date.getFullYear();
495
496                        if ( isNaN(new Date(date)) === false)
497                        {
498                            date = year+'-'+month+'-'+day;
499                        }
500                        else
501                        {
502                            date = '';
503                        }
504                    }
505            }
506            umgAAL.track.tour_store_link(platform,date,location,ticket_tier,dest_url);
507        });
508    }
509})(jQuery);
510
511//New Royalslider
512(function($) {
513    "use strict";
514    if (UMGAALWP.plugins.new_royalslider && typeof(umgAAL) != 'undefined' )
515    {
516        $(window).load(function() {
517            $(document).ready(function(){
518                //Get Slider Title From AAL JSON
519                function get_royal_Slider_title(id){
520                    for (var i = 0; i < UMGAALWP.data.royalslider.length; i++) {
521                        if (UMGAALWP.data.royalslider[i].id === id)
522                        {
523                            return UMGAALWP.data.royalslider[i].name;
524                        }
525                    }
526                    return '';
527                }
528                //Get loop though all Sliders on the Page
529                $('.royalSlider').each(function() {
530                    var id = $(this).attr('id').replace("new-royalslider-", "");
531                    var royal_Slider_title = get_royal_Slider_title(id);
532                    umgAAL.track.photo_gallery_view( id, royal_Slider_title);
533                });
534            });
535        });
536    }
537})(jQuery);
538
539//Nextgen gallery
540(function($) {
541    "use strict";
542    if (UMGAALWP.plugins.nextgen_gallery && typeof(umgAAL) != 'undefined' )
543    {
544        $(window).load(function() {
545            $(document).ready(function(){
546                $('.ngg-galleryoverview').each(function(){
547                    umgAAL.track.photo_gallery_view( '',window.location.href);
548                });
549                $('.ngg-navigation a').click(function(){
550                    umgAAL.track.photo_gallery_load_more( '',window.location.href,'',$(this).data('pageid'));
551                });
552            });
553        });
554    }
555})(jQuery);
556
557//ADD THIS
558(function($) {
559    "use strict";
560    var addthisAAL = (window.addthisAAL) ? window.addthisAAL : {};
561    if (UMGAALWP.plugins.add_this && typeof(umgAAL) != 'undefined' )
562    {
563        addthisAAL = {
564            init: function () {
565                if (typeof(addthis) != 'undefined' ){
566                    addthis.addEventListener('addthis.ready', addthisAAL.addthisReady);
567                    addthis.addEventListener('addthis.menu.share', addthisAAL.shareEventHandler);
568                }
569            },
570            addthisReady : function(e){
571
572            },
573            shareEventHandler : function(e){
574                if (e.type == 'addthis.menu.share') {
575                    umgAAL.track.share(e.data.service.replace("_share", ""),'page','',document.title);
576                }
577            }
578        };
579        //Cant run till after files are loaded as Add this is loaded in the footer so wont work
580        $(window).load(function () {
581            addthisAAL.init();
582        });
583    }
584})(jQuery);
585
586//epoch comments
587(function($) {
588    "use strict";
589
590    var oldXHR;
591    function newXHR() {
592        var realXHR = new oldXHR();
593        realXHR.addEventListener("readystatechange", function() {
594            if(realXHR.readyState===4 && realXHR.status===200
595                    && realXHR.responseURL.indexOf("epoch-api") !== -1 &&
596                    ( realXHR.responseURL.indexOf("submit_comment") !== -1 ))
597            {
598                umgAAL.track.comment('page',epoch_vars.post_id,document.title);
599            }
600        }, false);
601        return realXHR;
602    }
603    $(window).load(function() {
604        //If comments on page and epoch tracking enabled track Ajax comment post events
605        if(typeof(UMGAALWP.plugins.epoch) !== 'undefined' && UMGAALWP.plugins.epoch && typeof(epoch_vars) !== 'undefined') {
606            //Detect Ajax calls to EPOCH
607            oldXHR = window.XMLHttpRequest;
608            window.XMLHttpRequest = newXHR;
609        }
610    });
611
612})(jQuery);
613
614jQuery(document).on('click', '#_evidon-decline-button, #_evidon-accept-button, #evidon-prefdiag-accept, #evidon-prefdiag-decline, #evidon-prefdiag-closeicon', function(){
615	processEvidonConsent();
616});
617
618jQuery(document).ready(function() {   
619    if (typeof (UMGAALWP.services) !== 'undefined' && (typeof UMGAALWP.services.you_tube) !== 'undefined' && UMGAALWP.services.you_tube)
620    {
621        // Cascade consent tools - first check for Evidon  and if that isn't found, then check for Transcend (airgap)
622        // Evidon is on the way out but we still need to cater for it during migration.
623        // Once Evidon is decommissioned everywhere, we can just leave Transcend (airgap) checks in place.
624
625        // Cater for Evidon being in place on the site
626        waitFor('evidon', function() {
627            UMGAALWP.helpers.debugOutput('AAL: Found Evidon');
628            // check if evidon is active and wait until consent has been given before dropping in the YT scripts
629            // otherwise add the scripts regardless
630            if(typeof window.evidon !== 'undefined') {
631                waitForLocalStorage('_evidon_consent_ls_', function(){
632                    processEvidonConsent();
633                });
634            }
635        }, function(){
636            UMGAALWP.helpers.debugOutput('AAL: Couldnt find Evidon.');
637
638            // Cater for Transcend (airgap) being in place on the site
639            UMGAALWP.helpers.debugOutput('AAL: Looking for Transcend');
640            waitFor('airgap', function() {
641                // check if Transcend is active and wait until consent has been given before dropping in the YT scripts
642                // otherwise add the scripts regardless
643                UMGAALWP.helpers.debugOutput('AAL: Found Transcend');
644                // This checks that we have airgap and that it's functional. If we don't do this check and domain
645                // isn't whitelisted, it will cause an error
646                if(typeof window.airgap !== 'undefined' && typeof window.airgap.addEventListener !== 'undefined') {
647                    airgap.addEventListener(
648                        'consent-change',
649                        ({ detail: { consent, oldConsent, changes } }) => {
650                            UMGAALWP.helpers.debugOutput('AAL: Detected consent change');
651                            if (consent.purposes.Advertising || consent.purposes.Analytics) {
652                                insertYouTubeScripts();
653                            }
654                        },
655                    );
656                    // Check consent
657                    processTranscendConsent();
658                } else {
659                    UMGAALWP.helpers.debugOutput('AAL: Transcend not active. Potentially need to whitelist domain.');
660                }
661            }, function() {
662                // No consent platform found. Defaulting to include scripts.
663                insertYouTubeScripts(); // can't find evidon object so drop cookies
664            });
665        });
666    } else {
667        UMGAALWP.helpers.debugOutput('AAL: No YouTube service identified');
668        // services may well be set but the youtube option is not selected
669        insertYouTubeScripts();
670    }
671});
672
673function checkEvidon(){
674    UMGAALWP.helpers.debugOutput('AAL: Couldnt find Transcend. Looking for Evidon.');
675
676
677
678}
679
680function processTranscendConsent() {
681    let currentConsent = window.airgap.getConsent();
682    if (typeof currentConsent.purposes !== 'undefined') {
683        if (currentConsent.purposes.Advertising || currentConsent.purposes.Analytics) {
684            insertYouTubeScripts();
685        }
686    }
687}
688
689function processEvidonConsent(){
690	currentWaitAttempts = 0;
691	waitFor('evidon.notice',function(){
692		setTimeout(function(){
693			let getVendorList=window.evidon.notice.vendorList;
694			let getActiveCategories=window.evidon.notice.activecategorySet;
695			let consentedCategories=window.evidon.notice._getConsentedCategories();
696			let setYouTubeVendorID=0;
697			let setYouTubeCategory='';
698			let setHandleFunction='';
699			let searchActiveCategories=true;
700			let handleFunctionFired=false;
701
702			Object.keys(getVendorList).forEach(key=>{
703				if(getVendorList[key]=='youtube'){
704					setYouTubeVendorID=parseInt(key);
705				}
706			});
707
708			Object.keys(getActiveCategories).every(categoryKey=>{
709				Object.keys(getActiveCategories[categoryKey].vendors).every(vendorIDKey=>{
710					setHandleFunction=getActiveCategories[categoryKey].name.replace(/ /g,'');
711					if(vendorIDKey==setYouTubeVendorID){
712						setYouTubeCategory=categoryKey;
713						searchActiveCategories=false;
714						return false;
715					}
716					return true;
717				});
718				if(!searchActiveCategories){
719					return false;
720				}
721				return true;
722			});
723
724			switch(setHandleFunction){
725				case'OnlineAdvertising':
726					window.evidon.handleOnlineAdvertising=function(){
727						insertYouTubeScripts();
728						handleFunctionFired=true;
729					}
730					break;
731
732				case'PerformanceandAnalytics':
733					window.evidon.handlePerformanceandAnalytics=function(){
734						insertYouTubeScripts();
735						handleFunctionFired=true;
736					}
737					break;
738				}
739				
740				if(
741					!handleFunctionFired
742					&&setYouTubeVendorID!==0
743					&&setYouTubeCategory!==''
744					&&consentedCategories[setYouTubeCategory]
745				){
746					insertYouTubeScripts();
747			}
748		}, 1000);
749	},function(){
750        UMGAALWP.helpers.debugOutput('AAL: Cannot find evidon notice');
751	});
752}
753
754function insertYouTubeScripts()
755{
756    if (!youTubeScriptsOutput) {
757        UMGAALWP.helpers.debugOutput('Loading YouTube scripts');
758        //Tracking for YouTube
759        tagYTPlayerAPI = document.createElement('script');
760        tagYTPlayerAPI.src = "//www.youtube.com/player_api";
761
762        firstScriptTag = document.getElementsByTagName('script')[0];
763        firstScriptTag.parentNode.insertBefore(tagYTPlayerAPI, firstScriptTag);
764
765        tagIframeAPI = document.createElement('script');
766        tagIframeAPI.src = "https://www.youtube.com/iframe_api";
767
768        secondScriptTag = document.getElementsByTagName('script')[0];
769        secondScriptTag.parentNode.insertBefore(tagIframeAPI, secondScriptTag);
770
771        youTubeScriptsOutput = true;
772    }
773
774}
775
776(function($) {
777    "use strict";
778    var youtubeAAL = (window.youtubeAAL) ? window.youtubeAAL : {};
779    //var youtubeAAL =  {};
780    var YTdeferred = $.Deferred();
781    window.onYouTubeIframeAPIReady = function() {
782        YTdeferred.resolve(window.YT);
783    };
784
785    youtubeAAL = {
786        players : [],
787        details : {},
788        first : false,
789        init: function () {
790            youtubeAAL.setIframes();
791            $('body').bind("DOMSubtreeModified", youtubeAAL.domChange);
792        },
793        youtube_parser : function (url){
794            var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
795            var match = url.match(regExp);
796            return (match&&match[7].length===11)? match[7] : false;
797        },
798        youtubeIframe : function (potentialYouTubeVideo) {
799            var potentialYouTubeVideoSrc = potentialYouTubeVideo.src || '';
800            if( potentialYouTubeVideoSrc.indexOf( 'youtube.com/embed/' ) > -1 ||
801                potentialYouTubeVideoSrc.indexOf( 'youtube.com/v/' ) > -1 ) {
802                return true;
803            }
804            return false;
805        },
806        setPlayer : function(iframe, ytid, iframe_id){
807            var player = new YT.Player($(iframe).attr('id'), {
808                events: {
809                    'onReady': function(){
810                        $(iframe).data('aal-tracking', 'true');
811                        $(iframe).data('aal-tracking-yt-id', ytid);
812                    },
813                    //youtubeAAL.onReady,
814                    'onStateChange':youtubeAAL.onStateChange,
815                }
816            });
817            youtubeAAL.players[ytid] = player;
818            player.details = {
819                'id' : ytid,
820                'title' : '',
821                'paused' : false,
822                'progress25' : false,
823                'progress50' : false,
824                'progress75' : false,
825                'progress90' : false,
826                'progress100': false,
827                'postion_timer' : null,
828                'duration' : 0,
829                'states_array' : [],
830                'current_video_postion' : 0
831            };
832        },
833        onStateChange : function(e){
834            var player = e.target;
835            var player_data = youtubeAAL.getVideoData(player);
836            var video_data = player_data.videoData;
837            player.details.duration = player_data.duration;
838
839
840            if ((e.data === 1
841                    && (player.details.states_array[player.details.states_array.length-1] !== 2)
842                    && player.details.states_array[player.details.states_array.length-1] !== 3)
843                    || (e.data === 1 && player.details.states_array[player.details.states_array.length-1] === 3
844                     && (player.details.states_array[player.details.states_array.length-2] === -1 || player.details.states_array.length < 2) )){
845
846                        umgAAL.track.video('youtube','play',video_data['video_id'], video_data['title']);
847
848            }else if (e.data === 2 && player.details.states_array[player.details.states_array.length-1] === 1){
849                umgAAL.track.video('youtube','pause',video_data['video_id'], video_data['title']);
850            }else if (e.data === 0 && player.details.states_array[player.details.states_array.length-1] === 1){
851                umgAAL.track.video('youtube','stop',video_data['video_id'], video_data['title']);
852            }
853
854            if (e.data === 1){
855                player.details.postion_timer = setInterval(function() {
856                    var new_percent = Math.round((player_data.currentTime/player.details.duration)*100);
857                    if (player.details.percent_played !== new_percent)
858                    {
859                        switch(new_percent) {
860                            case 25:
861                                umgAAL.track.video('youtube','25%',video_data['video_id'], video_data['title']);
862                            break;
863                            case 50:
864                                umgAAL.track.video('youtube','50%',video_data['video_id'], video_data['title']);
865                            break;
866                            case 75:
867                                umgAAL.track.video('youtube','75%',video_data['video_id'], video_data['title']);
868                            break;
869                            case 90:
870                                umgAAL.track.video('youtube','90%',video_data['video_id'], video_data['title']);
871                            break;
872                            case 100:
873                                umgAAL.track.video('youtube','100%',video_data['video_id'], video_data['title']);
874                            break;
875                        }
876                    }
877
878                    if (player.details.current_video_postion===player_data.currentTime){
879                         clearInterval(player.details.postion_timer);
880                    }
881                    player.details.current_video_postion=player_data.currentTime;
882                    player.details.percent_played = new_percent;
883                }, 1000);
884            }
885
886            if (player.details.states_array.length === 5)
887            {
888                player.details.states_array.shift();
889            }
890            player.details.states_array.push(e.data);
891
892            if (e.data === 0 || e.data === 2)
893            {
894                player.details.states_array = [];
895            }
896
897            player.details.current_video_postion = player_data.currentTime;
898
899        },
900        setIframes : function(){
901            $('iframe').each(function(index, iframe) {
902                var yt_id = youtubeAAL.youtube_parser(iframe.src);
903                if ((yt_id && $(this).data('aal-tracking') === undefined) || (yt_id && ($(this).data('aal-tracking-yt-id') !==yt_id)))
904                {
905
906                    if ($(this).attr('id') === undefined)
907                    {
908                        $(this).attr('id', 'player-'+yt_id);
909                    }
910
911                    if ($(this).attr('src').indexOf('enablejsapi=1') === -1){
912                        if ($(this).attr('src').indexOf('?') === -1){
913                            $(this).attr('src', $(this).attr('src') + '?enablejsapi=1');
914                        }else
915                        {
916                            $(this).attr('src', $(this).attr('src') + '&enablejsapi=1');
917                        }
918                    }
919                    youtubeAAL.setPlayer($(this)[0],yt_id, $(this).attr('id'));
920                }
921            });
922        },
923        domChange : function (){
924            youtubeAAL.setIframes();
925        },
926
927        getVideoData: function(videoObj) {
928            /**
929             * Get YouTube Video datablock from video object
930             * - reason for this function is that when other YT.Player are initiating the video then the API functions are not available
931             * - such as getDuration()
932             */
933            for (var prop in videoObj) {
934                if(videoObj.hasOwnProperty(prop)) {
935                    var propValue = videoObj[prop];
936                    if(propValue && typeof propValue !== 'undefined' && typeof propValue.videoData !== 'undefined'
937                        && typeof propValue.duration !== 'undefined') {
938                        return propValue;
939                    }
940                }
941            }
942            return false;
943        }
944    };
945
946    YTdeferred.done(function() {
947        jQuery(window).load(function() {
948            if (typeof (UMGAALWP.services) !== 'undefined' && (typeof UMGAALWP.services.you_tube) !== 'undefined' && UMGAALWP.services.you_tube)
949            {
950               youtubeAAL.init();
951            }
952        });
953    });
954
955})(jQuery);
956
957
958//Stackla
959(function($) {
960    "use strict";
961    var stacklaAAL = window.stacklaAAL ? window.stacklaAAL : {};
962    stacklaAAL = {
963        stackla_items : [],
964        init: function () {
965            Stackla.WidgetManager
966                .on('load', stacklaAAL.onLoad)
967                .on('tileExpand', stacklaAAL.onTileExpand)
968                .on('userClick', stacklaAAL.onUserClick)
969                .on('shareClick', stacklaAAL.onShareClick)
970                .on('moreLoad', stacklaAAL.onLoadMore)
971                .on('productActionClick', stacklaAAL.onProductActionClick);
972        },
973        onLoad : function(e, data){
974            var type = 'custom';
975            if (data.styleName && data.styleName.indexOf('carousel') !== -1)
976            {
977                type = 'carousel';
978                umgAAL.track.photo_gallery_view( data.widgetId, data.name, '', 0 );
979            }
980            else if (data.styleName && data.styleName.indexOf('billboard') !== -1)
981            {
982                type = 'billboard';
983                umgAAL.track.photo_gallery_view( data.widgetId, data.name, '', 0 );
984            }
985            else if (data.styleName && data.styleName.indexOf('feed') !== -1)
986            {
987               type = 'feed';
988               umgAAL.track.photo_gallery_view( data.widgetId, data.name, '', 0 );
989            }
990            else if (data.styleName && data.styleName.indexOf('slideshow') !== -1)
991            {
992                type = 'slideshow';
993                umgAAL.track.photo_gallery_view( data.widgetId, data.name, '', 0 );
994            }
995            else if (data.styleName && data.styleName.indexOf('waterfall') !== -1)
996            {
997               type = 'waterfall';
998               umgAAL.track.photo_gallery_view( data.widgetId, data.name, '', 0 );
999            }
1000            var stackla_obj = {id:data.widgetId,type:type, name:data.name};
1001            stacklaAAL.stackla_items.push(stackla_obj);
1002        },
1003        onTileExpand : function(e, data){
1004            if (data.tileData.media === 'video' && data.tileData.source!=='youtube' && data.tileData.source!=='vimeo'){
1005                umgAAL.track.video(data.tileData.source,'play',data.widgetId, data.tileData.message);
1006            }
1007            else if (data.tileData.media === 'audio' && data.tileData.source!=='soundcloud'){
1008                umgAAL.track.audio(data.tileData.source, 'play', data.widgetId, data.tileData.message);
1009            }
1010        },
1011        onUserClick : function (e, data){
1012            if (data.tileData.author_link)
1013            {
1014                umgAAL.track.outbound_link( data.tileData.author_link );
1015            }
1016            else
1017            {
1018                umgAAL.track.outbound_link( data.tileData.original_url );
1019            }
1020        },
1021        onShareClick : function(e, data){
1022            umgAAL.track.share( data.shareNetwork, data.tileData.media, data.widgetId, data.tileData.message );
1023        },
1024        onLoadMore : function (e, data) {
1025            var stackla_obj = stacklaAAL.getStacklaItemById(data.widgetId);
1026            if (stackla_obj !== null
1027                  /*
1028                    &&
1029                (stackla_obj.type === 'slideshow'
1030                || stackla_obj.type === 'carousel'
1031                || stackla_obj.type === 'billboard')
1032                */
1033               ){
1034
1035                umgAAL.track.photo_gallery_load_more( stackla_obj.id, stackla_obj.name, '', data.page );
1036            }
1037        },
1038        onProductActionClick: function(e, data){
1039
1040            var store = '';
1041            var dest_url = '';
1042            if (data.productTag)
1043            {
1044                if (data.productTag.custom_url)
1045                {
1046                    dest_url = data.productTag.custom_url;
1047                }
1048                if (data.productTag.tag)
1049                {
1050                    store = data.productTag.tag;
1051                }
1052            }
1053            umgAAL.track.merch_link( store, dest_url )
1054        },
1055        getStacklaItemById : function(id){
1056            for (var i = 0; i < stacklaAAL.stackla_items.length; i++) {
1057                if (stacklaAAL.stackla_items[i].id === id)
1058                {
1059                   return stacklaAAL.stackla_items[i];
1060                }
1061            }
1062            return null;
1063        }
1064    };
1065    if (UMGAALWP.plugins.stackla && typeof(umgAAL) != 'undefined' )
1066    {
1067        stacklaAAL.init();
1068    }
1069})(jQuery);
1070
1071
1072//Slider Revolution
1073(function($) {
1074    "use strict";
1075    if (UMGAALWP.plugins.revslider && typeof(umgAAL) != 'undefined' )
1076    {
1077        $(window).load(function() {
1078            $(document).ready(function(){
1079                //Get Slider Title From AAL JSON
1080                function get_revslider_details(alias){
1081                    for (var i = 0; i < UMGAALWP.data.revslider_slider.length; i++) {
1082                        if (UMGAALWP.data.revslider_slider[i].alias === alias)
1083                        {
1084                            return UMGAALWP.data.revslider_slider[i];
1085                        }
1086                    }
1087                    return null;
1088                }
1089                //Get loop though all Sliders on the Page
1090                $('.rev_slider_wrapper').each(function() {
1091                    var alias = $(this).data('alias');
1092                    var source = $(this).data('source');
1093
1094                    if (source === 'gallery' || source === 'flickr' || source === 'instagram')
1095                    {
1096                        var slider_details = get_revslider_details(alias);
1097                        var title = '';
1098                        var id = '';
1099                        if (slider_details !== null)
1100                        {
1101                            title = slider_details.title;
1102                            id = slider_details.id;
1103                        }
1104                        umgAAL.track.photo_gallery_view( id, title);
1105                    }
1106                });
1107            });
1108        });
1109    }
1110})(jQuery);

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.