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) downloadProgressBackup()

Downloads a JSON backup of watch progress.
Source:

(static) getEpisodeWatchData(seriesTitle, season, epIndex) → {Object}

Retrieves watch data for a specific series episode.
Parameters:
Name Type Description
seriesTitle string Series title.
season string | number Season number.
epIndex number Episode index (0-based).
Source:
Returns:
Watch data object with watched boolean and time number.
Type
Object

(static) getFilmWatchData(title) → {Object}

Retrieves watch data for a specific film.
Parameters:
Name Type Description
title string Film title.
Source:
Returns:
Watch data object with watched boolean and time number.
Type
Object

(static) getWatchedContent() → {Object}

Retrieves watched content data from localStorage.
Source:
Returns:
Object with films and series watch data.
Type
Object

(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) importProgressFromFile(file) → {Promise.<Object>}

Imports watch progress from a JSON file.
Parameters:
Name Type Description
file File The file to import.
Source:
Returns:
Object with filmsCount and seriesCount.
Type
Promise.<Object>

(static) initPlayerPersistence()

Initializes video player progress persistence.
Source:

(static) isSeriesFullyWatched(series) → {boolean}

Checks if all episodes of a series have been watched.
Parameters:
Name Type Description
series Object Series object with seasons data.
Source:
Returns:
True if all episodes are watched, false otherwise.
Type
boolean

(static) openProgressImport()

Opens the file input dialog for importing progress data.
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:

(static) toggleSettings()

Toggles the settings 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) getResumeTime(src, context) → {number}

Gets the resume time for a video based on context or fallback.
Parameters:
Name Type Description
src string Video source URL.
context Object | null Playback context.
Source:
Returns:
Resume time in seconds.
Type
number

(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) markEpisodeWatched(seriesTitle, season, epIndex, watchedopt, timeopt)

Marks a series episode as watched or updates its progress.
Parameters:
Name Type Attributes Default Description
seriesTitle string Series title.
season string | number Season number.
epIndex number Episode index (0-based).
watched boolean <optional>
true Whether the episode is watched.
time number <optional>
0 Current playback time in seconds.
Source:

(inner) markFilmWatched(title, watchedopt, timeopt)

Marks a film as watched or updates its progress.
Parameters:
Name Type Attributes Default Description
title string Film title.
watched boolean <optional>
true Whether the film is watched.
time number <optional>
0 Current playback time in seconds.
Source:

(inner) normalizeEpisodeIndex(epIndex) → {number}

Normalizes episode index to a valid non-negative integer.
Parameters:
Name Type Description
epIndex any Episode index to normalize.
Source:
Returns:
Normalized episode index (defaults to 0).
Type
number

(inner) normalizeSeason(season) → {string}

Normalizes season input to a valid string.
Parameters:
Name Type Description
season any Season value to normalize.
Source:
Returns:
Normalized season string (defaults to '1').
Type
string

(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) sanitizeProgressData(raw) → {Object}

Sanitizes raw progress data to ensure valid structure.
Parameters:
Name Type Description
raw Object Raw data to sanitize.
Source:
Returns:
Sanitized data with films and series objects.
Type
Object

(inner) saveWatchProgress(player, isEndedopt)

Saves watch progress for the current video.
Parameters:
Name Type Attributes Default Description
player HTMLVideoElement The video player element.
isEnded boolean <optional>
false Whether the video has ended.
Source:

(inner) seekToPosition(e)

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

(inner) setWatchedContent(data)

Stores watched content data to localStorage.
Parameters:
Name Type Description
data Object Watch data object containing films and series.
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: