|
@@ -2,7 +2,7 @@
|
|
|
* The code box class
|
|
|
*/
|
|
|
class CodeBox {
|
|
|
- constructor() {
|
|
|
+ constructor(codeBoxID, initialStackID, outputID) {
|
|
|
/**
|
|
|
* Possible vectors the pointer can move in
|
|
|
* @type {Object}
|
|
@@ -59,6 +59,21 @@ class CodeBox {
|
|
|
* @type {Stack}
|
|
|
*/
|
|
|
this.stack = new Stack();
|
|
|
+
|
|
|
+ this.codeBoxDOM = document.getElementById(codeBoxID);
|
|
|
+ if(!this.codeBoxDOM) {
|
|
|
+ throw new Error(`Failed to find textarea with ID: ${codeBoxID}`);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.outputDOM = document.getElementById(outputID);
|
|
|
+ if(!this.outputDOM) {
|
|
|
+ throw new Error(`Failed to find textarea with ID: ${outputID}`);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.initialStackDOM = document.getElementById(initialStackID);
|
|
|
+ if(!this.initialStackDOM) {
|
|
|
+ throw new Error(`Failed to find input with ID: ${initialStackID}`);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -68,7 +83,7 @@ class CodeBox {
|
|
|
* @param {*} value
|
|
|
*/
|
|
|
Output(value) {
|
|
|
- console.log(value);
|
|
|
+ this.outputDOM.value += value;
|
|
|
}
|
|
|
|
|
|
Execute(instruction) {
|