1function getCookie(name) { 2 let cookieArr = document.cookie.split(';'); 3 4 for (let i = 0; i < cookieArr.length; i++) { 5 let cookiePair = cookieArr[i].split('='); 6 7 if (name === cookiePair[0].trim()) { 8 return decodeURIComponent(cookiePair[1]); 9 } 10 } 11 return null; 12} 13 14function hasCookieOfType(actionType) { 15 let cookieArr = document.cookie.split(';'); 16 17 for (let i = 0; i < cookieArr.length; i++) { 18 let cookiePair = cookieArr[i].split('='); 19 20 if (cookiePair[0].trim().includes(actionType)) { 21 return true; 22 } 23 } 24 return false; 25} 26 27function getSmartRuleCookieName(ruleObjName, actionType) { 28 const conditionCheckedInClientEnabled = 29 rtCommonProps[ 30 'platform.monolith.personalization.dateTimeCondition.popupMsgAction.moveToclient.enabled' 31 ]; 32 return conditionCheckedInClientEnabled 33 ? '_dm_showed_' + 34 actionType + 35 '_' + 36 encodeURIComponent(ruleObjName, 'UTF-8') 37 : '_dm_showed_' + encodeURIComponent(ruleObjName, 'UTF-8'); 38} 39 40//after the action happens the first time we set cookie of shown with ttl 41function setSmartRuleCookie(ruleObjName, actionType) { 42 setCookie( 43 getSmartRuleCookieName(ruleObjName, actionType), 44 true, 45 rtCommonProps['popup.insite.cookie.ttl'] 46 ); 47} 48 49function setCookie(name, value, hours) { 50 let expires = ''; 51 52 if (hours) { 53 let date = new Date(); 54 date.setTime(date.getTime() + hours * 60 * 60 * 1000); 55 expires = '; expires=' + date.toUTCString(); 56 } 57 58 document.cookie = 59 name + '=' + encodeURIComponent(value) + expires + '; path=/'; 60} 61 62//have to be var to be in global scope and accessible from other files 63var ActionType = { 64 POPUP: 'popup', 65 MESSAGE: 'message', 66}; 67 68const checkRuleLogicOnFeEnabled = 69 rtCommonProps[ 70 'platform.monolith.personalization.dateTimeCondition.popupMsgAction.moveToclient.enabled' 71 ]; 72 73const shouldCheckMultipleConditions = 74 rtFlags[ 75 'streamline.monolith.personalization.supportMultipleConditions.enabled' 76 ]; 77 78var ConditionType = { 79 USER_VISITS: 'user_visits', 80 ...(checkRuleLogicOnFeEnabled && { 81 USER_IN_DATE_TIME_RANGE: 'user_in_date_time_range', 82 }), 83}; 84 85function checkIfInPreviewMode() { 86 try { 87 return window.parent.location.hash.indexOf('rule_preview') !== -1; 88 } catch { 89 return false; 90 } 91} 92 93function shouldShowActionRule(settings) { 94 const isInPreviewMode = checkIfInPreviewMode(); 95 if (isInPreviewMode) { 96 return {}; // no need to check conditions in preview mode 97 } 98 99 if (shouldCheckMultipleConditions) { 100 const ruleConditions = JSON.parse(settings.ruleConditions); 101 const allConditionsMoveToFE = ruleConditions.every((condition) => 102 Object.values(ConditionType).includes( 103 condition.conditionType.toLowerCase() 104 ) 105 ); 106 if (!allConditionsMoveToFE) { 107 return {}; 108 } 109 const conditionTypeToCallback = { 110 [ConditionType.USER_VISITS]: shouldShowRuleObjectForUserVisit, 111 ...(checkRuleLogicOnFeEnabled && { 112 [ConditionType.USER_IN_DATE_TIME_RANGE]: 113 shouldShowRuleObjectForDateTimeRange, 114 }), 115 }; 116 const conditionsToCheck = ruleConditions.map((condition) => { 117 return { 118 condition, 119 callback: 120 conditionTypeToCallback[ 121 condition.conditionType.toLowerCase() 122 ], 123 }; 124 }); 125 return conditionsToCheck && conditionsToCheck.length 126 ? { conditionsToCheck } 127 : {}; 128 } 129 const hasMoreThenOneCondition = settings.conditions_number > 1; 130 const shouldCheckUserVisitsCondition = 131 !hasMoreThenOneCondition && settings.user_visits_number !== undefined; 132 const shouldCheckDateTimeRangeCondition = 133 checkRuleLogicOnFeEnabled && 134 !hasMoreThenOneCondition && 135 settings.start_time && 136 settings.end_time; 137 138 return { 139 shouldCheckUserVisitsCondition, 140 shouldCheckDateTimeRangeCondition, 141 }; 142} 143 144function parseBoolean(str) { 145 return str.toLowerCase() === 'true'; 146}
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.