Module: utils

js/utils.js Utility functions for video playback, UI toggles, loader management, and video player enhancements.
Source:

Methods

(static) closeVideo()

Closes the video overlay and stops playback.
Source:

(static) hardenPlayerControls()

Enhances video player controls to prevent downloading and remote playback.
Source:

(static) hideLoader()

Hides the loading spinner with a fade-out effect.
Source:

(static) initPlayerPersistence()

Initializes video player progress persistence.
Source:

(static) playVideo(src, context)

Plays a video in the overlay player with optional watch context.
Parameters:
Name Type Description
src string The video source URL.
context Object | null Optional playback context {type, title, season, episodeIndex}.
Source:

(static) showLoader()

Shows the loading spinner.
Source:

(static) toggleMobileMenu()

Toggles the mobile menu visibility.
Source:

(static) toggleMobileSearch()

Toggles the mobile search panel visibility.
Source:

(static) toggleNotifs()

Toggles the notifications dropdown visibility.
Source:

(inner) applyStartTime(player, startTime)

Applies a saved start time (resume) when metadata is available.
Parameters:
Name Type Description
player HTMLVideoElement The video player element.
startTime number Time in seconds to seek to.
Source:

(inner) cleanupCustomVideoControls()

Cleans up custom video controls event listeners
Source:

(inner) formatTime(seconds) → {string}

Formats time in seconds to MM:SS or HH:MM:SS
Parameters:
Name Type Description
seconds number Time in seconds
Source:
Returns:
Formatted time string
Type
string

(inner) handleKeyboardControls(e)

Handles keyboard controls
Parameters:
Name Type Description
e KeyboardEvent Keyboard event
Source:

(inner) hideControls()

Hides video controls
Source:

(inner) initCustomVideoControls()

Initializes all custom video player controls
Source:

(inner) persistGenericProgress(player)

Persists video playback progress to localStorage (fallback when no context is provided).
Parameters:
Name Type Description
player HTMLVideoElement The video player element.
Source:

(inner) progressKey(src) → {string}

Generates a unique key for storing video progress in localStorage.
Parameters:
Name Type Description
src string The video source URL.
Source:
Returns:
The generated storage key.
Type
string

(inner) resetControlsTimeout()

Resets the auto-hide timeout for controls
Source:

(inner) seekToPosition(e)

Seeks to clicked position on progress bar
Parameters:
Name Type Description
e MouseEvent Click event
Source:

(inner) showControls()

Shows video controls
Source:

(inner) showTimeTooltip(e)

Shows time tooltip on progress bar hover
Parameters:
Name Type Description
e MouseEvent Mouse event
Source:

(inner) toggleFullscreen()

Toggles fullscreen mode
Source:

(inner) toggleMute()

Toggles mute state
Source:

(inner) togglePlayPause()

Toggles play/pause state
Source:

(inner) updateBufferedProgress()

Updates buffered progress bar
Source:

(inner) updatePlayPauseIcon(isPaused)

Updates play/pause button icon
Parameters:
Name Type Description
isPaused boolean Whether video is paused
Source:

(inner) updateProgress()

Updates progress bar and time display
Source:

(inner) updateVideoTitle(context)

Updates the video title overlay based on context
Parameters:
Name Type Description
context Object | null Video context {type, title, season, episodeIndex, episodeTitle}
Source:

(inner) updateVolumeIcon(volume)

Updates volume icon based on volume level
Parameters:
Name Type Description
volume number Volume level (0-1)
Source:

(inner) updateVolumeSliderBackground(value)

Updates volume slider background gradient
Parameters:
Name Type Description
value number Slider value (0-100)
Source: