2022-12-30 20:14:35 +01:00
|
|
|
function play() {
|
|
|
|
console.log("Play...");
|
|
|
|
var xhttp = new XMLHttpRequest();
|
|
|
|
xhttp.open("GET", "play", true);
|
|
|
|
xhttp.send();
|
|
|
|
}
|
2023-01-01 02:43:54 +01:00
|
|
|
|
|
|
|
function loadAvailableFiles() {
|
|
|
|
console.log("Available files...");
|
|
|
|
fetch("/available-files")
|
|
|
|
.then(response => response.json())
|
2023-01-01 02:55:32 +01:00
|
|
|
.then(handleAvailableFiles);
|
2023-01-01 02:43:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function selectFile(name) {
|
|
|
|
console.log("Select file");
|
|
|
|
const body = new FormData();
|
|
|
|
body.set("fileName", name);
|
|
|
|
fetch("/select-file", {method: "POST", body: body})
|
2023-01-01 02:55:32 +01:00
|
|
|
.then(response => response.json())
|
|
|
|
.then(handleAvailableFiles);
|
|
|
|
}
|
|
|
|
|
|
|
|
function handleAvailableFiles(data) {
|
|
|
|
console.log("data", data);
|
|
|
|
let dom = "";
|
|
|
|
data.files.forEach(element => {
|
|
|
|
if (element === data.selectedFile) {
|
|
|
|
dom += `<button class="w3-button w3-green" onclick="selectFile('${element}')">${element}</button>`;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
dom += `<button class="w3-button w3-blue" onclick="selectFile('${element}')">${element}</button>`;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
document.getElementById("available-files").innerHTML = dom;
|
2023-01-01 02:43:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
(() => {
|
|
|
|
loadAvailableFiles();
|
2023-01-01 18:14:41 +01:00
|
|
|
setInterval(loadAvailableFiles, 10000);
|
2023-01-01 02:43:54 +01:00
|
|
|
})();
|