window.onload = function () { getBankInfo(); }; async function getBankInfo() { await fetch("http://192.168.1.66/api/bankinfo.json").then(async response => { const json = await response.json(); let contentBody = ""; for (let i = 0; i < json.length; i++) { if (json[i].slots > 0) { contentBody += "

" + json[i].name + "

"; } } contentBody += "

TSOP

"; let content = document.getElementById("content"); content.innerHTML = contentBody; }).catch(error => { let content = document.getElementById("content"); content.innerHTML = "Failed to connect." }); } async function launchBank(id) { await fetch("http://192.168.1.66/api/launchbank?" + id).catch(error => { content.innerHTML = "Failed to connect." }).then(response => { if (response.status == 200) { let content = document.getElementById("content"); content.innerHTML = "Launching..." } else { let content = document.getElementById("content"); content.innerHTML = "Failed to launch." } }); } async function launchTsop() { await fetch("http://192.168.1.66/api/launchtsop").catch(error => { content.innerHTML = "Failed to connect." }).then(response => { if (response.status == 200) { let content = document.getElementById("content"); content.innerHTML = "Launching..." } else { let content = document.getElementById("content"); content.innerHTML = "Failed to launch." } }); }