Make it node safe

This commit is contained in:
Dale Weiler 2012-11-13 03:52:19 +00:00
parent 369db58bab
commit 4f4ef893f4
2 changed files with 29 additions and 27 deletions

View 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, "&");
//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 ";

View file

@ -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>
@ -54,6 +55,33 @@
<!--<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]-->