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

Side by Side Diff: runtime/bin/vmservice/client/lib/src/app/location_manager.dart

Issue 215213003: Rework the <field-view> page. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
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 part of app; 5 part of app;
6 6
7 /// The LocationManager class observes and parses the hash ('#') portion of the 7 /// The LocationManager class observes and parses the hash ('#') portion of the
8 /// URL in window.location. The text after the '#' is used as the request 8 /// URL in window.location. The text after the '#' is used as the request
9 /// string for the VM service. 9 /// string for the VM service.
10 class LocationManager extends Observable { 10 class LocationManager extends Observable {
11 static const String defaultHash = '#/vm'; 11 static const String defaultHash = '#/vm';
12 12
13 ObservatoryApplication _app; 13 ObservatoryApplication _app;
14 @observable String currentHash = ''; 14 @observable String currentHash = '';
15 15
16 void init() { 16 void init() {
17 window.onHashChange.listen((event) { 17 window.onHashChange.listen((event) {
18 // Request the current anchor. 18 // Request the current anchor.
19 requestCurrentHash(); 19 requestCurrentHash();
20 }); 20 });
21 // Set the default hash. 21
22 window.location.hash = defaultHash; 22 if (window.location.hash == '') {
23 // Fresh start, load the vm page.
24 window.location.hash = defaultHash;
25 } else {
26 // The page is being reloaded.
27 requestCurrentHash();
28 }
23 } 29 }
24 30
25 /// Clear the current hash. 31 /// Clear the current hash.
26 void clearCurrentHash() { 32 void clearCurrentHash() {
27 window.location.hash = ''; 33 window.location.hash = '';
28 } 34 }
29 35
30 /// Refresh the service object reference in the location entry. 36 /// Refresh the service object reference in the location entry.
31 void requestCurrentHash() { 37 void requestCurrentHash() {
32 currentHash = window.location.hash; 38 currentHash = window.location.hash;
33 if (!currentHash.startsWith('#/')) { 39 if (!currentHash.startsWith('#/')) {
34 return; 40 return;
35 } 41 }
36 var parts = currentHash.substring(2).split('#'); 42 var parts = currentHash.substring(2).split('#');
37 var location = parts[0]; 43 var location = parts[0];
38 var args = (parts.length > 1 ? parts[1] : ''); 44 var args = (parts.length > 1 ? parts[1] : '');
39 if (parts.length > 2) { 45 if (parts.length > 2) {
40 Logger.root.warning('Found more than 2 #-characters in $currentHash'); 46 Logger.root.warning('Found more than 2 #-characters in $currentHash');
41 } 47 }
42 _app.vm.get(currentHash.substring(2)).then((obj) { 48 _app.vm.get(currentHash.substring(2)).then((obj) {
43 _app.response = obj; 49 _app.response = obj;
44 _app.args = args; 50 _app.args = args;
45 }); 51 });
46 } 52 }
47 } 53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698