diff options
author | Alon Zakai <alonzakai@gmail.com> | 2011-12-31 17:19:14 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2011-12-31 17:19:14 -0800 |
commit | d1d6cbf8701b204bf379c6d94bb15d52f6f003aa (patch) | |
tree | 8c801949722e1c8c4561ed80f61bebf4c2f76387 /src/shell.html | |
parent | eceba2944f95058ecc432e016652ffdb09c46e6b (diff) |
override print() by default, to avoid errors when using the browser print() (print to printer) if it hasn't been overridden. Overriding is now possible through Module.print
Diffstat (limited to 'src/shell.html')
-rw-r--r-- | src/shell.html | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/shell.html b/src/shell.html index 87c285ea..c096a314 100644 --- a/src/shell.html +++ b/src/shell.html @@ -9,23 +9,21 @@ <div id='output'></div> <hr> <script type='text/javascript'> - // implement print - var print = (function() { - var element = document.getElementById('output'); - return function(text) { - element.innerHTML += text.replace('\n', '<br>', 'g') + '<br>'; - }; - })(); - // connect to canvas var Module = { + print: (function() { + var element = document.getElementById('output'); + return function(text) { + element.innerHTML += text.replace('\n', '<br>', 'g') + '<br>'; + }; + })(), canvas: document.getElementById('canvas') }; try { Module.ctx2D = Module.canvas.getContext('2d'); if (!Module.ctx2D) throw 'Could not create canvas :('; } catch (e) { - print('(canvas not available)'); + Module.print('(canvas not available)'); } // The compiled code |