
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();
