1const updateText = (selector, newText) => { 2 const elements = document.querySelectorAll(selector); 3 elements.forEach((element) => { 4 element.textContent = isNaN(newText) ? newText : Math.floor(newText); 5 }); 6}; 7const updateAttr = (selector, attr, val) => { 8 const elements = document.querySelectorAll(selector); 9 elements.forEach((element) => { 10 element.setAttribute(attr, val); 11 }); 12}; 13const handleEl = (selector, cb) => { 14 const elements = document.querySelectorAll(selector); 15 elements.forEach((element) => { 16 cb(element); 17 }); 18}; 19 20document.addEventListener("DOMContentLoaded", function () { 21 const account = window.accountVariables; 22 const defaults = window.defaultVariables; 23 24 if (account) { 25 updateText("[data-account-name]", account.name); 26 updateText("[data-account-email]", account.email); 27 28 handleEl("[data-p-team-upgrade-checkout-link]", (el) => { 29 if (account.hasTeamLicense) { 30 el.parentElement.parentElement.remove(); 31 } else { 32 el.parentElement.setAttribute( 33 "href", 34 account.teamUpgradeCheckoutLink 35 ); 36 } 37 }); 38 } 39 handleEl("[data-download]", (el) => { 40 el.addEventListener("click", (e) => { 41 e.preventDefault(); 42 const name = el.dataset.download; 43 window.location.href = defaults.baseUrl + "/files/download/" + name; 44 }); 45 }); 46 47 handleEl("[data-sign-out]", (el) => { 48 el.addEventListener( 49 "click", 50 () => (window.location = defaults.baseUrl + "/logout") 51 ); 52 }); 53});
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.