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

Unified Diff: samples/swarm/DataSource.dart

Issue 10735076: Update swarm to run from the Dart Editor with demo data (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update README Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samples/swarm/CannedData.dart ('k') | samples/swarm/README » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/swarm/DataSource.dart
diff --git a/samples/swarm/DataSource.dart b/samples/swarm/DataSource.dart
index 042da41a7c0af69f2f8d348109cabb65255e23da..aa850074dbf0018ba2ce8a8ab94a2fcc28748138 100644
--- a/samples/swarm/DataSource.dart
+++ b/samples/swarm/DataSource.dart
@@ -31,11 +31,6 @@ class Sections implements Collection<Section> {
// TODO(jimhug): Track down callers!
Iterator<Section> iterator() => _sections.iterator();
- // TODO(jimhug): Better support for switching between local dev and server.
- static bool get runningFromFile() {
- return window.location.protocol.startsWith('file:');
- }
-
static String get home() {
// TODO(jmesserly): window.location.origin not available on Safari 4.
// Move this workaround to the DOM code. See bug 5389503.
@@ -54,18 +49,14 @@ class Sections implements Collection<Section> {
callback(new Sections(sections));
}
- static void initializeFromUrl(void callback(Sections sections)) {
- if (Sections.runningFromFile) {
- initializeFromData(CannedData.data['user.data'], callback);
- } else {
- // TODO(jmesserly): display an error if we fail here! Silent failure bad.
- new XMLHttpRequest.get('data/user.data',
- EventBatch.wrap((request) {
- // TODO(jimhug): Nice response if get error back from server.
- // TODO(jimhug): Might be more efficient to parse request in sections.
- initializeFromData(request.responseText, callback);
- }));
- }
+ static void initializeFromUrl(void callback(Sections sections)) {
+ // TODO(jmesserly): display an error if we fail here! Silent failure bad.
+ new XMLHttpRequest.get('data/user.data',
+ EventBatch.wrap((request) {
+ // TODO(jimhug): Nice response if get error back from server.
+ // TODO(jimhug): Might be more efficient to parse request in sections.
+ initializeFromData(request.responseText, callback);
+ }));
Bob Nystrom 2012/07/12 21:10:08 -2 indent on the })); line.
vsm 2012/07/12 21:49:44 Hmm, the editor seems to want this indent ... but
}
Section findSectionById(String id) {
@@ -202,12 +193,7 @@ class Article {
String get thumbUrl() {
if (!hasThumbnail) return null;
- var home;
- if (Sections.runningFromFile) {
- home = 'http://dart.googleplex.com';
- } else {
- home = Sections.home;
- }
+ var home = Sections.home;
// By default images from the real server are cached.
// Bump the version flag if you change the thumbnail size, and you want to
// get the new images. Our server ignores the query params but it gets
@@ -221,15 +207,11 @@ class Article {
if (_htmlBody !== null) return;
var name = '$dataUri.html';
- if (Sections.runningFromFile) {
- _htmlBody = CannedData.data[name];
- } else {
- // TODO(jimhug): Remove this truly evil synchronoush xhr.
- final req = new XMLHttpRequest();
- req.open('GET', 'data/$name', false);
- req.send();
- _htmlBody = req.responseText;
- }
+ // TODO(jimhug): Remove this truly evil synchronoush xhr.
Bob Nystrom 2012/07/12 21:10:08 "synchronous"
vsm 2012/07/12 21:49:44 Done.
+ final req = new XMLHttpRequest();
+ req.open('GET', 'data/$name', false);
+ req.send();
+ _htmlBody = req.responseText;
}
static Article decodeHeader(Feed source, Decoder decoder) {
« no previous file with comments | « samples/swarm/CannedData.dart ('k') | samples/swarm/README » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698