1(function () { 2 // Bypass: ?bypassstandby=true|false. The server mirrors the param into a 3 // session cookie (Bootstrap::_initStandbyBypass) on every request, so the 4 // bypass survives server-side redirects and pages whose layout doesn't load 5 // this script. The cookie is the single source of truth. 6 var params = new URLSearchParams(window.location.search); 7 if (params.get('bypassstandby') === 'true') { return; } 8 if (/(^|;\s*)bypassstandby=true(;|$)/.test(document.cookie)) { return; } 9 10 // Read config injected by PHP 11 var config = window.__standbyConfig; 12 if (!config || !config.statusApiUrl || !config.standbyUrl) { return; } 13 14 // Prevent redirect loop if current page is already the standby URL 15 if (window.location.href.indexOf(config.standbyUrl) === 0) { return; } 16 17 var pollInterval = config.pollInterval || 30000; 18 19 function checkStandby() { 20 fetch(config.statusApiUrl) 21 .then(function (res) { 22 if (res.status === 503) { 23 // The status API answers 503 standby_not_active while standby is 24 // off; that is the normal "inactive" signal, not a failure. 25 return res.json().then(function (body) { 26 if (body && body.error === 'standby_not_active') { return null; } 27 throw new Error('HTTP 503'); 28 }); 29 } 30 if (!res.ok) { throw new Error('HTTP ' + res.status); } 31 return res.json(); 32 }) 33 .then(function (data) { 34 if (!data) { return; } 35 // Only the "active" state redirects. "ready" means FitWeb is back 36 // (data.active is still true then, for legacy mobile clients). 37 if (data.state === 'active' && data.surfaces && data.surfaces.web === true) { 38 window.location.replace(config.standbyUrl); 39 } 40 }) 41 .catch(function (err) { 42 console.warn('[standby] Status check failed:', err.message); 43 }); 44 } 45 46 // Initial check 47 checkStandby(); 48 49 // Poll on interval 50 setInterval(checkStandby, pollInterval); 51 52 // Re-check when tab becomes visible 53 document.addEventListener('visibilitychange', function () { 54 if (document.visibilityState === 'visible') { 55 checkStandby(); 56 } 57 }); 58})();
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.