Test-HTML / ArkReCode /script.js
GilbertClaus's picture
Auto Full Screen
165859f
raw
history blame
1.56 kB
function playVideo(charName) {
const videoPath = `https://gilbertclaus.pythonanywhere.com/video/${encodeURIComponent("Ark ReCode")}/${encodeURIComponent(charName)}.mp4`;
const wrapper = document.getElementById("videoWrapper");
wrapper.innerHTML = "";
const video = document.createElement("video");
video.src = videoPath;
video.width = 360;
video.controls = true;
video.autoplay = true;
video.volume = 0.01;
video.style.marginTop = "20px";
wrapper.appendChild(video);
// Minta fullscreen setelah video ditambahkan ke halaman
video.addEventListener("loadedmetadata", () => {
if (video.requestFullscreen) {
video.requestFullscreen();
} else if (video.webkitRequestFullscreen) { // Safari
video.webkitRequestFullscreen();
} else if (video.msRequestFullscreen) { // IE11
video.msRequestFullscreen();
}
});
}
function fetchData() {
const input = document.getElementById("charName").value.trim();
const charaBtns = document.querySelectorAll(".chara");
if (input === "") {
// Ambil status tombol pertama sebagai acuan
const isHidden = charaBtns[0].style.display === "none" || charaBtns[0].style.display === "";
// Toggle semua tombol
charaBtns.forEach(btn => {
btn.style.display = isHidden ? "inline-block" : "none";
});
} else {
const name = document.getElementById("charName").value;
alert(`Fungsi fetchData untuk karakter "${name}" belum diimplementasikan`);
}
}