forked from tools/josh
parent
d6f7e9dc68
commit
a4d3f0c912
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "fwdekker.com",
|
||||
"version": "0.16.0",
|
||||
"version": "0.16.1",
|
||||
"description": "The source code of [my personal website](https://fwdekker.com/).",
|
||||
"author": "Felix W. Dekker",
|
||||
"repository": {
|
||||
|
|
|
@ -89,6 +89,7 @@ body {
|
|||
#terminalCurrentPrefix {
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
#terminalCurrentFocusInput {
|
||||
|
|
|
@ -25,15 +25,25 @@
|
|||
Please check the <a href="https://www.enable-javascript.com/">
|
||||
instructions how to enable JavaScript in your web browser</a>.
|
||||
</noscript>
|
||||
<div id="ie-warning" style="display:none;">
|
||||
This website does not function with Internet Explorer.
|
||||
Please install a newer browser such as
|
||||
<a href="https://www.microsoft.com/en-us/windows/microsoft-edge">Microsoft Edge</a>.
|
||||
</div>
|
||||
<div id="terminalOutput"></div>
|
||||
<div id="terminalCurrent">
|
||||
<span id="terminalCurrentPrefix"></span>
|
||||
<span id="terminalCurrentFocusInput" contenteditable="true" autocapitalize="none" spellcheck="false"></span>
|
||||
<span id="terminalCurrentPrefix"></span><!--
|
||||
--><span id="terminalCurrentFocusInput" contenteditable="true" autocapitalize="none"
|
||||
spellcheck="false"></span>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
|
||||
<script>
|
||||
if (/MSIE|Trident/.test(window.navigator.userAgent))
|
||||
document.getElementById("ie-warning").style.display = "block";
|
||||
</script>
|
||||
<script type="module" src="bundle.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -8,7 +8,7 @@ interface String {
|
|||
* Returns this string with all leading and trailing whitespace removed from each line.
|
||||
*/
|
||||
String.prototype.trimLines = function(): string {
|
||||
return this.split("\n").map(it => it.trimStart()).join("\n");
|
||||
return this.split("\n").map(it => it.trimLeft()).join("\n");
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@ String.prototype.trimLines = function(): string {
|
|||
* split.
|
||||
*/
|
||||
String.prototype.trimMultiLines = function(): string {
|
||||
return this.trimLines().split("\\").map(it => it.trimStart()).join("");
|
||||
return this.trimLines().split("\\").map(it => it.trimLeft()).join("");
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -61,14 +61,17 @@ export class Persistence {
|
|||
* failed.
|
||||
*/
|
||||
static getFileSystem(): FileSystem {
|
||||
try {
|
||||
const parsedFiles = Node.deserialize(localStorage.getItem("files") ?? "{}");
|
||||
if (parsedFiles instanceof Directory)
|
||||
return new FileSystem(parsedFiles);
|
||||
else
|
||||
console.warn("`files` cookie contains non-directory.");
|
||||
} catch (error) {
|
||||
console.warn("Failed to deserialize `files` cookie.", error);
|
||||
const fileString = localStorage.getItem("files");
|
||||
if (fileString !== null) {
|
||||
try {
|
||||
const parsedFiles = Node.deserialize(fileString);
|
||||
if (parsedFiles instanceof Directory)
|
||||
return new FileSystem(parsedFiles);
|
||||
else
|
||||
console.warn("`files` cookie contains non-directory.");
|
||||
} catch (error) {
|
||||
console.warn("Failed to deserialize `files` cookie.", error);
|
||||
}
|
||||
}
|
||||
|
||||
return new FileSystem();
|
||||
|
|
|
@ -28,7 +28,7 @@ export const emptyFunction = () => {};
|
|||
* @param fun the function to run as soon as the page is done loading
|
||||
*/
|
||||
export function addOnLoad(fun: () => void): void {
|
||||
const oldOnLoad = window.onload || emptyFunction;
|
||||
const oldOnLoad = window.onload ?? emptyFunction;
|
||||
|
||||
window.onload = () => {
|
||||
// @ts-ignore: Call works without parameters as well
|
||||
|
|
|
@ -98,7 +98,7 @@ export class Terminal {
|
|||
* Returns the input the user has entered in the HTML element.
|
||||
*/
|
||||
private get inputText(): string {
|
||||
return this.input.innerText.replace(/<br>/g, "");
|
||||
return this.input.innerText.replace(/<\/?br>/g, "");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -254,7 +254,7 @@ export class Terminal {
|
|||
*/
|
||||
private onclick(): void {
|
||||
// Focus on input unless user has text selected. This allows user to copy text
|
||||
if ((document.getSelection() || "").toString() === "")
|
||||
if ((document.getSelection() ?? "").toString() === "")
|
||||
this.input.focus();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue