1function isReachedTotalVisits(expectedVisits) { 2 const userVisitsCookie = getCookie('dm_total_visits'); 3 let userVisits = 0; 4 if (userVisitsCookie) { 5 userVisits = parseInt(userVisitsCookie); 6 } else { 7 // if cookie hasn't been set, yet it will be null 8 const lastView = getCookie('dm_this_page_view'); // data & time of last visit in site 9 if (!lastView) { 10 userVisits++; 11 } else { 12 const now = new Date(); 13 const visitLength = window.visitLength || 0; 14 if (now.getTime() - lastView > window.visitLength) { 15 userVisits++; // this counts as a new visit 16 } 17 } 18 } 19 return userVisits === expectedVisits; 20} 21 22function shouldShowRuleObjectForUserVisit(ruleObjName, condition, actionType) { 23 const expectedTotalVisits = shouldCheckMultipleConditions 24 ? parseInt(condition.params.user_visits_number) 25 : parseInt(condition.user_visits_number); 26 27 if (expectedTotalVisits) { 28 const cookieName = getSmartRuleCookieName(ruleObjName, actionType); 29 return ( 30 isReachedTotalVisits(expectedTotalVisits) && // all the times after the first one you go to the site after the condition was applied 31 // but the configured period of time didn't meet, the action shouldn't be applied 32 getCookie(cookieName) === null && 33 // there is no cookie of the same action type - site visitor already saw this action 34 !hasCookieOfType(actionType) 35 ); 36 } 37 38 //if there is no user_visits_number in settings it means 39 // that the condition is not user_visits, and we need to disregard this conditions 40 return true; 41}
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.