Skip to content

Commit 0281260

Browse files
committed
✨ added complete routage
1 parent a915353 commit 0281260

3 files changed

Lines changed: 257 additions & 17 deletions

File tree

404.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html lang="fr">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>StreamIt</title>
7+
<script>
8+
(function () {
9+
var full = window.location.pathname + window.location.search + window.location.hash;
10+
var base = window.location.pathname.replace(/\/[^\/]*$/, '/');
11+
var relative = full.startsWith(base) ? '/' + full.slice(base.length) : full;
12+
var target = base + 'index.html?route=' + encodeURIComponent(relative);
13+
window.location.replace(target);
14+
})();
15+
</script>
16+
</head>
17+
<body></body>
18+
</html>

js/display.js

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,32 @@ let activeVideoSrc = "";
1313
let activeVideoContext = null;
1414
let activeSelectedSeason = null; // Track the currently selected season
1515

16+
/**
17+
* Opens media details and syncs route if available.
18+
* @param {Object} item - Media item.
19+
*/
20+
function openDetailsWithRoute(item) {
21+
if (typeof window !== 'undefined' && typeof window.openMediaDetails === 'function') {
22+
window.openMediaDetails(item);
23+
} else {
24+
openDetails(item);
25+
}
26+
}
27+
28+
/**
29+
* Opens actor details and syncs route if available.
30+
* @param {Object} actor - Actor item.
31+
* @param {Object} filmsData - Films data.
32+
* @param {Object} seriesData - Series data.
33+
*/
34+
function openActorDetailsWithRoute(actor, filmsData, seriesData) {
35+
if (typeof window !== 'undefined' && typeof window.openActorDetailsRoute === 'function') {
36+
window.openActorDetailsRoute(actor, filmsData, seriesData);
37+
} else {
38+
openActorDetails(actor, filmsData, seriesData);
39+
}
40+
}
41+
1642
/**
1743
* Sets up the hero section with the given media item.
1844
* @param {Object} item - The media item to display in the hero section.
@@ -47,7 +73,7 @@ export function setupHero(item) {
4773

4874
// Set up play button click handler based on media type
4975
newBtn.onclick = () => {
50-
openDetails(item);
76+
openDetailsWithRoute(item);
5177
if (isSerie && item.seasons?.["1"]?.[0]) {
5278
const ctx = {
5379
type: 'series',
@@ -72,7 +98,7 @@ export function setupHero(item) {
7298
if (infoBtn) {
7399
const newInfoBtn = infoBtn.cloneNode(true);
74100
infoBtn.parentNode.replaceChild(newInfoBtn, infoBtn);
75-
newInfoBtn.onclick = () => openDetails(item);
101+
newInfoBtn.onclick = () => openDetailsWithRoute(item);
76102
}
77103
}
78104

@@ -446,7 +472,7 @@ export function createMediaCard(item, extraClasses = "") {
446472
</div>
447473
</div>
448474
`;
449-
card.onclick = () => openDetails(item);
475+
card.onclick = () => openDetailsWithRoute(item);
450476
return card;
451477
}
452478

@@ -791,7 +817,7 @@ export function renderActorsList(actorsData, filmsData = {}, seriesData = {}) {
791817
</div>
792818
`;
793819

794-
card.onclick = () => openActorDetails(actor, filmsData, seriesData);
820+
card.onclick = () => openActorDetailsWithRoute(actor, filmsData, seriesData);
795821
grid.appendChild(card);
796822
});
797823

@@ -847,7 +873,7 @@ export function renderActorsListSearch(actorsData, filmsData = {}, seriesData =
847873
</div>
848874
`;
849875

850-
card.onclick = () => openActorDetails(actor, filmsData, seriesData);
876+
card.onclick = () => openActorDetailsWithRoute(actor, filmsData, seriesData);
851877
grid.appendChild(card);
852878
});
853879

0 commit comments

Comments
 (0)