OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 (function() { | 5 (function() { |
6 // Bootstrap support for Dart scripts on the page as this script. | 6 // Bootstrap support for Dart scripts on the page as this script. |
7 if (navigator.webkitStartDart) { | 7 if (navigator.userAgent.indexOf('(Dart)') === -1) { |
ricow1
2013/10/30 06:35:25
same comment as before
| |
8 if (!navigator.webkitStartDart()) { | |
9 document.body.innerHTML = 'This build has expired. Please download a new Da rtium at http://www.dartlang.org/dartium/index.html'; | |
10 } | |
11 } else { | |
12 // TODO: | 8 // TODO: |
13 // - Support in-browser compilation. | 9 // - Support in-browser compilation. |
14 // - Handle inline Dart scripts. | 10 // - Handle inline Dart scripts. |
15 | 11 |
16 // Fall back to compiled JS. Run through all the scripts and | 12 // Fall back to compiled JS. Run through all the scripts and |
17 // replace them if they have a type that indicate that they source | 13 // replace them if they have a type that indicate that they source |
18 // in Dart code. | 14 // in Dart code. |
19 // | 15 // |
20 // <script type="application/dart" src="..."></script> | 16 // <script type="application/dart" src="..."></script> |
21 // | 17 // |
22 var scripts = document.getElementsByTagName("script"); | 18 var scripts = document.getElementsByTagName("script"); |
23 var length = scripts.length; | 19 var length = scripts.length; |
24 for (var i = 0; i < length; ++i) { | 20 for (var i = 0; i < length; ++i) { |
25 if (scripts[i].type == "application/dart") { | 21 if (scripts[i].type == "application/dart") { |
26 // Remap foo.dart to foo.dart.js. | 22 // Remap foo.dart to foo.dart.js. |
27 if (scripts[i].src && scripts[i].src != '') { | 23 if (scripts[i].src && scripts[i].src != '') { |
28 var script = document.createElement('script'); | 24 var script = document.createElement('script'); |
29 script.src = scripts[i].src.replace(/\.dart(?=\?|$)/, '.dart.js'); | 25 script.src = scripts[i].src.replace(/\.dart(?=\?|$)/, '.dart.js'); |
30 var parent = scripts[i].parentNode; | 26 var parent = scripts[i].parentNode; |
31 // TODO(vsm): Find a solution for issue 8455 that works with more | 27 // TODO(vsm): Find a solution for issue 8455 that works with more |
32 // than one script. | 28 // than one script. |
33 document.currentScript = script; | 29 document.currentScript = script; |
34 parent.replaceChild(script, scripts[i]); | 30 parent.replaceChild(script, scripts[i]); |
35 } | 31 } |
36 } | 32 } |
37 } | 33 } |
38 } | 34 } |
39 })(); | 35 })(); |
OLD | NEW |