Move initialising code to `main.ts`
This commit is contained in:
parent
2c80d42960
commit
9d714795ba
|
@ -27,6 +27,6 @@
|
|||
</div>
|
||||
|
||||
|
||||
<script type="module" src="js/terminal.js"></script>
|
||||
<script type="module" src="js/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
import {addOnLoad, q} from "./shared.js";
|
||||
import {Terminal} from "./terminal.js";
|
||||
|
||||
|
||||
// TODO Ignore ts-ignore in whole block
|
||||
addOnLoad(() => {
|
||||
// @ts-ignore: Force definition
|
||||
window.terminal = new Terminal(
|
||||
q("#terminal"),
|
||||
q("#terminalCurrentFocusInput"),
|
||||
q("#terminalOutput"),
|
||||
q("#terminalCurrentPrefix")
|
||||
);
|
||||
// @ts-ignore: Force definition
|
||||
window.relToAbs = (filename: string) => window.terminal.fileSystem.pwd + filename;
|
||||
// @ts-ignore: Force definition
|
||||
window.run = (command: string) => window.terminal.processInput(command);
|
||||
|
||||
// @ts-ignore
|
||||
window.terminal.processInput("ls");
|
||||
});
|
|
@ -1,4 +1,4 @@
|
|||
import {addOnLoad, asciiHeaderHtml, moveCaretToEndOf, q} from "./shared.js";
|
||||
import {asciiHeaderHtml, moveCaretToEndOf} from "./shared.js";
|
||||
import {FileSystem} from "./fs.js";
|
||||
import {Commands} from "./commands.js";
|
||||
import {System} from "./system.js";
|
||||
|
@ -242,22 +242,3 @@ class InputHistory {
|
|||
return this.getEntry(this.index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export let terminal: Terminal;
|
||||
|
||||
addOnLoad(() => {
|
||||
terminal = new Terminal(
|
||||
q("#terminal"),
|
||||
q("#terminalCurrentFocusInput"),
|
||||
q("#terminalOutput"),
|
||||
q("#terminalCurrentPrefix")
|
||||
);
|
||||
|
||||
// @ts-ignore: Force definition
|
||||
window.relToAbs = (filename: string) => terminal.fileSystem.pwd + filename;
|
||||
// @ts-ignore: Force definition
|
||||
window.run = (command: string) => terminal.processInput(command);
|
||||
|
||||
terminal.processInput("ls");
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue