Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(610)

Side by Side Diff: src/site/codelabs/darrrt/examples/packages/browser/dart.js

Issue 339243004: Update generated JS for codelab's pirate app. (Closed) Base URL: https://github.com/dart-lang/dartlang.org.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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) {
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 (type="application/dart").
19 //
20 // <script type="application/dart" src="..."></script>
21 //
22 var scripts = document.getElementsByTagName("script"); 15 var scripts = document.getElementsByTagName("script");
23 var length = scripts.length; 16 var length = scripts.length;
24 for (var i = 0; i < length; ++i) { 17 for (var i = 0; i < length; ++i) {
25 if (scripts[i].type == "application/dart") { 18 if (scripts[i].type == "application/dart") {
26 // Remap foo.dart to foo.dart.js. 19 // Remap foo.dart to foo.dart.js.
27 if (scripts[i].src && scripts[i].src != '') { 20 if (scripts[i].src && scripts[i].src != '') {
28 var script = document.createElement('script'); 21 var script = document.createElement('script');
29 script.src = scripts[i].src.replace(/\.dart(?=\?|$)/, '.dart.js'); 22 script.src = scripts[i].src.replace(/\.dart(?=\?|$)/, '.dart.js');
30 var parent = scripts[i].parentNode; 23 var parent = scripts[i].parentNode;
31 // TODO(vsm): Find a solution for issue 8455 that works with more 24 // TODO(vsm): Find a solution for issue 8455 that works with more
32 // than one script. 25 // than one script.
33 document.currentScript = script; 26 document.currentScript = script;
34 parent.replaceChild(script, scripts[i]); 27 parent.replaceChild(script, scripts[i]);
35 } 28 }
36 } 29 }
37 } 30 }
38 } 31 }
39 })(); 32 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698