1(function (global) { 2 function b64DecodeUnicode(str) { 3 // Convert base64 to a string 4 const binaryString = atob(str); 5 6 // Convert binary string to a byte array 7 const byteArray = new Uint8Array(binaryString.length); 8 for (var i = 0; i < binaryString.length; i++) { 9 byteArray[i] = binaryString.charCodeAt(i); 10 } 11 // Convert byte array to a string 12 const decoder = new TextDecoder('utf-8'); 13 return decoder.decode(byteArray); 14 } 15 16 global.insiteScripts = global.insiteScripts || {}; 17 global.insiteScripts.message = 18 global.insiteScripts.message || 19 function message(scriptOptions) { 20 window?.waitForDeferred?.('dmAjax', () => { 21 const dmSmartScriptSettings = scriptOptions.settings, 22 dmSmartScriptRuleId = scriptOptions.ruleId, 23 dmSmartScriptDontParseSettings = 24 scriptOptions.dontParseSettings; 25 26 // don't show a notification if another notification is currently displaying 27 const currentNotification = document.querySelector( 28 '#d-notification-bar' 29 ); 30 if ( 31 currentNotification && 32 !currentNotification.getAttribute('data-was-shown') 33 ) { 34 return; 35 } 36 const settings = dmSmartScriptDontParseSettings 37 ? dmSmartScriptSettings 38 : JSON.parse(b64DecodeUnicode(dmSmartScriptSettings)); 39 const messageBody = decodeURIComponent(settings.body);
40 const messageBackground = settings.background 41 ? decodeURIComponent(settings.background) 42 : undefined; 43 // Optional appearance value written by the React personalization 44 // wizard. Older rules omit it and the runtime then sets no 45 // custom property, so the bar keeps its stylesheet default. 46 const messagePaddingBlock = settings.paddingBlock; 47 48 const canShowNotification = function ( 49 dmSmartScriptRuleId, 50 settings 51 ) { 52 if (shouldCheckMultipleConditions) { 53 const { conditionsToCheck } = 54 shouldShowActionRule(settings); 55 56 if (!conditionsToCheck) { 57 return true; //meaning conditions are filtered in BE 58 } else { 59 return conditionsToCheck.every( 60 ({ condition, callback }) => { 61 return ( 62 callback && 63 callback( 64 dmSmartScriptRuleId, 65 condition, 66 ActionType.MESSAGE 67 ) 68 ); 69 } 70 ); 71 } 72 } else { 73 const { 74 shouldCheckUserVisitsCondition, 75 shouldCheckDateTimeRangeCondition, 76 } = shouldShowActionRule(settings); 77 78 if (shouldCheckUserVisitsCondition) { 79 return shouldShowRuleObjectForUserVisit( 80 dmSmartScriptRuleId, 81 settings, 82 ActionType.MESSAGE 83 ); 84 } 85 if (shouldCheckDateTimeRangeCondition) { 86 return shouldShowRuleObjectForDateTimeRange( 87 dmSmartScriptRuleId, 88 settings, 89 ActionType.MESSAGE 90 ); 91 } 92 return true; 93 } 94 }; 95 96 const shouldShowMessage = 97 canShowNotification(dmSmartScriptRuleId, settings) && 98 scriptOptions.useNew && 99 'runtime' in window; 100 101 if (shouldShowMessage) { 102 setSmartRuleCookie(dmSmartScriptRuleId, ActionType.MESSAGE); 103 setTimeout(() => { 104 $(global.document).ready(function () { 105 const layoutContainer = 106 document.querySelector('[dmtemplateid]'); 107 108 return global.runtime.notify({ 109 markup: messageBody, 110 delay: Math.max(settings.delay || 1, 1.5), 111 messageContainer: layoutContainer,
112 background: messageBackground, 113 paddingBlock: messagePaddingBlock, 114 duration: scriptOptions.duration || -1, 115 shouldMoveContainer: 116 !!window.flexSite || 117 !/amburger/i.test( 118 layoutContainer.getAttribute( 119 'dmtemplateid' 120 ) 121 ) 122 }); 123 }); 124 }, 0); 125 return; 126 } 127 // scriptOptions.useNew was false or window.runtime wasn't 128 // present. A legacy jQuery fallback bar used to live here, 129 // built from a messageDiv/closeTrigger and only ever shown 130 // by triggerMessage â which itself started with 131 // `if (!shouldShowMessage) return;`, so with shouldShowMessage 132 // false that fallback could never display anything. Removed 133 // as dead code (see git history); there is nothing left to do. 134 }); 135 }; 136})(this);
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.