1// This is duplicated out of all.js, which is an older javascript bundle that is mostly 2// only running on older pages (not currently imported in header-v3.php). We probably want this 3// logic separated out so that it is easier to manage when cookies are initialized 4// 5// ââ Load-order dependency âââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 6// This file requires build/theme/geo-country.js to have executed first. That bundle defines 7// ss_get_cookie / ss_cookie / getParameterByName (src/js/util/cookies.js) and owns the 8// home_country cookie (src/js/util/geoCountry.js), which used to live here. 9// 10// The order holds structurally, not by luck: geo-country is enqueued on wp_enqueue_scripts 11// (helpers/enqueue.php), so it prints inside the <head> script block, while this file is a 12// raw tag further down header.php. Deferred scripts execute in document order. 13// 14// If you ever move the geo-country enqueue to wp_head, it will silently land in the footer 15// and every helper below becomes undefined. 16 17(document.readyState === 'loading') 18 ? document.addEventListener('DOMContentLoaded', ss_init_cookies) 19 : ss_init_cookies(); 20 21function ss_init_cookies() { 22 23 // referrer 24 if (document.referrer && 25 document.referrer.length > 0 && 26 document.referrer.toLowerCase().indexOf('.shipstation.com') == -1) { 27 ss_cookie("referrer", document.referrer, 60); 28 } 29 30 // ref 31 if (getParameterByName('ref') != '') { 32 ss_cookie("ds3_ref", getParameterByName('ref')); 33 ss_cookie("referral_code", getParameterByName('ref')); 34 } 35 36 // gclid 37 if (getParameterByName('gclid') != '') { 38 ss_cookie("ds3_gclid", getParameterByName('gclid')); 39 } 40 41 // affiliate 42 if (getParameterByName('affiliate') != '') { 43 ss_cookie("affiliate", getParameterByName('affiliate')); 44 } 45 46 // home_country is resolved by src/js/util/geoCountry.js, which runs earlier â see the 47 // load-order note at the top of this file. 48 49 // cjevent 50 if (getParameterByName('cjevent') != '') { 51 ss_cookie("cjevent", getParameterByName('cjevent')); 52 } 53 54 if (ss_get_cookie('referral_code') === 'stamps') { 55 document.querySelectorAll('.referral_endicia').forEach(function(el) { el.style.display = 'none'; }); 56 document.querySelectorAll('.referral_stamps').forEach(function(el) { el.style.display = ''; }); 57 document.querySelectorAll('.no_referral').forEach(function(el) { el.style.display = 'none'; }); 58 } 59 60 if (ss_get_cookie('app-logout') === 'Yes') { 61 var el = document.getElementById('app-logout'); 62 if (el) el.style.display = ''; 63 } 64} 65 66// ââ Signup form "ready" contract ââââââââââââââââââââââââââââââââââââââââââââââââââ 67// forms/signup.php mounts a Vue app on #signup_form that fully REBUILDS the form's DOM
68// on its first mount, discarding any jQuery handler / plugin state (e.g. jQuery Validate) 69// or plain .val() write made against the server-rendered elements beforehand. Because the 70// registration scripts are deferred, their $(document).ready fires via a setTimeout that 71// races Vue's DOMContentLoaded mount, so binding in ready() worked only "half the time". 72// 73// This contract makes form-dependent setup run exactly once, always AFTER the mount, in 74// either ordering: 75// - Vue calls ssSignalSignupFormReady() from mounted()'s trailing $nextTick. 76// - Registration scripts wrap their form setup in ssOnSignupFormReady(cb). 77// mount-first: the flag is already set, so cb runs immediately against the live form. 78// ready-first: cb is queued and runs the moment Vue signals readiness. Using an internal 79// queue (not a DOM event) sidesteps the "listener registered too late" race entirely. 80// 81// Vue also waits on ssOnHomeCountry before signalling, so callbacks are guaranteed to see the 82// final resolved country. That matters because js/register.js:636 picks its jQuery Validate 83// messages once at bind time, from getHomeCountry(). 84var __ssSignupFormReadyCallbacks = []; 85var __ssSignupFormReady = false; 86 87function ssOnSignupFormReady(cb) { 88 if (typeof cb !== 'function') return; 89 if (__ssSignupFormReady) { 90 cb(); 91 } else { 92 __ssSignupFormReadyCallbacks.push(cb); 93 } 94} 95 96function ssSignalSignupFormReady() { 97 if (__ssSignupFormReady) return; // idempotent: only the first mount counts 98 __ssSignupFormReady = true; 99 var callbacks = __ssSignupFormReadyCallbacks; 100 __ssSignupFormReadyCallbacks = []; 101 callbacks.forEach(function (cb) { 102 try { 103 cb(); 104 } catch (e) { 105 console.error('ssOnSignupFormReady callback error:', e); 106 } 107 }); 108}
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.