r/learnjavascript • u/Wonderful_Ask7487 • 27d ago
How can i make javascript accept video files to archive videos on fake website?
Context - A final project that I have for my Programming with Scripting Languages class, I have to make a fake website that has pagination buttons and a minimum of three pages. I also found out that I have to include javascript in the website somehow. The html part of the code and css part of the code is already done. My fake website idea is similar to archive.org, the fake website's purpose is to archive anime music videos just incase they get removed from socials.
What I'm trying to get at is, how can i make javascript accept video files to archive videos on the fake website?
Here is the code I have so far -
<!doctype html>
<html lang="en">
<head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>AMVsArchived</title>
<style> body { background-color: #0B0F19; color: white; font-family: Arial; text-align: center; margin: 0; } header { background-color: #161F32; padding: 25px; } h1 { margin: 0; color: #00f0ff; } .page { display: none; padding: 30px; } .page.active { display: block; } .amv { background-color: #161F32; display: inline-block; margin: 15px; padding: 15px; border-radius: 10px; width: 500px; max-width: 90%; } .amv h2 { color: #00f0ff; } video { width: 100%; border-radius: 8px; } .pagination { margin: 30px; } .pagination button { background-color: #00f0ff; border: none; padding: 12px 18px; margin: 5px; border-radius: 5px; cursor: pointer; font-size: 18px; } .pagination button:hover { background-color: #FFFFFF; } .pagination button.active { background-color: blue; color: cyan; } </style>
</head> <body>
<header>
<h1>AMVs Archived</h1>
<p>We archive anime music videos here just in case they get deleted from socials.</p>
</header>
<!--PAGE 1-->
<div class="page active" id="page1">
<h2>Page 1 - Pop</h2>
<div class="amv">
<h2>Pop amv 1</h2>
<video controls muted loop>
<source src="popamv1.mp4" type="video/mp4" />
<source src="popamv1.webm" type="video/webm" />
Your browser does not support video.
</video>
</div>
<div class="amv">
<h2>Pop amv 2</h2>
<video controls muted loop>
<source src="popamv2.mp4" type="video/mp4" />
<source src="popamv2.webm" type="video/webm" />
Your browser does not support video.
</video>
</div></div>
<!--PAGE 2-->
<div class="page" id="page2"> <h2>Page 2 - Rock</h2>
<div class="amv">
<h2>Rock amv 1</h2>
<video controls muted loop>
<source src="rockamv1.mp4" type="video/mp4" />
<source src="rockamv1.webm" type="video/webm" />
Your browser does not support video.
</video>
</div>
<div class="amv">
<h2>Rock amv 2</h2>
<video controls muted loop>
<source src="rockamv2.mp4" type="video/mp4" />
<source src="rockamv2.webm" type="video/webm" />
Your browser does not support video.
</video>
</div></div>
<!--PAGE 3-->
<div class="page" id="page3"> <h2>Page 3 - Electronic</h2>
<div class="amv"> <h2>Electronic amv 1</h2>
<video controls muted loop>
<source src="electronicamv1.mp4" type="video/mp4" />
<source src="electronicamv1.webm" type="video/webm" />
Your browser does not support video.
</video></div>
<div class="amv"> <h2>Electronic amv 2</h2>
<video controls muted loop> <source src="electronicamv2.mp4" type="video/mp4" /> <source src="electronicamv2.webm" type="video/webm" /> </video> </div>
</div>
<!--PAGINATION BUTTONS-->
<div class="pagination"> <button onclick="showPage(1)">1</button> <button onclick="showPage(2)">2</button> <button onclick="showPage(3)">3</button> </div>
<script> function showPage(pageNumber) { // Hide all pages let pages = document.querySelectorAll(".page"); pages.forEach(function (page) { page.classList.remove("active"); }); // Show selected page document.getElementById("page" + pageNumber).classList.add("active"); } </script>
</body> </html>