Skip to content

Commit ceb1f34

Browse files
update
1 parent 1d928e5 commit ceb1f34

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

src/js/4make/makeInterface.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,32 @@ function makeInterface()
123123
evaluateButton.innerHTML = 'Activate';
124124
evaluateButton.className = 'buttonStyle001';
125125
evaluateButton.style.marginLeft = '200px';
126+
126127
evaluateButton.onclick = function()
127128
{
128-
eval(ge('htmlInput').value);
129+
// Grab the raw text from the input
130+
let rawCode = ge('htmlInput').value;
131+
132+
try
133+
{
134+
// Wrap the text in an anonymous function and execute it
135+
let result = new Function(rawCode)();
136+
137+
// Optional: Do something with the result if the user used 'return'
138+
if (result !== undefined)
139+
{
140+
console.log("Result: ", result);
141+
// ge('outputDiv').innerHTML = result; // Uncomment if you have an output div!
142+
}
143+
}
144+
catch (error)
145+
{
146+
// If they try to type HTML like <h1>Hello</h1>, it will fail safely here
147+
console.error("Syntax Error: ", error.message);
148+
// alert("Syntax Error: " + error.message);
149+
}
129150
};
151+
130152
buttonRowContainer.append(evaluateButton);
131153

132154
//-//

0 commit comments

Comments
 (0)