1// Remote Control TV module 2window.remoteControl = (function() { 3 let currentChannel = 1; 4 let isPowerOn = true; 5 6 function updateTV() { 7 const tvScreen = document.getElementById('tvScreen'); 8 const channelInfo = document.getElementById('channelInfo'); 9 10 // Safety check - if elements don't exist yet, skip 11 if (!tvScreen || !channelInfo) return; 12 13 if (!isPowerOn) { 14 tvScreen.classList.add('off'); 15 tvScreen.removeAttribute('data-channel'); 16 channelInfo.textContent = 'OFF'; 17 return; 18 } 19 20 tvScreen.classList.remove('off'); 21 tvScreen.setAttribute('data-channel', currentChannel); 22 channelInfo.textContent = 'Channel ' + currentChannel; 23 } 24 25 function togglePower() { 26 isPowerOn = !isPowerOn; 27 updateTV(); 28 } 29 30 function changeChannel(channel) { 31 if (!isPowerOn) return; 32 currentChannel = channel; 33 updateTV(); 34 } 35 36 function channelUp() { 37 if (!isPowerOn) return; 38 currentChannel = currentChannel >= 9 ? 1 : currentChannel + 1; 39 updateTV(); 40 } 41 42 function channelDown() { 43 if (!isPowerOn) return; 44 currentChannel = currentChannel <= 1 ? 9 : currentChannel - 1; 45 updateTV(); 46 } 47 48 function init() { 49 updateTV(); 50 } 51 52 // Auto-initialize when DOM is ready 53 if (document.readyState === 'loading') { 54 document.addEventListener('DOMContentLoaded', init); 55 } else { 56 // DOM already loaded, wait a bit for content injection 57 setTimeout(init, 100); 58 } 59 60 // Public API 61 return { 62 togglePower: togglePower, 63 changeChannel: changeChannel, 64 channelUp: channelUp, 65 channelDown: channelDown, 66 init: init 67 }; 68})();
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.