1(function () { 2 'use strict'; 3 4 // ââ Core âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 5 6 function normalize(str) { 7 return (str || '').replace(/\s+/g, ' ').trim().toLowerCase(); 8 } 9 10 function ascTrackMediaInteraction(element, payload) { 11 var dl = window.asc_datalayer; 12 if (!dl) return; 13 14 window.ascPublishEvent({ 15 event: 'asc_media_interaction', 16 event_owner: 'intice', 17 page_type: dl.page_type || '', 18 page_location: window.location.href, 19 media_type: payload.media_type || '', 20 event_action_result: payload.event_action_result || '', 21 link_url: payload.link_url || '', 22 creative_name: payload.creative_name || '', 23 items: dl.items || [], 24 }); 25 } 26 27 function dataAttr(el, name) { 28 if (!el) return ''; 29 var val = el.getAttribute('data-asc-' + name); 30 if (val) return val; 31 var parent = el.closest('[data-asc-' + name + ']'); 32 return parent ? (parent.getAttribute('data-asc-' + name) || '') : ''; 33 } 34 35 function linkUrl(el) { 36 var a = el && (el.tagName === 'A' ? el : el.closest('a')); 37 return (a && a.href) ? a.href.toLowerCase() : ''; 38 } 39 40 function filenameSlug(url) { 41 return normalize((url || '').split('/').pop().replace(/\?.*$/, '').replace(/\.[^.]+$/, '')); 42 } 43 44 // ââ 360 / Spin buttons ââââââââââââââââââââââââââââââââââââââââââââââââââââ 45 46 var SPIN_TYPE_MAP = { 47 'spin-evo': { media_type: '360_platform', event_action_result: 'spin', creative_name: '360_spin' }, 48 'spin-evox': { media_type: '360_platform', event_action_result: 'spin', creative_name: '360_spin' }, 49 'spin-impel': { media_type: '360_platform', event_action_result: 'spin', creative_name: '360_spin' }, 50 'spin-autoexact': { media_type: '360_platform', event_action_result: 'spin', creative_name: '360_spin' }, 51 'spin-lesa': { media_type: '360_platform', event_action_result: 'spin', creative_name: '360_spin' }, 52 'spin-autoport': { media_type: '360_platform', event_action_result: 'spin', creative_name: '360_spin' }, 53 'spin-video': { media_type: 'video', event_action_result: 'play', creative_name: 'walkaround_video' }, 54 }; 55 56 document.addEventListener('click', function (e) { 57 var btn = e.target.closest('.btn-spin'); 58 if (!btn) return; 59 60 var defaults = { media_type: '360_platform', event_action_result: 'spin', creative_name: '360_spin' }; 61 62 for (var cls in SPIN_TYPE_MAP) { 63 if (btn.classList.contains(cls)) { 64 defaults = SPIN_TYPE_MAP[cls]; 65 break; 66 } 67 } 68 69 ascTrackMediaInteraction(btn, { 70 media_type: dataAttr(btn, 'media-type') || defaults.media_type, 71 event_action_result: dataAttr(btn, 'media-action') || defaults.event_action_result, 72 link_url: linkUrl(btn), 73 creative_name: dataAttr(btn, 'creative-name') || defaults.creative_name, 74 }); 75 }); 76 77 // ââ FancyBox / Lightbox clicks ââââââââââââââââââââââââââââââââââââââââââââ 78 79 document.addEventListener('click', function (e) { 80 var trigger = e.target.closest('[data-fancybox]'); 81 if (!trigger) return; 82 if (trigger.classList.contains('btn-spin')) return; 83 84 var mediaType = dataAttr(trigger, 'media-type'); 85 var actionResult = dataAttr(trigger, 'media-action'); 86 var creative = dataAttr(trigger, 'creative-name'); 87 88 if (!mediaType) { 89 var fbType = trigger.getAttribute('data-type') || ''; 90 if (fbType === 'iframe' || fbType === 'video') { 91 mediaType = 'video'; 92 actionResult = actionResult || 'open'; 93 } else { 94 var group = trigger.getAttribute('data-fancybox') || ''; 95 mediaType = (group.indexOf('gallery') !== -1 || group.indexOf('grid') !== -1) ? 'gallery' : 'image'; 96 actionResult = actionResult || 'popup'; 97 } 98 } 99 100 if (!creative) { 101 var img = trigger.querySelector('img'); 102 if (img) creative = normalize(img.getAttribute('alt') || ''); 103 if (!creative) { 104 var src = trigger.getAttribute('href') || trigger.getAttribute('data-src') || ''; 105 creative = filenameSlug(src); 106 } 107 } 108 109 ascTrackMediaInteraction(trigger, { 110 media_type: mediaType, 111 event_action_result: actionResult || 'popup', 112 link_url: linkUrl(trigger), 113 creative_name: creative, 114 }); 115 }); 116 117 // ââ Slick slider navigation âââââââââââââââââââââââââââââââââââââââââââââââ 118 119 function initSlickTracking($) { 120 $(document).on('click', '.slider-nav-holder .slide, .detail-slider-nav .slide', function () { 121 var el = this; 122 ascTrackMediaInteraction(el, { 123 media_type: dataAttr(el, 'media-type') || 'gallery', 124 event_action_result: dataAttr(el, 'media-action') || 'next_step', 125 link_url: '', 126 creative_name: dataAttr(el, 'creative-name') || 'vehicle_thumbnail', 127 }); 128 }); 129 } 130 131 // ââ Video tracking ââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 132 133 var BGVIDEO_EVENTS = { 134 playingVideo: 'play', 135 pauseVideo: 'stop', 136 endedVideo: 'stop', 137 }; 138 139 function bgVideoCreativeName(el) { 140 var c = dataAttr(el, 'creative-name'); 141 if (c) return c; 142 var data = {}; 143 try { data = JSON.parse(el.getAttribute('data-video') || '{}'); } catch (e) {} 144 var name = data.type ? (data.type + '_video') : 'video'; 145 if (data.video) name += '_' + data.video; 146 return name; 147 } 148 149 function initVideoTracking($) {
150 Object.keys(BGVIDEO_EVENTS).forEach(function (evtName) { 151 $(document).on(evtName, '[data-video]', function () { 152 var el = this; 153 ascTrackMediaInteraction(el, { 154 media_type: dataAttr(el, 'media-type') || 'video', 155 event_action_result: BGVIDEO_EVENTS[evtName], 156 link_url: '', 157 creative_name: bgVideoCreativeName(el), 158 }); 159 }); 160 }); 161 } 162 163 function initNativeVideoTracking() { 164 document.addEventListener('play', function (e) { 165 if (e.target.tagName !== 'VIDEO') return; 166 var el = e.target; 167 ascTrackMediaInteraction(el, { 168 media_type: dataAttr(el, 'media-type') || 'video', 169 event_action_result: 'play', 170 link_url: '', 171 creative_name: dataAttr(el, 'creative-name') || filenameSlug(el.getAttribute('src') || '') || 'html5_video', 172 }); 173 }, true); 174 175 document.addEventListener('pause', function (e) { 176 if (e.target.tagName !== 'VIDEO' || e.target.ended) return; 177 var el = e.target; 178 ascTrackMediaInteraction(el, { 179 media_type: dataAttr(el, 'media-type') || 'video', 180 event_action_result: 'stop', 181 link_url: '', 182 creative_name: dataAttr(el, 'creative-name') || filenameSlug(el.getAttribute('src') || '') || 'html5_video', 183 }); 184 }, true); 185 } 186 187 // ââ Boot ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 188 189 var booted = false; 190 191 function boot() { 192 if (booted) return; 193 booted = true; 194 195 initNativeVideoTracking(); 196 197 if (window.jQuery) { 198 initSlickTracking(window.jQuery); 199 initVideoTracking(window.jQuery); 200 } 201 } 202 203 if (document.readyState === 'loading') { 204 document.addEventListener('DOMContentLoaded', boot); 205 } else { 206 boot(); 207 } 208}());
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.