Spaces:
Running
Running
Commit ·
cba261e
1
Parent(s): ee16a23
CORS
Browse files- ArkReCode/index.html +1 -3
- ArkReCode/script.js +34 -27
- ArkReCode/{s.js → test.js} +0 -0
ArkReCode/index.html
CHANGED
|
@@ -19,9 +19,7 @@
|
|
| 19 |
<input type="text" id="charName" placeholder="Masukkan nama karakter...">
|
| 20 |
<button onclick="fetchData()">Cari</button>
|
| 21 |
<br>
|
| 22 |
-
<
|
| 23 |
-
<button class="chara" onclick="playVideo(this)">Ermes</button>
|
| 24 |
-
<div id="result"></div>
|
| 25 |
</div>
|
| 26 |
|
| 27 |
<!-- Tempat Video Ditampilkan -->
|
|
|
|
| 19 |
<input type="text" id="charName" placeholder="Masukkan nama karakter...">
|
| 20 |
<button onclick="fetchData()">Cari</button>
|
| 21 |
<br>
|
| 22 |
+
<div id="charButtons"></div>
|
|
|
|
|
|
|
| 23 |
</div>
|
| 24 |
|
| 25 |
<!-- Tempat Video Ditampilkan -->
|
ArkReCode/script.js
CHANGED
|
@@ -30,6 +30,27 @@ function playVideo(button) {
|
|
| 30 |
// });
|
| 31 |
}
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
function fetchData() {
|
| 34 |
// Ambil elemen tombol karakter
|
| 35 |
const input = document.getElementById("charName").value.trim();
|
|
@@ -53,7 +74,7 @@ function fetchData() {
|
|
| 53 |
|
| 54 |
// Pilih URL video berdasarkan status tombol
|
| 55 |
const newVideoURL = isSafe
|
| 56 |
-
? `${baseURL}/video/${encodeURIComponent("Edalia Skill")}.mp4`
|
| 57 |
: `https://video.twimg.com/ext_tw_video/1892164405464629249/pu/vid/avc1/1280x720/cgW9XdNOX1DPI6Rq.mp4`;
|
| 58 |
|
| 59 |
// Set dan muat ulang video
|
|
@@ -62,9 +83,7 @@ function fetchData() {
|
|
| 62 |
video.play();
|
| 63 |
|
| 64 |
} else {
|
| 65 |
-
|
| 66 |
-
showNotif(`Fungsi fetchData untuk karakter "${name}" belum diimplementasikan`);
|
| 67 |
-
|
| 68 |
}
|
| 69 |
}
|
| 70 |
|
|
@@ -74,33 +93,21 @@ window.onload = () => {
|
|
| 74 |
.then(res => res.json())
|
| 75 |
.then(data => {
|
| 76 |
const container = document.getElementById("charButtons");
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
const btn = document.createElement("button");
|
| 79 |
btn.textContent = name;
|
| 80 |
btn.className = "chara";
|
| 81 |
-
btn.onclick =
|
|
|
|
|
|
|
| 82 |
container.appendChild(btn);
|
| 83 |
});
|
|
|
|
|
|
|
|
|
|
| 84 |
});
|
| 85 |
};
|
| 86 |
-
|
| 87 |
-
function showNotif(message, duration = 3000) {
|
| 88 |
-
const notif = document.createElement("div");
|
| 89 |
-
notif.className = "notif";
|
| 90 |
-
notif.textContent = message;
|
| 91 |
-
|
| 92 |
-
document.body.appendChild(notif);
|
| 93 |
-
|
| 94 |
-
// Trigger fade-in
|
| 95 |
-
requestAnimationFrame(() => {
|
| 96 |
-
notif.style.opacity = 1;
|
| 97 |
-
});
|
| 98 |
-
|
| 99 |
-
// Auto-hide
|
| 100 |
-
setTimeout(() => {
|
| 101 |
-
notif.style.opacity = 0;
|
| 102 |
-
setTimeout(() => {
|
| 103 |
-
notif.remove();
|
| 104 |
-
}, 500); // Tunggu animasi selesai
|
| 105 |
-
}, duration);
|
| 106 |
-
}
|
|
|
|
| 30 |
// });
|
| 31 |
}
|
| 32 |
|
| 33 |
+
function showNotif(message, duration = 3000) {
|
| 34 |
+
const notif = document.createElement("div");
|
| 35 |
+
notif.className = "notif";
|
| 36 |
+
notif.textContent = message;
|
| 37 |
+
|
| 38 |
+
document.body.appendChild(notif);
|
| 39 |
+
|
| 40 |
+
// Trigger fade-in
|
| 41 |
+
requestAnimationFrame(() => {
|
| 42 |
+
notif.style.opacity = 1;
|
| 43 |
+
});
|
| 44 |
+
|
| 45 |
+
// Auto-hide
|
| 46 |
+
setTimeout(() => {
|
| 47 |
+
notif.style.opacity = 0;
|
| 48 |
+
setTimeout(() => {
|
| 49 |
+
notif.remove();
|
| 50 |
+
}, 500); // Tunggu animasi selesai
|
| 51 |
+
}, duration);
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
function fetchData() {
|
| 55 |
// Ambil elemen tombol karakter
|
| 56 |
const input = document.getElementById("charName").value.trim();
|
|
|
|
| 74 |
|
| 75 |
// Pilih URL video berdasarkan status tombol
|
| 76 |
const newVideoURL = isSafe
|
| 77 |
+
? `${baseURL}/video/${encodeURIComponent("Ark ReCode - Edalia Skill")}.mp4`
|
| 78 |
: `https://video.twimg.com/ext_tw_video/1892164405464629249/pu/vid/avc1/1280x720/cgW9XdNOX1DPI6Rq.mp4`;
|
| 79 |
|
| 80 |
// Set dan muat ulang video
|
|
|
|
| 83 |
video.play();
|
| 84 |
|
| 85 |
} else {
|
| 86 |
+
showNotif(`Fungsi fetchData untuk karakter "${input}" belum diimplementasikan`);
|
|
|
|
|
|
|
| 87 |
}
|
| 88 |
}
|
| 89 |
|
|
|
|
| 93 |
.then(res => res.json())
|
| 94 |
.then(data => {
|
| 95 |
const container = document.getElementById("charButtons");
|
| 96 |
+
|
| 97 |
+
// Urutkan nama-nama video secara alfabet
|
| 98 |
+
const sortedNames = data.videos.sort((a, b) => a.localeCompare(b));
|
| 99 |
+
|
| 100 |
+
sortedNames.forEach(name => {
|
| 101 |
const btn = document.createElement("button");
|
| 102 |
btn.textContent = name;
|
| 103 |
btn.className = "chara";
|
| 104 |
+
btn.onclick = function () {
|
| 105 |
+
playVideo(this);
|
| 106 |
+
};
|
| 107 |
container.appendChild(btn);
|
| 108 |
});
|
| 109 |
+
})
|
| 110 |
+
.catch(err => {
|
| 111 |
+
showNotif("Gagal ambil daftar karakter dari server");
|
| 112 |
});
|
| 113 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ArkReCode/{s.js → test.js}
RENAMED
|
File without changes
|