1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <!DOCTYPE html>
- <html>
- <body>
- <p>
- Oberon module:
- </p>
- <textarea id="source" rows="10" cols="80">
- MODULE test;
- IMPORT JS;
- BEGIN
- JS.alert("Hello, World!")
- END test.
- </textarea>
- <p>
- <button onclick="compile()">Compile</button>
- <button onclick="compile(); run()">Compile & Run</button>
- </p>
- <p id="errors" style="color:red">
- </p>
- <textarea id="result" rows="10" cols="80">
- </textarea>
- <p>
- <button onclick="run()">Run</button>
- </p>
- <script>
- function require(){}
- </script>
- <script src="oc.js"></script>
- <script>
- function compile(){
- var src = document.getElementById("source").value;
- var result;
- var errors = "";
- try {
- result = require("oc.js").compile(src, function(e){
- errors += e;
- });
- }
- catch (e) {
- errors += e;
- }
- if (!result)
- result = "";
- document.getElementById("result").value = result;
- document.getElementById("errors").textContent = errors;
- }
- function run(){
- eval(document.getElementById("result").value);
- }
- </script>
- </body>
- </html>
|