add console clearing, allow use of console within itself
This commit is contained in:
parent
5cf909b867
commit
213b495fe8
@ -80,7 +80,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="console">
|
<div id="console">
|
||||||
<pre><code id="console-code">Karlkode 1.0</code></pre>
|
<pre id="console-code"></pre>
|
||||||
<input
|
<input
|
||||||
id="console-input"
|
id="console-input"
|
||||||
type="text"
|
type="text"
|
||||||
@ -101,7 +101,7 @@
|
|||||||
<pre
|
<pre
|
||||||
id="editor"
|
id="editor"
|
||||||
>
|
>
|
||||||
const lib = karlkoder.lib();
|
export const lib = karlkoder.lib();
|
||||||
|
|
||||||
lib.clear("green");
|
lib.clear("green");
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ export class CodeRunner {
|
|||||||
async run() {
|
async run() {
|
||||||
this.isRunning = true;
|
this.isRunning = true;
|
||||||
|
|
||||||
|
this.console.clear();
|
||||||
this.console.log("Running code...");
|
this.console.log("Running code...");
|
||||||
|
|
||||||
this.codeStopper.start();
|
this.codeStopper.start();
|
||||||
@ -57,7 +58,7 @@ export class CodeRunner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Evaluate code
|
// Evaluate code
|
||||||
const func = new Function(`"use strict";return ${code}`);
|
const func = new Function(`"use strict";let console=playgroundConsole;return ${code}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = func();
|
const result = func();
|
||||||
|
@ -40,7 +40,7 @@ export class Gamelib {
|
|||||||
try {
|
try {
|
||||||
loopFunction(deltaT);
|
loopFunction(deltaT);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.console.log(error);
|
this.console.error(error);
|
||||||
}
|
}
|
||||||
}, 16);
|
}, 16);
|
||||||
|
|
||||||
|
@ -19,6 +19,10 @@ const playgroundConsole = new PlaygroundConsole(
|
|||||||
document.querySelector("#console-code"),
|
document.querySelector("#console-code"),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
window.addEventListener('DOMContentLoaded', () => {
|
||||||
|
playgroundConsole.log("Karlkode 1.0");
|
||||||
|
});
|
||||||
|
|
||||||
const codeStopper = new CodeStopper();
|
const codeStopper = new CodeStopper();
|
||||||
|
|
||||||
const spriteProvider = new SpriteProvider();
|
const spriteProvider = new SpriteProvider();
|
||||||
|
@ -31,4 +31,8 @@ export class PlaygroundConsole {
|
|||||||
el.textContent = "" + text;
|
el.textContent = "" + text;
|
||||||
this.elem.appendChild(el);
|
this.elem.appendChild(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clear() {
|
||||||
|
this.elem.textContent = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -351,11 +351,8 @@ footer {
|
|||||||
transition: border-color 200ms ease-in-out;
|
transition: border-color 200ms ease-in-out;
|
||||||
}
|
}
|
||||||
|
|
||||||
#project-name:hover, #project-name:active {
|
#project-name:hover, #project-name:focus {
|
||||||
border-color: white;
|
border-color: white;
|
||||||
}
|
|
||||||
|
|
||||||
#project-name:focus {
|
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user