]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Make it node safe
authorDale Weiler <killfieldengine@gmail.com>
Tue, 13 Nov 2012 03:52:19 +0000 (03:52 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Tue, 13 Nov 2012 03:52:19 +0000 (03:52 +0000)
javascripts/vm.js
test.html

index 4b8f77ba1cfc14c28d28368993e6cd9f719e908f..ef6617c51e923f2b34cf1ea545889a1c66e3e215 100644 (file)
@@ -1,29 +1,3 @@
-var Module = {
-    preRun: [],
-    noInitialRun: true,
-    postRun: [],
-    print: (function() {
-        var element = document.getElementById('output');
-        element.value = ''; // clear browser cache
-        return function(text) {
-            // These replacements are necessary if you render to raw HTML
-            //text = text.replace(/&/g, "&amp;");
-            //text = text.replace(/</g, "&lt;");
-            //text = text.replace(/>/g, "&gt;");
-            //text = text.replace('\n', '<br>', 'g');
-            element.value += text + "\n";
-            element.scrollTop = 99999; // focus on bottom
-        };
-    })(),
-    printErr: function(text) {
-        if (0) { // XXX disabled for safety typeof dump == 'function') {
-            dump(text + '\n'); // fast, straight to the real console
-        } else {
-            console.log(text);
-        }
-    }
-};
-
 // Note: Some Emscripten settings will significantly limit the speed of the generated code.
 // Note: Some Emscripten settings may limit the speed of the generated code.
 // TODO: " u s e   s t r i c t ";
index a3370cbcc72e5bdc63c28731ab9c6fca092e55e4..8fdd98ea7d0fd5bf649896a6d091eef0add36d9b 100644 (file)
--- a/test.html
+++ b/test.html
@@ -46,7 +46,8 @@
                     <option value="13">Variadic Arguments</option>
                 </select>
                 <textarea id="input" rows="25" cols="100%" disabled="disabled"></textarea>
-                Execute: <button onclick="compile()">Execute</button>
+                <br>
+                <button onclick="compile()">Execute</button>
                 <h4>Execution Output:</h4>
                 <textarea id="output" rows="25", cols="100%"></textarea>
             </section>
                 <!--<script type="text/javascript" src="http://www.ohloh.net/p/602517/widgets/project_partner_badge.js"></script>-->
             </footer>
         </div>
+        <script>
+            var Module = {
+                preRun: [],
+                noInitialRun: true,
+                postRun: [],
+                print: (function() {
+                    var element = document.getElementById('output');
+                    element.value = ''; // clear browser cache
+                    return function(text) {
+                        // These replacements are necessary if you render to raw HTML
+                        //text = text.replace(/&/g, "&amp;");
+                        //text = text.replace(/</g, "&lt;");
+                        //text = text.replace(/>/g, "&gt;");
+                        //text = text.replace('\n', '<br>', 'g');
+                        element.value += text + "\n";
+                        element.scrollTop = 99999; // focus on bottom
+                    };
+                })(),
+                printErr: function(text) {
+                    if (0) { // XXX disabled for safety typeof dump == 'function') {
+                        dump(text + '\n'); // fast, straight to the real console
+                    } else {
+                        console.log(text);
+                    }
+                }
+            };
+        </script>
         <script src="javascripts/compiler.js"></script>
         <script src="javascripts/vm.js"></script>
         <!--[if !IE]><script>fixScale(document);</script><![endif]-->