diff --git a/browser/app.js b/browser/app.js new file mode 100644 index 0000000..d923310 --- /dev/null +++ b/browser/app.js @@ -0,0 +1,31 @@ +import { hi2js } from '../transpiler.js'; + +document.addEventListener('DOMContentLoaded', () => { + const hiInput = document.getElementById('hi-input'); + const jsOutput = document.getElementById('js-output'); + + const transpile = () => { + const hiCode = hiInput.value; + try { + const jsCode = hi2js(hiCode); + jsOutput.value = jsCode; + jsOutput.style.color = '#333'; + } catch (e) { + jsOutput.value = `Error: ${e.message}`; + jsOutput.style.color = 'red'; + } + }; + + hiInput.addEventListener('input', transpile); + + hiInput.value = `// Welcome, Master. +message: "Hello from the browser!" +_(message) + +// Try changing the value +count: 10 +count = count + 5 +_("The new count is", count) +`; + transpile(); +});