forked from tools/josh
Fix #18
This commit is contained in:
parent
3b8fbfac47
commit
60dd4e188f
Binary file not shown.
|
@ -12,7 +12,11 @@
|
|||
"deploy": "grunt deploy",
|
||||
"test": "echo TODO"
|
||||
},
|
||||
"dependencies": {
|
||||
"js-cookie": "^2.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/js-cookie": "^2.2.4",
|
||||
"grunt": "^1.0.4",
|
||||
"grunt-cli": "^1.3.2",
|
||||
"grunt-contrib-clean": "^2.0.0",
|
||||
|
|
|
@ -27,9 +27,6 @@
|
|||
</div>
|
||||
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.2.1/js.cookie.min.js"
|
||||
integrity="sha256-oE03O+I6Pzff4fiMqwEGHbdfcW7a3GRRxlL+U49L5sA="
|
||||
crossorigin="anonymous"></script>
|
||||
<script type="module" src="bundle.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import * as Cookies from "js-cookie";
|
||||
import "./extensions"
|
||||
import {File, FileSystem, Path} from "./fs"
|
||||
import {stripHtmlTags} from "./shared";
|
||||
|
@ -194,11 +195,8 @@ export class Commands {
|
|||
*/
|
||||
execute(inputString: string): OutputAction {
|
||||
if (inputString === "factory-reset") {
|
||||
// @ts-ignore
|
||||
Cookies.remove("files");
|
||||
// @ts-ignore
|
||||
Cookies.remove("cwd");
|
||||
// @ts-ignore
|
||||
Cookies.remove("user");
|
||||
location.reload();
|
||||
throw "Goodbye";
|
||||
|
@ -359,7 +357,6 @@ export class Commands {
|
|||
if (!(node instanceof File))
|
||||
return ["append", `'${fileName}' is not a file`];
|
||||
|
||||
// @ts-ignore: False positive
|
||||
window.open(node.contents, target);
|
||||
return ["nothing"];
|
||||
}
|
||||
|
@ -369,7 +366,6 @@ export class Commands {
|
|||
if (user === undefined)
|
||||
throw "Cannot execute `poweroff` while not logged in.";
|
||||
|
||||
// @ts-ignore
|
||||
Cookies.set("poweroff", "true", {
|
||||
"expires": new Date(new Date().setSeconds(new Date().getSeconds() + 30)),
|
||||
"path": "/"
|
||||
|
|
|
@ -3,6 +3,7 @@ import {Terminal} from "./terminal";
|
|||
|
||||
|
||||
// TODO Ignore ts-ignore in whole block
|
||||
// TODO Add interface for Window to add types
|
||||
addOnLoad(() => {
|
||||
// @ts-ignore: Force definition
|
||||
window.terminal = new Terminal(
|
||||
|
@ -16,8 +17,8 @@ addOnLoad(() => {
|
|||
// @ts-ignore: Force definition
|
||||
window.run = (command: string) => window.terminal.processInput(command);
|
||||
|
||||
// @ts-ignore
|
||||
// @ts-ignore: Force definition
|
||||
if (window.terminal.shell.userSession.isLoggedIn)
|
||||
// @ts-ignore
|
||||
// @ts-ignore: Force definition
|
||||
window.terminal.processInput("ls");
|
||||
});
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import * as Cookies from "js-cookie";
|
||||
import {Commands} from "./commands";
|
||||
import {FileSystem} from "./fs";
|
||||
import {asciiHeaderHtml} from "./shared";
|
||||
|
@ -41,7 +42,6 @@ export class Shell {
|
|||
constructor(inputHistory: InputHistory) {
|
||||
this.inputHistory = inputHistory;
|
||||
|
||||
// @ts-ignore
|
||||
const user = Cookies.get("user");
|
||||
if (user === undefined)
|
||||
this.userSession = new UserSession("felix");
|
||||
|
@ -50,7 +50,6 @@ export class Shell {
|
|||
else
|
||||
this.userSession = new UserSession(user);
|
||||
|
||||
// @ts-ignore
|
||||
this.fileSystem = new FileSystem(Cookies.get("files"), Cookies.get("cwd"));
|
||||
this.commands = new Commands(this.userSession, this.fileSystem);
|
||||
}
|
||||
|
@ -137,16 +136,13 @@ export class Shell {
|
|||
* Saves the shell's state in cookies.
|
||||
*/
|
||||
private saveState() {
|
||||
// @ts-ignore
|
||||
Cookies.set("files", this.fileSystem.serializedRoot, {
|
||||
"expires": new Date(new Date().setFullYear(new Date().getFullYear() + 25)),
|
||||
"path": "/"
|
||||
});
|
||||
// @ts-ignore
|
||||
Cookies.set("cwd", this.fileSystem.cwd, {"path": "/"});
|
||||
|
||||
const user = this.userSession.currentUser;
|
||||
// @ts-ignore
|
||||
Cookies.set("user", user === undefined ? "" : user.name, {"path": "/"});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue