1document.addEventListener('DOMContentLoaded', function() { 2 3 if (typeof customModalsLinks === 'undefined' || !Array.isArray(customModalsLinks)) { 4 return; 5 } 6 7 const urlParams = new URLSearchParams(window.location.search); 8 let matchFound = false; 9 10 customModalsLinks.forEach(function(link) { 11 if (matchFound) return; 12 13 if (link.trigger_slug && link.target_url) { 14 15 // Define a unique key for this specific campaign 16 const storageKey = 'dv_modal_seen_' + link.trigger_slug; 17 18 if (urlParams.has(link.trigger_slug)) { 19 20 // CHECK: If user already closed this specific modal in this session, do not open 21 if (sessionStorage.getItem(storageKey)) { 22 return; 23 } 24 25 // Create iframe content 26 var iframeHtml = '<iframe src="' + link.target_url + '" style="width:100%; height:70vh; border:none;" title="Content"></iframe>'; 27 28 // Create a dummy jQuery object 29 var $dummyObj = $("<div></div>"); 30 $dummyObj.data("modal-content", iframeHtml); 31 $dummyObj.data("modal-title", ""); 32 33 if (typeof DVPopUp === "function") { 34 DVPopUp( 35 $dummyObj, 36 null, 37 false, 38 '', 39 {}, 40 'dv-automodal-custom' 41 ); 42 43 matchFound = true; 44 45 // SET STORAGE ON CLOSE 46 // We attach a listener to the document to catch the click on the dynamically created close button 47 // We target both the close button (#dv-close-modal) and the background mask (.dv-global-modal-mask) 48 // We use .one() to ensure it only runs once per opening 49 $(document).one('click', '.dv-automodal-custom #dv-close-modal, .dv-automodal-custom .dv-global-modal-mask', function() { 50 sessionStorage.setItem(storageKey, 'true'); 51 }); 52 53 } else { 54 console.error('DVPopUp function is not defined.'); 55 } 56 } 57 } 58 }); 59});
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.