Chromium Code Reviews| 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 var warning = [ | 5 var warning = [ |
| 6 'WARNING: This page is using a deprecated dart.js file. ', | 6 'WARNING: This page is using a deprecated dart.js file. ', |
| 7 'Please update this page as described here: ', | 7 'Please update this page as described here: ', |
| 8 'http://news.dartlang.org/2013/01/big-breaking-change-dartjs-bootstrap-file-mo ving-to-pub.html' | 8 'http://news.dartlang.org/2013/01/big-breaking-change-dartjs-bootstrap-file-mo ving-to-pub.html' |
| 9 ].join(''); | 9 ].join(''); |
| 10 console.error(warning); | 10 console.error(warning); |
| 11 | 11 |
| 12 // Bootstrap support for Dart scripts on the page as this script. | 12 // Bootstrap support for Dart scripts on the page as this script. |
| 13 if (navigator.webkitStartDart) { | 13 if (navigator.userAgent.indexOf('(Dart)') === -1) { |
|
ricow1
2013/10/30 06:35:25
indexOf should always return a number, so strictly
| |
| 14 if (!navigator.webkitStartDart()) { | |
| 15 document.body.innerHTML = 'This build has expired. Please download a new Da rtium at http://www.dartlang.org/dartium/index.html'; | |
| 16 } | |
| 17 } else { | |
| 18 // TODO: | 14 // TODO: |
| 19 // - Support in-browser compilation. | 15 // - Support in-browser compilation. |
| 20 // - Handle inline Dart scripts. | 16 // - Handle inline Dart scripts. |
| 21 window.addEventListener("DOMContentLoaded", function (e) { | 17 window.addEventListener("DOMContentLoaded", function (e) { |
| 22 // Fall back to compiled JS. Run through all the scripts and | 18 // Fall back to compiled JS. Run through all the scripts and |
| 23 // replace them if they have a type that indicate that they source | 19 // replace them if they have a type that indicate that they source |
| 24 // in Dart code. | 20 // in Dart code. |
| 25 // | 21 // |
| 26 // <script type="application/dart" src="..."></script> | 22 // <script type="application/dart" src="..."></script> |
| 27 // | 23 // |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 204 }; | 200 }; |
| 205 | 201 |
| 206 ReceivePortSync.prototype.toSendPort = function() { | 202 ReceivePortSync.prototype.toSendPort = function() { |
| 207 return new LocalSendPortSync(this); | 203 return new LocalSendPortSync(this); |
| 208 }; | 204 }; |
| 209 | 205 |
| 210 ReceivePortSync.prototype.close = function() { | 206 ReceivePortSync.prototype.close = function() { |
| 211 delete ReceivePortSync.map[this.id]; | 207 delete ReceivePortSync.map[this.id]; |
| 212 }; | 208 }; |
| 213 | 209 |
| 214 if (navigator.webkitStartDart) { | 210 if (navigator.userAgent.indexOf('(Dart)') !== -1) { |
| 215 window.addEventListener('js-sync-message', function(event) { | 211 window.addEventListener('js-sync-message', function(event) { |
| 216 var data = JSON.parse(getPortSyncEventData(event)); | 212 var data = JSON.parse(getPortSyncEventData(event)); |
| 217 var deserialized = deserialize(data.message); | 213 var deserialized = deserialize(data.message); |
| 218 var result = ReceivePortSync.map[data.id].callback(deserialized); | 214 var result = ReceivePortSync.map[data.id].callback(deserialized); |
| 219 // TODO(vsm): Handle and propagate exceptions. | 215 // TODO(vsm): Handle and propagate exceptions. |
| 220 dispatchEvent('js-result', serialize(result)); | 216 dispatchEvent('js-result', serialize(result)); |
| 221 }, false); | 217 }, false); |
| 222 } | 218 } |
| 223 | 219 |
| 224 function LocalSendPortSync(receivePort) { | 220 function LocalSendPortSync(receivePort) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 var result = null; | 256 var result = null; |
| 261 var listener = function (e) { | 257 var listener = function (e) { |
| 262 result = JSON.parse(getPortSyncEventData(e)); | 258 result = JSON.parse(getPortSyncEventData(e)); |
| 263 }; | 259 }; |
| 264 window.addEventListener(source, listener, false); | 260 window.addEventListener(source, listener, false); |
| 265 dispatchEvent(target, [source, serialized]); | 261 dispatchEvent(target, [source, serialized]); |
| 266 window.removeEventListener(source, listener, false); | 262 window.removeEventListener(source, listener, false); |
| 267 return deserialize(result); | 263 return deserialize(result); |
| 268 } | 264 } |
| 269 })(); | 265 })(); |
| OLD | NEW |