Manages modal display logic for content details and video playback.
This module handles the opening and dynamic rendering of modals for both films and series,
including displaying metadata, trailers, IMDb links, cast, and watched status. It also manages
playback of videos in a dedicated modal with resume support and watched progress tracking.
Series episodes are displayed per season with interactive controls, and the module keeps track
of the user's playback context to update localStorage as needed.
Methods
(inner) closeModals()
Closes all open modals and resets video playback state.
Stops the video, clears playback context, and re-enables page scrolling.
(inner) createModalContent(item, type) → {string}
Generates the HTML content of the modal based on the item’s metadata.
Builds a visual layout with poster, title, rating, genres, year, description,
cast, and available actions like watch/trailer/IMDb buttons.
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | The content item (film or series). |
type |
string | The content type: "film" or "series". |
Returns:
HTML string to be injected into the modal.
- Type
- string
(inner) displayEpisodes(series, seasonNumber)
Displays the list of episodes for a given season in the modal.
Generates episode cards with titles, descriptions, watched status,
and a click handler to start playback.
Parameters:
Name | Type | Description |
---|---|---|
series |
Object | The series object. |
seasonNumber |
string | The selected season number to display. |
(inner) handleVideoEnded()
Marks the content as fully watched when the video ends.
Called automatically when video playback reaches the end.
(inner) handleVideoPause()
Saves the current playback position when the video is paused.
Updates watch progress in localStorage without marking as fully watched.
(inner) handleVideoTimeUpdate()
Updates watch progress as the video plays.
Saves the current time to localStorage and marks the item as fully watched
if more than 90% of the video is completed.
(inner) openModal(title, type)
Opens the content detail modal for a given film or series.
Renders the modal content using the provided title and type, and sets up additional UI
for series (like seasons and episodes). Prevents background scrolling while the modal is open.
Parameters:
Name | Type | Description |
---|---|---|
title |
string | The title of the content item. |
type |
string | The content type: "film" or "series". |
(inner) playVideo(videoPath, type, title, seasonopt, epIndexopt)
Starts video playback in the video modal and initializes playback context.
Sets the video source, handles resume playback from last watched time,
and updates `currentVideoContext` for tracking progress.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
videoPath |
string | The path to the video file. | |
type |
string | "film" or "series". | |
title |
string | Title of the content. | |
season |
string |
<optional> |
Season number (only for series). |
epIndex |
number |
<optional> |
Episode index (only for series). |
(inner) setupSeriesModal(series)
Sets up the modal UI for a series, including seasons navigation and episodes display.
Builds buttons for each season and loads the episodes for the first one by default.
Parameters:
Name | Type | Description |
---|---|---|
series |
Object | The series object with seasons and episodes. |
(inner) showFilmModal(film)
Shows the film detail modal for a given film.
Parameters:
Name | Type | Description |
---|---|---|
film |
The film object containing metadata like title, description, genres, etc. |
(inner) showSeriesModal(series)
Shows the series detail modal for a given series.
Parameters:
Name | Type | Description |
---|---|---|
series |
The series object containing metadata like title, description, seasons, etc. |