1var trigger = false; 2 3var url = new URL(window.location.href); 4var searchParams = new URLSearchParams(url.search); 5var replaceUrl = false; 6 7if ('undefined' === typeof window.kuuid) { 8 var inIframe = isInIframe(); 9 var uuid = ''; 10 11 if (inIframe) { 12 if (searchParams.has('kuid')) { 13 uuid = searchParams.get('kuid'); 14 } else if (getCookieFront('kuuid')) { 15 uuid = getCookieFront('kuuid'); 16 } 17 } else { 18 uuid = getCookieFront('kuuid'); 19 20 if (!uuid) { 21 var kartraReferrer = searchParams.get('kref'); 22 var kartraLid = searchParams.get('lid'); 23 24 if ( 25 searchParams.has('kuid') 26 && kartraReferrer 27 && (document.referrer || kartraLid) 28 ) { 29 uuid = searchParams.get('kuid'); 30 } 31 } 32 } 33 34 if ( 35 !uuid 36 || !validateKuuid(uuid) 37 ) { 38 uuid = generateKuuid(); 39 } 40 41 window.kuuid = uuid; 42 43 setCookieFront( 44 'kuuid', 45 uuid, 46 { 47 path: '/', 48 days: 30, 49 secure: true, 50 samesite: 'none', 51 } 52 ); 53 54 if (searchParams.has('kuid')) { 55 url.searchParams.delete('kuid'); 56 57 replaceUrl = true; 58 } 59} 60 61 62if ('undefined' === typeof window.kll) { 63 var kll = ''; 64 65 if (searchParams.has('kll')) { 66 kll = searchParams.get('kll'); 67 } else if (getCookieFront('kll')){ 68 kll = getCookieFront('kll'); 69 } 70 71 window.kll = kll; 72 73 if (searchParams.has('kll')) { 74 url.searchParams.delete('kll'); 75 76 replaceUrl = true; 77 } 78} 79 80if (replaceUrl) { 81 window.history.replaceState( 82 null, 83 null, 84 url.toString() 85 ); 86} 87 88$(document).ready(function(){ 89 initConfirmActionPopovers(); 90 91 if( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) { 92 try { 93 $('.selectpicker').selectpicker('mobile'); 94 } catch {} 95 } 96 97 if ('undefined' !== typeof $.fn.popover) { 98 $.fn.popover.Constructor.prototype.recalculatePosition = function() { 99 var $tip = this.tip(); 100 101 if ($tip.is(':visible')) { 102 var placement = typeof this.options.placement == 'function' ? this.options.placement.call(this, $tip[0], this.$element[0]) : this.options.placement, 103 autoToken = /\s?auto?\s?/i, 104 autoPlace = autoToken.test(placement); 105 106 if (autoPlace) { 107 placement = placement.replace(autoToken, '') || 'top'; 108 } 109 110 $tip.addClass(placement); 111 112 var pos = this.getPosition(), 113 actualWidth = $tip[0].offsetWidth, 114 actualHeight = $tip[0].offsetHeight; 115 116 if (autoPlace) { 117 var orgPlacement = placement, 118 viewportDim = this.getPosition(this.$viewport); 119 120 placement = placement === 'bottom' && pos.bottom + actualHeight > viewportDim.bottom ? 'top' : 121 placement === 'top' && pos.top - actualHeight < viewportDim.top ? 'bottom' : 122 placement === 'right' && pos.right + actualWidth > viewportDim.width ? 'left' : 123 placement === 'left' && pos.left - actualWidth < viewportDim.left ? 'right' : 124 placement; 125 126 $tip.removeClass(orgPlacement).addClass(placement); 127 } 128 129 var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight); 130 131 this.applyPlacement(calculatedOffset, placement); 132 } 133 }; 134 } 135 136 $('body').on('click', function (e) { 137 //did not click a popover toggle or popover 138 139 var $target = $(e.target).is('i') ? $(e.target).parent() : $(e.target); 140 141 if ($target.parents('.popover.in').length === 0) { 142 if (typeof $target.data('bs.popover') !== 'undefined') { 143 $('.js_confirm_action_popover').not($target.data('bs.popover')['$element']).popover('hide'); 144 } else { 145 $('.js_confirm_action_popover').popover('hide'); 146 147 trigger = false;
148 } 149 } 150 }); 151 152 $(document).on('click', '.js_confirm_action_popover', function(e){ 153 154 var $trigger = $(this), 155 callback = $trigger.attr('data-callback-function'); 156 157 displayConfirmActionPopover($trigger, callback); 158 }); 159 160 $(document).on('mouseenter', '.js_confirm_action_popover', function(e){ 161 var $self = $(this), 162 popoverData = $self.data('bs.popover'); 163 164 if ('undefined' !== typeof popoverData) { 165 var $popover = popoverData.tip(); 166 167 if (null !== e.relatedTarget && $popover.hasClass('in') && trigger) { 168 $self.popover('hide'); 169 trigger = false; 170 } 171 } 172 }); 173 174 $(document).on('click', '.popover .js_popover_close', function(){ 175 var $self = $(this); 176 177 $self.parents('.popover:first').popover('hide'); 178 179 trigger = false; 180 }); 181 182 if ($('select.js_language_dropdown:not(.js_no_action )').length) { 183 var currentLanguage = $('select.js_language_dropdown:not(.js_no_action ) option:selected').attr('data-internationalization'); 184 $('body').addClass('lang-var-' + currentLanguage); 185 } 186 187 $(document).on('change', 'select.js_language_dropdown:not(.js_no_action)', function() { 188 var $languageDropdown = $(this), 189 languageId = $languageDropdown.val(), 190 baseUrl = window.jsVars.secure_base_url 191 || window.jsVars.app_base_url 192 || '', 193 encodedMemberId = window.jsVars.encoded_member_id; 194 195 $languageDropdown.attr('disabled', true); 196 197 // Ignore if we don't have selectpicker 198 try { 199 $languageDropdown.selectpicker('refresh'); 200 } catch {} 201 202 if (languageId) { 203 var requestUrl = baseUrl + 'api-external/languages/cookie'; 204 205 $.ajax({ 206 url : requestUrl, 207 type : 'POST', 208 xhrFields : { 209 withCredentials : true 210 }, 211 data : { 212 'language-id' : languageId, 213 'encoded-member-id' : encodedMemberId, 214 'kuid' : 'undefined' !== typeof window.kuuid ? window.kuuid : '' 215 } 216 }).done(function() { 217 if (!isKartraDomain(window.location.host)) { 218 $.ajax({ 219 url : 'https://' + window.location.host + '/api-external/languages/cookie', 220 type : 'POST', 221 data : { 222 'language-id' : languageId, 223 'encoded-member-id' : encodedMemberId, 224 'kuid' : 'undefined' !== typeof window.kuuid ? window.kuuid : '' 225 }, 226 xhrFields: { 227 withCredentials: true 228 } 229 }).done(function() { 230 if ('undefined' !== typeof windowProxy) { 231 windowProxy.post({ 232 message: 'kt-frame-reload' 233 }); 234 } else { 235 window.location.reload(); 236 } 237 }); 238 } else { 239 if ('undefined' !== typeof windowProxy) { 240 windowProxy.post({ 241 message: 'kt-frame-reload' 242 }); 243 } else { 244 window.location.reload(); 245 } 246 } 247 }); 248 } 249 }); 250 251 $('select.js_language_dropdown_tooltip').on('loaded.bs.select', function(ev) { 252 var $languageDropdown = $(this); 253 254 if ( 255 $languageDropdown 256 && $languageDropdown.length 257 ) { 258 var $dropdownTrigger = $languageDropdown.siblings('.btn.dropdown-toggle'), 259 $selectedLanguageOption = $languageDropdown.find('option:selected'), 260 selectedOption = ''; 261 262 if ($selectedLanguageOption.length) { 263 selectedOption = $selectedLanguageOption.text(); 264 } 265 266 if ($dropdownTrigger.length) { 267 $dropdownTrigger.tooltip({ 268 container: 'body', 269 trigger: 'hover', 270 placement: 'bottom', 271 title: selectedOption, 272 }); 273 274 $dropdownTrigger.on('click', function() { 275 var $trigger = $(this); 276 277 $trigger.tooltip('hide'); 278 }); 279 } 280 } 281 }); 282 283 $(document).on('click', '.js_iframe_download_button', function(ev) { 284 ev.preventDefault(); 285 286 var $button = $(this); 287 288 if ($button.hasClass('disabled')) { 289 return false;
290 } 291 292 var url = $button.attr('href'); 293 294 window.parent.postMessage({ 295 message: 'kt-frame-windowOpen', 296 payload: { 297 frame: window.name, 298 url: url, 299 } 300 }, '*'); 301 }); 302}); 303 304$(window).load(function () { 305 var leadModalTooltipShown = false, 306 $headerElement = $('.js_header_element'), 307 $leadLoginModalToggle = $('.js_profile_actions', $headerElement), 308 $navbarToggle = $('.navbar-toggle', $headerElement); 309 310 if ('undefined' !== typeof window.jsVars && 'undefined' !== typeof window.jsVars['kartra_profile_icon_tooltip']) { 311 leadModalTooltipShown = parseInt(window.jsVars['kartra_profile_icon_tooltip']) !== 0; 312 } 313 314 if ($headerElement.length && $leadLoginModalToggle.length) { 315 //We need to check if we are on a mobile view or not. 316 //If the navbar-toggle is visible, then it's mobile 317 318 if ($navbarToggle.is(':visible') && false === leadModalTooltipShown) { 319 var title = $('#lead_profile').length ? 'My Profile' : 'Login'; 320 321 $navbarToggle.tooltip({ 322 container: 'body', 323 viewport : { 324 selector: '.js_header_element', 325 padding : 0 326 327 }, 328 template : '<div class="tooltip tooltip_red tooltip_blink_anim" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>', 329 title : title, 330 placement: 'left' 331 }); 332 333 setTimeout(function () { 334 $navbarToggle.tooltip('show'); 335 leadModalTooltipShown = true; 336 337 setTimeout(function () { 338 $navbarToggle.tooltip('destroy'); 339 }, 5000); 340 341 }, 1000); 342 } else { 343 if (false === leadModalTooltipShown && $leadLoginModalToggle.length) { 344 setTimeout(function () { 345 $leadLoginModalToggle.tooltip('show'); 346 leadModalTooltipShown = true; 347 348 setTimeout(function () { 349 $leadLoginModalToggle.tooltip('hide'); 350 }, 5000); 351 352 }, 1000); 353 } 354 355 $leadLoginModalToggle.on('inserted.bs.tooltip', function (e) { 356 var tooltip = $(e.target).data('bs.tooltip'); 357 358 if (leadModalTooltipShown) { 359 tooltip.$tip.removeClass('tooltip_red tooltip_blink_anim'); 360 } else { 361 tooltip.$tip.addClass('tooltip_red tooltip_blink_anim'); 362 } 363 }); 364 } 365 } 366}); 367 368function initConfirmActionPopovers($element) { 369 if ('undefined' === typeof $element) { 370 $element = $('.js_confirm_action_popover'); 371 } 372 373 if ($element.length) { 374 $element.each(function(){ 375 var $popover = $(this), 376 contentSource = $popover.attr('data-content-source'), 377 classes = $popover.attr('data-classes'), 378 actionObject = $popover.attr('data-action-object'), 379 popoverContainer = $popover.attr('data-popover-container'); 380 381 if ('undefined' === typeof classes) { 382 classes = ''; 383 } 384 385 if ('undefined' === typeof popoverContainer) { 386 popoverContainer = ''; 387 } 388 389 $popover.popover({ 390 placement: 'top', 391 template: '<div class="popover popover_v2 popover-w-def ' + classes + '" role="tooltip"><div class="arrow"></div><div class="popover-content"></div></div>', 392 html: 'true', 393 container: popoverContainer, 394 trigger: 'manual', 395 content: function() { 396 if ($(contentSource).length) { 397 if ('undefined' !== typeof actionObject) { 398 try { 399 var object = $.parseJSON(actionObject); 400 401 $.each(object, function(key, value){ 402 $(contentSource).find('.js_popover_action').attr('data-' + key, value); 403 }); 404 } 405 catch (e) {} 406 } 407 408 return $(contentSource).html(); 409 } 410 } 411 }); 412 }); 413 } 414} 415
416function displayConfirmActionPopover($trigger, callback) { 417 var $openPopovers = $('.popover.in'); 418 419 $('[data-toggle="tooltip"]').tooltip('hide'); 420 421 if ($openPopovers.length === 0 || ($openPopovers.length > 0 && $($trigger).get(0) !== $openPopovers.data('bs.popover')['$element'].get(0))) { 422 $($trigger).popover('show'); 423 trigger = true; 424 425 if ('function' === typeof window[callback]) { 426 window[callback]($trigger, $openPopovers); 427 } 428 } 429} 430 431function setBackgroundContrast($elementGetColor, $elementSetColor) { 432 var backgroundColor = $elementGetColor.css('background-color'); 433 434 // Firefox sometimes is not returning the correct background color 435 if(!backgroundColor) { 436 backgroundColor = $elementGetColor[0].style.backgroundColor; 437 } 438 439 if (!backgroundColor) { 440 return; 441 } 442 443 $elementSetColor.removeClass('dark-white'); 444 445 if ('transparent' === backgroundColor || 'rgba(0, 0, 0, 0)' === backgroundColor) { 446 $elementSetColor.addClass('dark').removeClass('light'); 447 } else if ('rgb(255, 255, 255)' === backgroundColor) { 448 $elementSetColor 449 .removeClass('light') 450 .addClass('dark dark-white'); 451 } else { 452 var luminance = calculateLuminance(backgroundColor); 453 454 if (luminance > 200) { 455 $elementSetColor.addClass('dark').removeClass('light'); 456 } else { 457 $elementSetColor.addClass('light').removeClass('dark'); 458 } 459 } 460} 461 462function calculateLuminance(rgb) { 463 var [r, g, b] = rgb.match(/[\d\.]+/g), 464 luminance = Math.round(((parseInt(r) * 299) + (parseInt(g) * 587) + (parseInt(b) * 114)) / 1000); 465 466 return luminance; 467} 468 469//Handles the export file download in the frontend area 470function checkExportStatus(exportPaths, shortPollingInterval) { 471 var $pendingModal = $('.js_pending_modal'), 472 downloaded = false, 473 checkStatus = setInterval(function() { 474 $.post('/exports/checkExportStatus', { 475 'exportPaths' : exportPaths 476 }, function(downloadUrl) { 477 if (downloadUrl && !downloaded) { 478 window.location = downloadUrl[0]; 479 480 clearInterval(checkStatus); 481 482 if (typeof downloadUrl[1] !== 'undefined') { 483 var checkStatusSecond = setInterval(function() { 484 window.location = downloadUrl[1]; 485 downloaded = true; 486 487 clearInterval(checkStatusSecond); 488 489 $pendingModal.modal('hide'); 490 }, 1000); 491 } else { 492 $pendingModal.modal('hide'); 493 downloaded = true; 494 } 495 } 496 }); 497 }, shortPollingInterval); // short polling every X seconds 498} 499 500//checks if url is kartra domain or not 501function isKartraDomain(domain) { 502 var domainRegex = new RegExp('(.+?\\.)?(kartra|kartradev)\\.com'), 503 domainMatch = domainRegex.exec(domain); 504 return null !== domainMatch; 505} 506 507function generateUUID() { 508 var d = new Date().getTime(); 509 var d2 = ( 510 'undefined' !== typeof performance 511 && performance.now 512 && (performance.now() * 1000) 513 ) 514 || 0; 515 516 return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { 517 var r = Math.random() * 16; 518 519 if (d > 0) { 520 r = (d + r) % 16 | 0; 521 d = Math.floor(d / 16); 522 } else { 523 r = (d2 + r) % 16 | 0; 524 d2 = Math.floor(d2 / 16); 525 } 526 527 return ( 528 c === 'x' 529 ? r 530 : (r & 0x3 | 0x8) 531 ).toString(16); 532 }); 533} 534 535function generateKuuid() { 536 var uuid = generateUUID(); 537 var currentUnixTimestamp = Math.floor(Date.now() / 1000); 538 539 return uuid + '-' + currentUnixTimestamp; 540} 541 542function getCookieFront(name) { 543 var cookieRegex = '(?:(?:^|.*; *)' + name + ' *= *([^;]*).*$)|^.*$'; 544 var cookie = document.cookie.match(cookieRegex)[1]; 545 546 if (cookie) { 547 return decodeURIComponent(cookie); 548 } 549} 550 551function setCookieFront(name, value, options) { 552 options = options || {}; 553 554 // If 'days' is provided, calculate max-age in seconds 555 if (options.days) { 556 options['max-age'] = options.days * 60 * 60 * 24; 557 558 delete options.days; 559 } 560 561 // Build the options string from the options object 562 var optionsStr = Object.keys(options).reduce( 563 function(acc, key) { 564 return acc + '; ' + key + '=' + options[key]; 565 }, 566 '' 567 ); 568 569 // Get the current document domain and split it by '.' 570 var domain = document.domain; 571 var parts = domain.split('.'); 572 573 // Build an array of all possible domain variants 574 // For example, for "subdomain.abc.co.uk" this will yield: 575 // ["subdomain.abc.co.uk", "abc.co.uk", "co.uk"] 576 var domains = []; 577 578 if (parts.length > 1) { 579 for (var i = 0; i < parts.length - 1; i++) { 580 domains.push(parts.slice(i).join('.')); 581 } 582 } else { 583 domains = [domain]; 584 } 585 586 // Set the cookie for each domain variant 587 for (var j = 0; j < domains.length; j++) { 588 document.cookie = name + '=' + encodeURIComponent(value) + optionsStr + '; path=/; domain=' + domains[j]; 589 } 590} 591 592function validateKuuid(uuid) { 593 // Explode the string by the dash 594 var segments = uuid.split('-'); 595 596 // Check if the 6th segment exists & is a valid UNIX timestamp 597 if ( 598 segments.length >= 6 599 && segments[5] 600 ) { 601 return isValidUnixTimestamp(segments[5]); 602 } 603 604 // If no 6th segment, check the current time against the threshold 605 var currentTimestamp = Math.floor(Date.now() / 1000); // Current UNIX timestamp in seconds 606 var thresholdTimestamp = 1728950400; // 15 Oct 2024 00:00:00 UNIX timestamp 607 608 // Validate if the current timestamp is before the threshold 609 return currentTimestamp < thresholdTimestamp; 610} 611 612function isInIframe() { 613 try { 614 return window.self !== window.top; 615 } catch (e) { 616 return true; 617 } 618} 619 620function isValidUnixTimestamp(timestamp) { 621 var timestampInteger = parseInt(timestamp, 10); 622 623 return !isNaN(timestampInteger) 624 && timestampInteger > 0 625 && timestamp.length === 10; 626}
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.