| 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 library trydart.main; | 5 library trydart.main; |
| 6 | 6 |
| 7 import 'dart:html' show | 7 import 'dart:html' show |
| 8 HttpRequest, | 8 HttpRequest, |
| 9 LinkElement, | 9 LinkElement, |
| 10 querySelector, | 10 querySelector, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 try { | 44 try { |
| 45 new HttpRequest(); | 45 new HttpRequest(); |
| 46 replyTo.send(HAS_NON_DOM_HTTP_REQUEST); | 46 replyTo.send(HAS_NON_DOM_HTTP_REQUEST); |
| 47 } catch (e, trace) { | 47 } catch (e, trace) { |
| 48 replyTo.send(NO_NON_DOM_HTTP_REQUEST); | 48 replyTo.send(NO_NON_DOM_HTTP_REQUEST); |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 | 51 |
| 52 main() { | 52 main() { |
| 53 UserOption.storage = window.localStorage; | 53 UserOption.storage = window.localStorage; |
| 54 if (currentSource == null) { | 54 Map<String, String> parameters = |
| 55 Uri.parse('${window.location}').queryParameters; |
| 56 String sourceParameter = parameters['source']; |
| 57 if (sourceParameter != null) { |
| 58 currentSource = sourceParameter; |
| 59 } else if (currentSource == null) { |
| 55 currentSource = EXAMPLE_HELLO; | 60 currentSource = EXAMPLE_HELLO; |
| 56 } | 61 } |
| 57 | 62 |
| 58 buildUI(); | 63 buildUI(); |
| 59 spawnFunction(checkHttpRequest).first.then((reply) { | 64 spawnFunction(checkHttpRequest).first.then((reply) { |
| 60 ReceivePort port; | 65 ReceivePort port; |
| 61 if (reply == HAS_NON_DOM_HTTP_REQUEST) { | 66 if (reply == HAS_NON_DOM_HTTP_REQUEST) { |
| 62 port = spawnFunction(compilerIsolate); | 67 port = spawnFunction(compilerIsolate); |
| 63 } else { | 68 } else { |
| 64 port = spawnDomFunction(compilerIsolate); | 69 port = spawnDomFunction(compilerIsolate); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 81 interaction.onMutation([], observer); | 86 interaction.onMutation([], observer); |
| 82 break; | 87 break; |
| 83 default: | 88 default: |
| 84 // TODO(ahe): Close [port]? | 89 // TODO(ahe): Close [port]? |
| 85 print('Unexpected message received: $message'); | 90 print('Unexpected message received: $message'); |
| 86 break; | 91 break; |
| 87 } | 92 } |
| 88 }); | 93 }); |
| 89 }); | 94 }); |
| 90 } | 95 } |
| OLD | NEW |