dart-sdk/client/dart.js
vsm@google.com 331a3ad401 New dart.js bootstrap script for apps
The primary new add is the dart.js script.  All sample html files now point to it, and were tested with Dartium, Chrome, and FireFox.

I've checked in compiled JS so the samples 'just work'.  They were compiled via frog:

frog/minfrog --compile-only --out=client/samples/sunflower/Sunflower.dart.js client/samples/sunflower/Sunflower.dart

If you guys prefer, I can take these out.

Review URL: https://chromiumcodereview.appspot.com//9226025

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@3480 260f80e4-7a28-3924-810f-c04153c831b5
2012-01-22 23:34:35 +00:00

28 lines
1.1 KiB
JavaScript

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Bootstrap support for Dart scripts on the page as this script.
if (!document.implementation.hasFeature('dart', '1.0')) {
window.addEventListener("DOMContentLoaded", function (e) {
// Fall back to compiled JS.
var scripts = document.getElementsByTagName("script");
var length = scripts.length;
for (var i = 0; i < length; ++i) {
if (scripts[i].type == "application/dart") {
// Remap foo.dart to foo.js.
// TODO:
// - Support in-browser compilation.
// - Handle inline Dart scripts.
if (scripts[i].src && scripts[i].src != '') {
var script = document.createElement('script');
script.src = scripts[i].src + '.js';
var parent = scripts[i].parentNode;
parent.replaceChild(script, scripts[i]);
}
}
}
}, false);
}