forked from tools/josh
parent
b8dc83b960
commit
0c8e22e6e2
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "fwdekker.com",
|
||||
"version": "0.21.2",
|
||||
"version": "0.21.3",
|
||||
"description": "The source code of [my personal website](https://fwdekker.com/).",
|
||||
"author": "Felix W. Dekker",
|
||||
"repository": {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import {Persistence} from "./Persistence";
|
||||
import {addOnLoad, q} from "./Shared";
|
||||
import {Terminal} from "./Terminal";
|
||||
|
||||
|
@ -19,6 +20,12 @@ declare global {
|
|||
|
||||
|
||||
addOnLoad(() => {
|
||||
if (Persistence.getPoweroff()) {
|
||||
q("#terminalOutput").innerText = "Could not connect to fwdekker.com. Retrying in 10 seconds.";
|
||||
setTimeout(() => location.reload(), 10000);
|
||||
return;
|
||||
}
|
||||
|
||||
window.terminal = new Terminal(
|
||||
q("#terminal"),
|
||||
q("#terminalCurrentFocusInput"),
|
||||
|
|
|
@ -68,9 +68,9 @@ export class Persistence {
|
|||
if (parsedFiles instanceof Directory)
|
||||
return new FileSystem(parsedFiles);
|
||||
else
|
||||
console.warn("`files` cookie contains non-directory.");
|
||||
console.warn("'files' cookie contains non-directory.");
|
||||
} catch (error) {
|
||||
console.warn("Failed to deserialize `files` cookie.", error);
|
||||
console.warn("Failed to deserialize 'files' cookie.", error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ export class Persistence {
|
|||
try {
|
||||
return new InputHistory(JSON.parse(localStorage.getItem("history") ?? "[]"));
|
||||
} catch (error) {
|
||||
console.warn("Failed to deserialize `history` cookie.", error);
|
||||
console.warn("Failed to deserialize 'history' cookie.", error);
|
||||
return new InputHistory();
|
||||
}
|
||||
}
|
||||
|
@ -107,13 +107,25 @@ export class Persistence {
|
|||
localStorage.setItem("history", JSON.stringify(history.entries));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the persisted "power off" setting.
|
||||
*/
|
||||
static getPoweroff(): boolean {
|
||||
try {
|
||||
return JSON.parse(Cookies.get("poweroff") ?? "false");
|
||||
} catch(error) {
|
||||
console.warn("Failed to deserialize 'poweroff' cookie.", error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Persists the "power off" setting.
|
||||
*
|
||||
* @param value the value to persist for the "power off" setting
|
||||
*/
|
||||
static setPoweroff(value: boolean): void {
|
||||
Cookies.set("poweroff", `${value}`, {
|
||||
Cookies.set("poweroff", "" + value, {
|
||||
"expires": new Date(new Date().setSeconds(new Date().getSeconds() + 30)),
|
||||
"path": "/"
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue