TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/zshall/program-guide/llms.txt
Use this file to discover all available pages before exploring further.
TV class is the top-level controller for Television Simulator ‘99. It owns the application lifecycle from the initial page load through YouTube API readiness, guide data fetching, and channel rendering. Every feature visible to the viewer — channel switching, mute state, on-screen messages, and viewport scaling — is coordinated through a single TV instance created in index.html.
Constructor Parameters
The constructor accepts four optional parameters that tune startup behaviour and layout constraints.Maximum pixel width of the TV element before scaling is applied. When the viewport is wider than this value the CSS
transform: scale() is removed entirely, leaving the TV at its natural size.Maximum pixel height before scaling stops. The scale factor is calculated against both dimensions and the smaller result wins, so neither axis is clipped.
Duration in milliseconds of the fade-in animation when a channel first becomes visible. On the very first channel load this value is used as-is; on subsequent channel switches it is divided by 10, giving a quick
300 ms crossfade instead of a full warm-up.Tracks whether this is the simulator’s first startup.
showChannel sets it to false after the first channel loads, ensuring the long warm-up animation only plays once per page load.classes registry that maps channel numbers to their implementation classes:
The classes Object
this.classes is a plain object whose keys follow the convention Channel{number}. When showChannel is called with a channel number it performs a dynamic lookup:
Channel5) and registering it here:
startUp()
startUp() defers all initialisation until the DOM is ready, then wires up every event handler and kicks off the asynchronous loading chain.
Attach resize handler
On non-mobile devices, a
$(window).resize listener is registered that calls handleResize() whenever the viewport changes. scanlines CSS is also applied to .screen for desktop users.Wire UI buttons
The about panel toggle and the hardware mute button (
#tv-mute) are bound via jQuery click handlers. The about panel is also toggled immediately so it starts hidden.Listen for youtubeReady
A
document event listener waits for the custom youtubeReady event (fired by onYouTubeIframeAPIReady in youtube-ctrl.js). When it fires, a jQuery AJAX GET fetches data/guide.xml, parses it with $.parseXML, and stores the result as window.guideData.Find default channel and show it
After parsing the XML, the code queries for the channel element that carries both
watchable and default attributes and calls showChannel with its number attribute.showChannel(number)
showChannel tears down the currently active channel, loads the replacement channel’s HTML layout, and fades it in.
- If a channel is already loaded,
teardown()is called on it — clearing timers, stopping video, and emptying the container. - The
.current-channeldiv is hidden (opacity: 0), and jQuery’s.load()fetcheschannels/012/layout.html(zero-padded to 3 digits byHelpers.padLeft). - Once the HTML is injected, a new channel class is instantiated and
show()is called synchronously. - jQuery
.animate()fades the channel and the channel-number overlay in. When the animation finishes,ready()is called on the channel. - The channel number appears in
#tvm-top-rightfor four seconds, then clears. this.firstStartis set tofalse, switching all future transitions to the fastwarmupTime / 10duration.
toggleMute(), mute(), and unmute()
Mute control is delegated to YouTubeApi.toggleMuteVideo, which talks directly to the IFrame player. The result — a boolean indicating whether the player is now muted — is stored on this.muted and reflected in the on-screen overlay.
mute() and unmute() each call this.toggleMute() (passing a boolean argument that toggleMute does not use) followed by a second call to this.afterMute(). Because toggleMute() already calls afterMute() internally, calling mute() or unmute() results in afterMute() running twice. Both methods require that the active channel exposes a this.player property pointing to its YT.Player instance.
handleResize()
handleResize keeps the TV element sized correctly inside any viewport by computing a uniform scale factor and applying it as a CSS transform.
Math.min ensures the smaller of the two ratios (width-based or height-based) is used, so the TV never overflows either dimension. On viewports larger than maxWidth × maxHeight the transform is cleared entirely and the TV renders at natural size.
Instantiation
The entire application starts with two lines at the bottom ofindex.html: