1var auth = { 2 data: false, 3 isError: false, 4}; 5 6function getRootDomain(host) { 7 var parts = host.split('.'); 8 return parts.length >= 2 ? '.' + parts.slice(-2).join('.') : host; 9} 10 11function authRequest($) { 12 var domain = getRootDomain(window.location.hostname); 13 var oneYear = 60 * 60 * 24 * 365; 14 15 $.ajax({ 16 url: onlineDomain + '/ajax.user.data.ajax-authData.html', 17 jsonpCallback: 'JQuery' + Math.floor((Math.random() * 1000000000) + 1) + '_' + Math.floor(Date.now()), 18 dataType: 'jsonp', 19 success: function(res) { 20 auth.data = res; 21 if (typeof res == 'undefined') { 22 return; 23 } 24 handleAuthButtons(res.is_auth); 25 if (res.is_auth) { 26 document.cookie = 'login_cookie=true; path=/'; 27 if (res.data && res.data.account_id) { 28 document.cookie = 'UID=' + res.data.account_id + '; path=/; domain=' + domain + '; max-age=' 29 + oneYear; 30 } 31 if (res.is_trial) { 32 localStorage.removeItem('se-is-trial'); 33 } else { 34 localStorage.setItem('se-is-trial', 'true'); 35 } 36 setSubAccountCookie(res.data.account_type); 37 handleSubscriptionPage(res); 38 hubspotAddEmailToUser(res.data.email); 39 40 if (res.is_demo) { 41 document.body.classList.add('visited_demo'); 42 } 43 if (typeof Piwik !== 'undefined') { 44 var p = Piwik.getAsyncTracker(); 45 p.setUserId(res.data.email); 46 p.setCustomVariable(1, 'subscription_type', res.data.piwik_subscription_type, 'visit'); 47 p.trackPageView(); 48 } else { 49 if (typeof _paq === 'undefined') { 50 window._paq = []; 51 } 52 _paq.unshift( 53 ['setCustomVariable', 1, 'subscription_type', res.data.piwik_subscription_type, 'visit']); 54 _paq.unshift(['setUserId', res.data.email]); 55 } 56 if (typeof res._usc !== 'undefined' && typeof $.cookie('_usc') === 'undefined') { 57 $.cookie('_usc', res._usc, {path: '/', expires: 90}); 58 } 59 } else { 60 localStorage.removeItem('se-is-trial'); 61 setSubAccountCookie(false); 62 document.cookie = 'login_cookie=; max-age=0; path=/'; 63 document.cookie = 'auto_login_cookie=; max-age=0'; 64 document.cookie = 'UID=; max-age=0; domain=' + domain + ';'; 65 } 66 67 setTrialCookie(res.is_trial); 68 69 var seTimerLine = document.querySelector('.se-timer-line'); 70 if (seTimerLine) { 71 seTimerLineInit(res.is_auth, res.is_demo, res.is_trial); 72 timerLineEvent(); 73 } 74 }, 75 error: function() { 76 auth.isError = true; 77 }, 78 }); 79 80 function setTrialCookie(value) { 81 document.cookie = 'se_trial_cookie' + (value ? '=true' : '=; max-age=0'); 82 } 83} 84 85function handleAuthButtons(shouldShowLogOutGroup) { 86 var logOutButtonsGroup = document.querySelector('.f-button-group--authorization'); 87 var logInButtonsGroup = document.querySelector('.f-button-group'); 88 if (logOutButtonsGroup) { 89 logOutButtonsGroup.classList.toggle('show', shouldShowLogOutGroup); 90 logOutButtonsGroup.classList.toggle('hide', !shouldShowLogOutGroup); 91 } 92 if (logInButtonsGroup) { 93 logInButtonsGroup.classList.toggle('hide', shouldShowLogOutGroup); 94 logInButtonsGroup.classList.toggle('show', !shouldShowLogOutGroup); 95 } 96} 97 98function isSubAccount(accountType) { 99 return accountType !== 'admin'; 100} 101 102function setSubAccountCookie(accountType) { 103 var cookieSubAccountName = 'is_sub_account='; 104 105 if (accountType && isSubAccount(accountType)) { 106 document.cookie = cookieSubAccountName + 'true'; 107 } else { 108 document.cookie = cookieSubAccountName + '; max-age=0'; 109 } 110} 111 112function handleSubscriptionPage(res) { 113 var subscriptionTemplate = document.querySelector('.page-template-subscription, .se-page-behavior-subscription'); 114 if (!subscriptionTemplate) { 115 return; 116 } 117 if (isSubAccount(res.data.account_type)) { 118 var buyButtons = document.querySelectorAll('.subscription-page.buy-btn'); 119 if (buyButtons.length) { 120 disableBuyBtns(buyButtons); 121 } 122 } else { 123 const searchParams = new URLSearchParams(window.location.search); 124 if (!searchParams.has('noredirect')) { 125 redirectSubscription(); 126 } 127 } 128 129 function redirectSubscription() { 130 window.location = onlineDomain + '/admin.subscription.html#/?open_buy_subscription=1'; 131 } 132 133 function disableBuyBtns(buyButtons) { 134 var featuresHeadItems = document.querySelectorAll('.all-features-area-head-item'); 135 var featuresHeadItemAdmin = document.querySelectorAll('.all-features-area-head-item__info-wrapper_admin'); 136 var featuresHeadItemSub = document.querySelectorAll('.all-features-area-head-item__info-wrapper_sub-account'); 137 138 if (!featuresHeadItems.length 139 || !featuresHeadItemAdmin.length 140 || !featuresHeadItemSub.length) { 141 return; 142 } 143 144 changeBlockClass(featuresHeadItems, 'all-features-area-head-item__info-disabled', 'add'); 145 changeBlockClass(featuresHeadItemAdmin, 'd-none', 'add'); 146 changeBlockClass(featuresHeadItemSub, 'd-none', 'remove'); 147 changeBlockClass(buyButtons, 'se-btn_disabled', 'add'); 148 149 if (window.innerWidth < 992) { 150 var mobileSubTextBlocks = document.querySelectorAll( 151 '.all-features-area-head-item .all-features-area-head-item__sub-content'); 152 153 if (!mobileSubTextBlocks.length) { 154 return; 155 } 156
157 Array.from(mobileSubTextBlocks).forEach(item => { 158 changeBlockClass(item, 'd-none', 'remove'); 159 }); 160 } 161 } 162} 163 164function changeBlockClass(items, className, action) { 165 if (!items.length) { 166 items.classList[action](className); 167 } else { 168 items.forEach(function(item) { 169 item.classList[action](className); 170 }); 171 } 172} 173 174jQuery(document).ready(function($) { 175 authRequest($); 176});
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.