| 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 part of app; | 5 part of app; |
| 6 | 6 |
| 7 abstract class LocationManager extends Observable { | 7 abstract class LocationManager extends Observable { |
| 8 final _initialPath = '/vm'; | 8 final _initialPath = '/vm'; |
| 9 ObservatoryApplication _app; | 9 ObservatoryApplication _app; |
| 10 | 10 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 event.preventDefault(); | 68 event.preventDefault(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 /// Given an application url, generate a link. | 71 /// Given an application url, generate a link. |
| 72 String makeLink(String url); | 72 String makeLink(String url); |
| 73 } | 73 } |
| 74 | 74 |
| 75 /// Uses location.hash to encode application urls. | 75 /// Uses location.hash to encode application urls. |
| 76 class HashLocationManager extends LocationManager { | 76 class HashLocationManager extends LocationManager { |
| 77 void _onStartup() { | 77 void _onStartup() { |
| 78 String initialPath = '/${window.location.hash}'; | 78 String initialPath = '${window.location.hash}'; |
| 79 if ((window.location.hash == '') || (window.location.hash == '#')) { | 79 if ((window.location.hash == '') || (window.location.hash == '#')) { |
| 80 initialPath = '/#${_initialPath}'; | 80 initialPath = '#${_initialPath}'; |
| 81 } | 81 } |
| 82 window.history.replaceState(initialPath, document.title, initialPath); | 82 window.history.pushState(initialPath, document.title, initialPath); |
| 83 _go(window.location.hash); | 83 _go(window.location.hash); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void _onLocationChange(PopStateEvent _) { | 86 void _onLocationChange(PopStateEvent _) { |
| 87 _go(window.location.hash); | 87 _go(window.location.hash); |
| 88 } | 88 } |
| 89 | 89 |
| 90 /// Given an application url, generate a link for an anchor tag. | 90 /// Given an application url, generate a link for an anchor tag. |
| 91 String makeLink(String url) { | 91 String makeLink(String url) { |
| 92 return '#$url'; | 92 return '#$url'; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 108 _go(window.location.pathname); | 108 _go(window.location.pathname); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void _onLocationChange(PopStateEvent _) { | 111 void _onLocationChange(PopStateEvent _) { |
| 112 _go(window.location.pathname); | 112 _go(window.location.pathname); |
| 113 } | 113 } |
| 114 | 114 |
| 115 /// Given an application url, generate a link for an anchor tag. | 115 /// Given an application url, generate a link for an anchor tag. |
| 116 String makeLink(String url) => url; | 116 String makeLink(String url) => url; |
| 117 } | 117 } |
| OLD | NEW |