-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
30 lines (27 loc) · 1.19 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
document.addEventListener("DOMContentLoaded", function () {
loadVideos();
});
function loadVideos() {
fetch("videos.json")
.then(response => response.json())
.then(videos => {
const videoList = document.getElementById("video-list");
videoList.innerHTML = "";
videos.forEach(video => {
// Remove "thumbnails/" prefix if present
const thumbnail = video.thumbnail.replace("thumbnails/", "");
const videoElement = document.createElement("div");
videoElement.innerHTML = `
<div class="video-card">
<img src="thumbnails/${thumbnail}" alt="${video.video_title} Thumbnail">
<div class="video-info">
<h2>${video.video_title || "No Title"}</h2>
<p>Views: ${video.views}</p>
<p><a href="watch.php?filename=${encodeURIComponent(video.filename)}">Watch</a></p>
</div>
</div>
`;
videoList.appendChild(videoElement);
});
});
}