1/** 2 * Phone portrait only: Play Now auto-expands the game and CSS-rotates to landscape. 3 * PC and tablets never auto-expand. Shrink (expand toggle) returns to normal layout. 4 */ 5(function () { 6 if (window.__swGameMobileExpand) return; 7 window.__swGameMobileExpand = true; 8 9 function isArcadeGamePage() { 10 var path = (location.pathname || '').replace(/\\/g, '/'); 11 return path.indexOf('/arcade-games/') !== -1; 12 } 13 14 /** True only for phone-sized touch devices â not PC, not tablets. */ 15 function isPhone() { 16 try { 17 // Mouse / trackpad desktops (incl. touch-capable laptops used with mouse) 18 if (window.matchMedia('(hover: hover) and (pointer: fine)').matches) return false; 19 } catch (e) {} 20 21 // Tablets and larger: short CSS side is typically >= ~600â768 22 var w = window.innerWidth || 0; 23 var h = window.innerHeight || 0; 24 var shortSide = Math.min(w, h); 25 if (shortSide > 550) return false; 26 27 var ua = navigator.userAgent || ''; 28 if (/iPad|Tablet|PlayBook|Silk/i.test(ua)) return false; 29 // Android tablets often omit "Mobile" 30 if (/Android/i.test(ua) && !/Mobile/i.test(ua)) return false; 31 32 try { 33 if (window.matchMedia('(pointer: coarse)').matches) return true; 34 } catch (e2) {} 35 36 return /iPhone|iPod|Android.*Mobile|webOS|BlackBerry|IEMobile|Opera Mini/i.test(ua); 37 } 38 39 function isPortrait() { 40 try { 41 if (window.matchMedia('(orientation: landscape)').matches) return false; 42 if (window.matchMedia('(orientation: portrait)').matches) return true; 43 } catch (e) {} 44 return (window.innerHeight || 0) >= (window.innerWidth || 0); 45 } 46 47 /** Auto-expand + landscape lock only on phone + portrait (non-arcade). */ 48 function shouldAutoExpand() { 49 if (isArcadeGamePage()) return false; 50 return isPhone() && isPortrait(); 51 } 52 53 function gameSection() { 54 return document.getElementById('play-game-embed-online') || document.getElementById('play-space-waves'); 55 } 56 57 function isExpanded() { 58 var s = gameSection(); 59 return !!(s && s.classList.contains('expanded-mode')) 60 || document.body.classList.contains('game-expanded') 61 || document.body.classList.contains('game-embed-expanded'); 62 } 63 64 function syncLandscapeLock() { 65 var on = isExpanded() && shouldAutoExpand(); 66 document.documentElement.classList.toggle('game-landscape-lock', on); 67 document.body.classList.toggle('game-landscape-lock', on); 68 } 69 70 var PLAY_NOW_EXPAND_DELAY_MS = 10000; 71 var playNowExpandTimer = null; 72 73 function cancelPlayNowExpand() { 74 if (!playNowExpandTimer) return; 75 clearTimeout(playNowExpandTimer); 76 playNowExpandTimer = null; 77 } 78 79 function schedulePlayNowExpand() { 80 if (playNowExpandTimer || isExpanded()) return; 81 if (!shouldAutoExpand()) return; 82 playNowExpandTimer = setTimeout(function () { 83 playNowExpandTimer = null; 84 expandNow(); 85 }, PLAY_NOW_EXPAND_DELAY_MS); 86 } 87 88 function expandNow() { 89 if (!shouldAutoExpand()) return; 90 if (!isExpanded()) { 91 var btn = document.getElementById('expand-btn'); 92 if (btn) btn.click(); 93 } 94 window.setTimeout(syncLandscapeLock, 30); 95 } 96 97 function hookFrame(frame) { 98 if (!frame) return; 99 function attach() { 100 try { 101 var doc = frame.contentDocument; 102 if (!doc) return; 103 var root = doc.documentElement || doc.body; 104 if (!root || root.getAttribute('data-sw-play-hooked') === '1') return; 105 root.setAttribute('data-sw-play-hooked', '1'); 106 root.addEventListener('click', function (ev) { 107 var t = ev.target; 108 if (!t || !t.closest) return; 109 if (t.closest('.game-btn') || t.closest('#play-btn') || t.closest('.embed-thumb')) { 110 schedulePlayNowExpand(); 111 } 112 }, true); 113 } catch (e) {} 114 } 115 frame.addEventListener('load', attach); 116 attach(); 117 } 118 119 window.addEventListener('message', function (e) { 120 var d = e && e.data; 121 if (!d) return; 122 if (d.type === 'swPlayNow' || d.type === 'gamePlayNow') schedulePlayNowExpand(); 123 }); 124 125 var expandBtn = document.getElementById('expand-btn'); 126 if (expandBtn) { 127 expandBtn.addEventListener('click', function () { 128 cancelPlayNowExpand(); 129 window.setTimeout(syncLandscapeLock, 0); 130 }); 131 } 132 133 window.addEventListener('orientationchange', function () { 134 window.setTimeout(syncLandscapeLock, 80); 135 }); 136 window.addEventListener('resize', syncLandscapeLock); 137 138 var obs = new MutationObserver(syncLandscapeLock); 139 var section = gameSection(); 140 if (section) obs.observe(section, { attributes: true, attributeFilter: ['class'] }); 141 obs.observe(document.body, { attributes: true, attributeFilter: ['class'] }); 142 143 hookFrame(document.getElementById('game-frame')); 144 145 var reloadBtn = document.getElementById('game-reload-btn'); 146 if (reloadBtn) { 147 reloadBtn.addEventListener('click', function () { 148 window.setTimeout(function () { 149 hookFrame(document.getElementById('game-frame')); 150 }, 400); 151 }); 152 } 153 154 syncLandscapeLock(); 155})();
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.