maotube/public/watch/script.js

32 lines
784 B
JavaScript
Raw Normal View History

2024-01-19 03:22:22 +00:00
function error(message) {
const errorContainer = document.getElementById("mao-error");
const errorElement = document.getElementById("mao-error-message");
errorElement.innerText = message;
errorContainer.classList.remove("hidden");
}
function main() {
const params = new URLSearchParams(window.location.search);
const id = params.get("id");
if (!id) {
error("invalid id parameter");
return;
}
const result = document.getElementById("result");
const video = document.createElement("video");
video.controls = true;
video.id = "video-player";
video.src = `/videos/${id}.mp4`;
result.appendChild(video);
video.onerror = () => {
video.remove();
error("invalid id parameter");
}
}
main();