no-more-proxy #3
3 changed files with 21 additions and 23 deletions
|
@ -6,13 +6,11 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>FeDirect</title>
|
||||
<link rel="stylesheet" href="/static/main.css">
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; img-src *;">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script type="module">
|
||||
Object.assign(globalThis, await import("/static/crossroad.mjs"));
|
||||
getMainDialog().show(); // Don't show until the page is ready
|
||||
</script>
|
||||
<script type="module" src="/static/crossroad.mjs"></script>
|
||||
<div class="flex-vcenter">
|
||||
<dialog id="mainDialog" class="half-width half-height">
|
||||
<header class="separator-bottom margin-large-bottom">
|
||||
|
@ -31,7 +29,7 @@
|
|||
<p id="no-instance">You currently don't have any instances. You should add one!</p>
|
||||
<form id="instanceSelectForm" class="align-start wfit-content"></form>
|
||||
<br>
|
||||
<button onclick="showAddInstanceDialog()">Add an instance</button>
|
||||
<button id="showAddInstanceDialog">Add an instance</button>
|
||||
</center>
|
||||
</div>
|
||||
<div class="half-width align-self-start">
|
||||
|
|
|
@ -5,11 +5,16 @@ import storageManager from "./storage_manager.mjs";
|
|||
|
||||
const radioButtonName = "instanceSelect";
|
||||
|
||||
const mainDialog = findDialogOrFail(document.body, "#mainDialog");
|
||||
const showAddInstanceDialogButton = findButtonOrFail(document.body, "#showAddInstanceDialog");
|
||||
const detailsDialog = findDialogOrFail(document.body, "#instanceDetails");
|
||||
const addDialog = findDialogOrFail(document.body, "#addInstance");
|
||||
const instanceSelectForm = findFormOrFail(document.body, "#instanceSelectForm");
|
||||
const redirectButton = findButtonOrFail(document.body, "#redirect");
|
||||
const redirectAlwaysButton = findButtonOrFail(document.body, "#redirectAlways");
|
||||
const pathText = findPreOrFail(document.body, "#path");
|
||||
|
||||
showAddInstanceDialogButton.addEventListener("click", e => showAddInstanceDialog());
|
||||
|
||||
redirectButton.addEventListener("click", e => {
|
||||
// Can be assumed to not fail because the button is disabled if there are no options and the first one is selected by default
|
||||
|
@ -23,29 +28,25 @@ redirectAlwaysButton.addEventListener("click", e => {
|
|||
redirect(option);
|
||||
});
|
||||
|
||||
export const getMainDialog = () => findDialogOrFail(document.body, "#mainDialog");
|
||||
let showAddInstanceDialog = () => { };
|
||||
let hideAddInstanceDialog = () => { };
|
||||
|
||||
export const {
|
||||
showAddInstanceDialog,
|
||||
hideAddInstanceDialog
|
||||
} = ((): {
|
||||
showAddInstanceDialog: () => void,
|
||||
hideAddInstanceDialog: () => void
|
||||
} => {
|
||||
// Don't bother initializing if we're performing autoredirect
|
||||
if (autoRedirect()) return {
|
||||
showAddInstanceDialog: () => { },
|
||||
hideAddInstanceDialog: () => { }
|
||||
}
|
||||
// Don't bother initializing if we're performing autoredirect
|
||||
if (!autoRedirect()) {
|
||||
createInstanceSelectOptions();
|
||||
storageManager.addSaveCallback(createInstanceSelectOptions);
|
||||
updateNoInstanceHint();
|
||||
storageManager.addSaveCallback(updateNoInstanceHint);
|
||||
|
||||
findPreOrFail(document.body, "#path").innerText = getTargetPath();
|
||||
pathText.innerText = getTargetPath();
|
||||
|
||||
return initializeAddInstanceFlow(detailsDialog, addDialog);
|
||||
})();
|
||||
({
|
||||
showAddInstanceDialog,
|
||||
hideAddInstanceDialog
|
||||
} = initializeAddInstanceFlow(detailsDialog, addDialog));
|
||||
|
||||
mainDialog.show();
|
||||
};
|
||||
|
||||
function updateNoInstanceHint() {
|
||||
findParagraphOrFail(document.body, "#no-instance").style.display =
|
||||
|
@ -140,5 +141,3 @@ function redirect(to: string) {
|
|||
url.pathname = getTargetPath();
|
||||
location.href = url.toString();
|
||||
}
|
||||
|
||||
export { storageManager };
|
|
@ -11,6 +11,7 @@ html,
|
|||
body {
|
||||
background: linear-gradient(300deg, var(--red), var(--blue));
|
||||
background-size: 100vw 100vh;
|
||||
background-attachment: fixed;
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
height: 100vh;
|
||||
|
|
Loading…
Add table
Reference in a new issue