js/main.js
Main application logic for routing, filtering, searching, and initializing the app.
Methods
(inner) applyFilters()
Applies selected filters and sorting to the displayed items.
(inner) clearSearch()
Clears search input fields.
(inner) closeActorDetailsAndRoute()
Closes actor details overlay and restores the base view route.
(inner) closeDetailsAndRoute()
Closes media details overlay and restores the base view route.
(inner) enableHorizontalWheelScroll(rootopt)
Enables horizontal scrolling for elements with the 'scroll-row' class using the mouse wheel.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
root |
Document | HTMLElement |
<optional> |
document | The root element to search within. |
(inner) findActorBySlug(slug) → {Object|null}
Finds an actor by slug.
Parameters:
| Name | Type | Description |
|---|---|---|
slug |
string | Actor slug. |
Returns:
Actor object or null.
- Type
- Object | null
(inner) findCollectionBySlug(slug) → {Object|null}
Finds a collection by slug.
Parameters:
| Name | Type | Description |
|---|---|---|
slug |
string | Collection slug. |
Returns:
Collection object or null.
- Type
- Object | null
(inner) findMediaBySlug(type, slug) → {Object|null}
Finds a media item by slug within a media collection.
Parameters:
| Name | Type | Description |
|---|---|---|
type |
string | 'films' or 'series'. |
slug |
string | Media slug. |
Returns:
Media item or null.
- Type
- Object | null
(inner) getBasePath(pathname) → {string}
Determines the base path (useful for deployments in subfolders).
Parameters:
| Name | Type | Description |
|---|---|---|
pathname |
string | Current location pathname. |
Returns:
Normalized base path ending with '/'.
- Type
- string
(inner) getCollectionItems(collection) → {Array}
Builds media items array for a collection.
Parameters:
| Name | Type | Description |
|---|---|---|
collection |
Object | Collection object. |
Returns:
Ordered media items.
- Type
- Array
(inner) handleSearch(e)
Handles search input and updates the displayed content accordingly.
Parameters:
| Name | Type | Description |
|---|---|---|
e |
Event | The input event. |
(inner) initHero()
Initializes the hero section with a featured item or the latest item.
(inner) openActorDetailsRoute(actor, filmsData, seriesData)
Opens an actor details overlay and syncs the route.
Parameters:
| Name | Type | Description |
|---|---|---|
actor |
Object | Actor item. |
filmsData |
Object | Films data. |
seriesData |
Object | Series data. |
(inner) openMediaDetails(item)
Opens a media details overlay and syncs the route.
Parameters:
| Name | Type | Description |
|---|---|---|
item |
Object | Media item. |
(inner) parseLocationRoute() → {string}
Resolves the view name from the current URL.
Returns:
View name.
- Type
- string
(inner) populateFilters()
Populates filter dropdowns based on available data.
(inner) resetFilters()
Resets all filters to default values and reapplies them.
(inner) router(view)
Routes to the specified view and updates the UI accordingly.
Parameters:
| Name | Type | Description |
|---|---|---|
view |
string | The view to route to ('home', 'series', 'films', 'collections', 'actors'). |
(inner) slugify(text) → {string}
Builds a URL-friendly slug from a title string.
Parameters:
| Name | Type | Description |
|---|---|---|
text |
string | Source text. |
Returns:
Slug.
- Type
- string
(inner) textWhite(navHome, navSeries, navFilms, navCollections, navActors)
Sets navigation link colors to default (removes highlight).
Parameters:
| Name | Type | Description |
|---|---|---|
navHome |
HTMLElement | Navigation link for home |
navSeries |
HTMLElement | Navigation link for series |
navFilms |
HTMLElement | Navigation link for films |
navCollections |
HTMLElement | Navigation link for collections |
navActors |
HTMLElement | Navigation link for actors |
(inner) updateRoute(view, detail)
Updates the URL path for the current view and optional detail.
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
view |
string | Base view. | |
detail |
Object | null | null | Optional detail route. |