Skip to content

Commit d996855

Browse files
authored
Merge pull request #2 from spacestation13/zewaka/query-param-code
Add functionality to load code from a query param
2 parents 35bf144 + 11653af commit d996855

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/app/components/editor/editor.component.ts

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, ViewChild } from '@angular/core';
2+
import { ActivatedRoute } from '@angular/router';
23
import { EditorView } from 'codemirror';
34
import {
45
bracketMatching,
@@ -63,7 +64,7 @@ export class EditorComponent {
6364
@ViewChild('editor')
6465
private editor!: CodeEditor;
6566

66-
constructor(private executor: ExecutorService) {
67+
constructor(private executor: ExecutorService, private route: ActivatedRoute) {
6768
const noDotted = EditorView.theme({
6869
'&.cm-editor.cm-focused': {
6970
outline: 'none',
@@ -82,6 +83,23 @@ export class EditorComponent {
8283
flexGrow: 1,
8384
},
8485
});
86+
87+
// Check for URL parameter and decode if present
88+
this.route.queryParams.subscribe(params => {
89+
const encodedContent = params['code'];
90+
if (encodedContent) {
91+
const decodedContent = atob(encodedContent);
92+
this.content = `/world/New()
93+
main()
94+
..()
95+
eval("")
96+
shutdown()
97+
98+
/proc/main()
99+
${decodedContent}`
100+
}
101+
});
102+
85103
const darkMode = EditorView.theme({}, { dark: true });
86104

87105
const runCodeEffect = StateEffect.define<void>();
@@ -156,5 +174,6 @@ export class EditorComponent {
156174
[controlPanel],
157175
[runCodeField],
158176
];
177+
159178
}
160179
}

src/vm/byond.service.ts

+4
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ export class ByondService {
131131
void this.lock.run(async () => {
132132
for await (const version of (await this.getByondFolder()).keys()) {
133133
this._versions.set(version, VersionStatus.Fetched);
134+
// If this is the first version in the list, load it
135+
if (this._activeVersion == null) {
136+
await this.load(version, true);
137+
}
134138
}
135139
});
136140
void this.lock.run(() =>

0 commit comments

Comments
 (0)