Spaces:
Running
Running
Commit ·
e0449c8
1
Parent(s): 165859f
Change BG Video
Browse files- ArkReCode/index.html +2 -2
- ArkReCode/script.js +43 -4
ArkReCode/index.html
CHANGED
|
@@ -19,8 +19,8 @@
|
|
| 19 |
<input type="text" id="charName" placeholder="Masukkan nama karakter...">
|
| 20 |
<button onclick="fetchData()">Cari</button>
|
| 21 |
<br>
|
| 22 |
-
<button class="chara" onclick="playVideo(
|
| 23 |
-
<button class="chara" onclick="playVideo(
|
| 24 |
<div id="result"></div>
|
| 25 |
</div>
|
| 26 |
|
|
|
|
| 19 |
<input type="text" id="charName" placeholder="Masukkan nama karakter...">
|
| 20 |
<button onclick="fetchData()">Cari</button>
|
| 21 |
<br>
|
| 22 |
+
<button class="chara" onclick="playVideo(this)">Edalia</button>
|
| 23 |
+
<button class="chara" onclick="playVideo(this)">Ermes</button>
|
| 24 |
<div id="result"></div>
|
| 25 |
</div>
|
| 26 |
|
ArkReCode/script.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
| 1 |
-
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
| 4 |
const wrapper = document.getElementById("videoWrapper");
|
| 5 |
wrapper.innerHTML = "";
|
|
@@ -26,19 +30,54 @@ function playVideo(charName) {
|
|
| 26 |
}
|
| 27 |
|
| 28 |
function fetchData() {
|
|
|
|
| 29 |
const input = document.getElementById("charName").value.trim();
|
| 30 |
const charaBtns = document.querySelectorAll(".chara");
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
if (input === "") {
|
| 33 |
// Ambil status tombol pertama sebagai acuan
|
| 34 |
const isHidden = charaBtns[0].style.display === "none" || charaBtns[0].style.display === "";
|
| 35 |
|
| 36 |
// Toggle semua tombol
|
| 37 |
charaBtns.forEach(btn => {
|
| 38 |
-
|
| 39 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
} else {
|
| 41 |
const name = document.getElementById("charName").value;
|
| 42 |
alert(`Fungsi fetchData untuk karakter "${name}" belum diimplementasikan`);
|
| 43 |
}
|
| 44 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Ganti domain kamu di sini:
|
| 2 |
+
const baseURL = "https://gilbertclaus.pythonanywhere.com";
|
| 3 |
+
|
| 4 |
+
function playVideo(button) {
|
| 5 |
+
const charName = button.textContent.trim();
|
| 6 |
+
const videoPath = `${baseURL}/video/${encodeURIComponent("Ark ReCode")}/${encodeURIComponent(charName)}.mp4`;
|
| 7 |
|
| 8 |
const wrapper = document.getElementById("videoWrapper");
|
| 9 |
wrapper.innerHTML = "";
|
|
|
|
| 30 |
}
|
| 31 |
|
| 32 |
function fetchData() {
|
| 33 |
+
// Ambil elemen tombol karakter
|
| 34 |
const input = document.getElementById("charName").value.trim();
|
| 35 |
const charaBtns = document.querySelectorAll(".chara");
|
| 36 |
|
| 37 |
+
// Ambil elemen video
|
| 38 |
+
const video = document.getElementById("bgVideo");
|
| 39 |
+
const source = video.querySelector("source");
|
| 40 |
+
|
| 41 |
if (input === "") {
|
| 42 |
// Ambil status tombol pertama sebagai acuan
|
| 43 |
const isHidden = charaBtns[0].style.display === "none" || charaBtns[0].style.display === "";
|
| 44 |
|
| 45 |
// Toggle semua tombol
|
| 46 |
charaBtns.forEach(btn => {
|
| 47 |
+
btn.style.display = isHidden ? "inline-block" : "none";
|
| 48 |
});
|
| 49 |
+
|
| 50 |
+
// Cek apakah sedang bukan video Edalia
|
| 51 |
+
const isSafe = !source.src.includes("Edalia");
|
| 52 |
+
|
| 53 |
+
// Pilih URL video berdasarkan status tombol
|
| 54 |
+
const newVideoURL = isSafe
|
| 55 |
+
? `${baseURL}/video/${encodeURIComponent("Edalia Skill")}.mp4`
|
| 56 |
+
: `https://video.twimg.com/ext_tw_video/1892164405464629249/pu/vid/avc1/1280x720/cgW9XdNOX1DPI6Rq.mp4`;
|
| 57 |
+
|
| 58 |
+
// Set dan muat ulang video
|
| 59 |
+
source.src = newVideoURL;
|
| 60 |
+
video.load();
|
| 61 |
+
video.play();
|
| 62 |
+
|
| 63 |
} else {
|
| 64 |
const name = document.getElementById("charName").value;
|
| 65 |
alert(`Fungsi fetchData untuk karakter "${name}" belum diimplementasikan`);
|
| 66 |
}
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
// Ambil daftar karakter dari server
|
| 70 |
+
window.onload = () => {
|
| 71 |
+
fetch(`${baseURL}/list-videos`)
|
| 72 |
+
.then(res => res.json())
|
| 73 |
+
.then(data => {
|
| 74 |
+
const container = document.getElementById("charButtons");
|
| 75 |
+
data.videos.forEach(name => {
|
| 76 |
+
const btn = document.createElement("button");
|
| 77 |
+
btn.textContent = name;
|
| 78 |
+
btn.className = "chara";
|
| 79 |
+
btn.onclick = () => playVideo(name);
|
| 80 |
+
container.appendChild(btn);
|
| 81 |
+
});
|
| 82 |
+
});
|
| 83 |
+
};
|