forked from tools/josh
1
0
Fork 0

Fix autoscrolling after clicking

This commit is contained in:
Florine W. Dekker 2021-04-23 00:30:13 +02:00
parent e9c617716e
commit 0237225750
Signed by: FWDekker
GPG Key ID: B1B567AF58D6EE0F
6 changed files with 10 additions and 9 deletions

View File

@ -1,6 +1,6 @@
{
"name": "fwdekker.com",
"version": "0.40.1",
"version": "0.40.2",
"description": "The source code of [my personal website](https://fwdekker.com/).",
"author": "Felix W. Dekker",
"browser": "dist/bundle.js",

View File

@ -1,8 +1,9 @@
#terminal a {
cursor: pointer;
text-decoration: none;
}
#terminal a:link, #terminal a:visited {
#terminal a, #terminal a:link, #terminal a:visited {
color: #00FF00;
}

View File

@ -641,7 +641,7 @@ return new Command(
const commandWidth = Math.max.apply(null, commandNames.map(it => it.length)) + 4;
const commandPaddings = commandNames.map(it => commandWidth - it.length);
const commandLinks = commandNames
.map(it => \`<a href="#" onclick="execute('help \${it}')">\${it}</a>\`)
.map(it => \`<a onclick="execute('help \${it}')">\${it}</a>\`)
.map((it, i) => \`\${it.padEnd(it.length + commandPaddings[i], " ")}\`);
const commandEntries = commandNames
.map((it, i) => \`\${commandLinks[i]}\${commands[it].summary}\`);

View File

@ -615,7 +615,7 @@ export class Directory extends Node {
* @param path the path to this node
*/
nameString(name: string, path: Path): string {
return `<a href="#" class="dirLink" onclick="execute('${path.toString(true)}; and ls -l')">${name}</a>`;
return `<a class="dirLink" onclick="execute('${path.toString(true)}; and ls -l')">${name}</a>`;
}
visit(path: string,
@ -715,7 +715,7 @@ export class File extends Node {
switch (this.mime ?? getFileExtension(name)) {
case "jsh": {
const script = `execute('${path.toString(true)}'); return false`;
return `<a href="#" class="fileLink" onclick="${script}">${name}</a>`;
return `<a class="fileLink" onclick="${script}">${name}</a>`;
}
case "lnk": {
const script = `execute('open ${path.toString(true)}'); return false`;
@ -723,7 +723,7 @@ export class File extends Node {
}
case "txt": {
const script = `execute('cat ${path.toString(true)}')`;
return `<a href="#" class="fileLink" onclick="${script}">${name}</a>`;
return `<a class="fileLink" onclick="${script}">${name}</a>`;
}
default:
return name;

View File

@ -73,7 +73,7 @@ export class Shell {
</span>@ <a href="https://www.tudelft.nl/en/" ${target}>TU Delft</a>, the Netherlands
<span class="wideScreenOnly">${(new Date()).toISOString()}
</span>
Type "<a href="#" onclick="execute('help');">help</a>" for help.
Type "<a onclick="execute('help');">help</a>" for help.
Welcome to josh v%%VERSION_NUMBER%%, the javascript online shell.
`.trimLines();

View File

@ -52,12 +52,12 @@ describe("file", () => {
it("uses the file extension to determine the value", () => {
expect(new File("contents").nameString("file.txt", new Path("/file")))
.to.equal(`<a href="#" class="fileLink" onclick="execute('cat /file')">file.txt</a>`);
.to.equal(`<a class="fileLink" onclick="execute('cat /file')">file.txt</a>`);
});
it("uses the mime type if no type is known", () => {
expect(new File("contents", "txt").nameString("file", new Path("/file")))
.to.equal(`<a href="#" class="fileLink" onclick="execute('cat /file')">file</a>`);
.to.equal(`<a class="fileLink" onclick="execute('cat /file')">file</a>`);
});
it("overrides the file extension with the mime type", () => {