Skip to content

Commit

Permalink
properly unfuck installer
Browse files Browse the repository at this point in the history
  • Loading branch information
twnlink committed Jun 4, 2024
1 parent 881a5d6 commit 7da187a
Showing 1 changed file with 43 additions and 18 deletions.
61 changes: 43 additions & 18 deletions frontend/install/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@

const installButton = document.getElementById("install-button");
const uninstallButton = document.getElementById("uninstall-button");
const fetchStatus = async () =>
(await (await fetch(server + "status")).text()) == "installed";

installButton.style.display = "none";
uninstallButton.style.display = "none";

async function showCorrectButton() {
const installed =
(await (await fetch(server + "status")).text()) == "installed";
const installed = await fetchStatus();

if (installed) {
uninstallButton.style.display = "block";
Expand All @@ -35,33 +36,56 @@
uninstallButton.style.display = "none";
}
}

const installNeptune = () => fetch(server + "install", { method: "POST", mode: "no-cors" });
const uninstallNeptune = () => fetch(server + "uninstall", { method: "POST", mode: "no-cors" });

const installNeptune = () =>
fetch(server + "install", { method: "POST", mode: "no-cors" });
const uninstallNeptune = () =>
fetch(server + "uninstall", { method: "POST", mode: "no-cors" });

installButton.addEventListener("click", async (e) => {
installButton.disabled = true;

const succeeded = await installNeptune().then(r => r.ok);
await installNeptune();

const installed = await fetchStatus();
if (!installed) {
installButton.disabled = false;

return alert(
"neptune failed to install! make sure to close TIDAL before installing."
);
}

alert(
"neptune is installed. feel free to close this tab whenever you'd like."
);

if (!succeeded) return alert("neptune failed to install! make sure to close TIDAL before installing.")

alert("neptune is installed. feel free to close this tab whenever you'd like.")

await showCorrectButton();

installButton.disabled = false;
})
});

uninstallButton.addEventListener("click", async (e) => {
uninstallButton.disabled = true;

await uninstallNeptune();
alert("neptune is uninstalled. feel free to close this tab whenever you'd like.")

const installed = await fetchStatus();
if (installed) {
uninstallButton.disabled = false;

return alert(
"neptune failed to uninstall! make sure to close TIDAL before uninstalling."
);
}

alert(
"neptune is uninstalled. feel free to close this tab whenever you'd like."
);
await showCorrectButton();

uninstallButton.disabled = false;
})
});

showCorrectButton();
</script>
Expand All @@ -82,7 +106,7 @@

#install-button {
background-color: #314648;
color: #7DFBEE;
color: #7dfbee;
}

#uninstall-button {
Expand All @@ -101,17 +125,18 @@
height: 400px;
border-radius: 20px;
font-weight: 500;
font-family: Avenir, Montserrat, Corbel, 'URW Gothic', source-sans-pro, sans-serif;
font-family: Avenir, Montserrat, Corbel, "URW Gothic", source-sans-pro,
sans-serif;
font-size: 90px;
cursor: pointer;
}

button:hover {
filter:brightness(1.1)
filter: brightness(1.1);
}

button:active {
filter: brightness(0.9)
filter: brightness(0.9);
}
</style>
</body>
Expand Down

0 comments on commit 7da187a

Please sign in to comment.