OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:html'; | 5 import 'dart:html'; |
6 | 6 |
7 void run() { | 7 void run() { |
8 // Get user script. | 8 // Get user script. |
9 final textarea = document.query('#code'); | 9 final textarea = document.query('#code'); |
10 final text = textarea.value; | 10 final text = textarea.value; |
11 | 11 |
12 // Clear previous output. | 12 // Clear previous output. |
13 final output = document.query('#output'); | 13 final output = document.query('#output'); |
14 output.innerHTML = ''; | 14 output.innerHtml = ''; |
15 | 15 |
16 // Run user script in new iframe. | 16 // Run user script in new iframe. |
17 final iframe = new IFrameElement(); | 17 final iframe = new IFrameElement(); |
18 iframe.height = '200'; | 18 iframe.height = '200'; |
19 iframe.width = '100%'; | 19 iframe.width = '100%'; |
20 iframe.src = '''data:text/html, | 20 iframe.src = '''data:text/html, |
21 <html> | 21 <html> |
22 <body> | 22 <body> |
23 <script type="application/dart"> | 23 <script type="application/dart"> |
24 ${text.replaceAll('\n', '%0A')} | 24 ${text.replaceAll('\n', '%0A')} |
25 </script> | 25 </script> |
26 <script>window.navigator.webkitStartDart();</script> | 26 <script>window.navigator.webkitStartDart();</script> |
27 </body> | 27 </body> |
28 </html> | 28 </html> |
29 '''; | 29 '''; |
30 output.nodes.add(iframe); | 30 output.nodes.add(iframe); |
31 } | 31 } |
32 | 32 |
33 void main() { | 33 void main() { |
34 final button = document.query('#button'); | 34 final button = document.query('#button'); |
35 button.on.click.add((e) => run(), false); | 35 button.on.click.add((e) => run(), false); |
36 } | 36 } |
OLD | NEW |