| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 swarmlib; | 5 part of swarmlib; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A simple news reader in Dart. | 8 * A simple news reader in Dart. |
| 9 */ | 9 */ |
| 10 class Swarm extends App { | 10 class Swarm extends App { |
| 11 /** | 11 /** |
| 12 * Flag to insure the onLoad isn't called when callback from initializeFromUrl | 12 * Flag to insure the onLoad isn't called when callback from initializeFromUrl |
| 13 * could occur before the document's onload event. | 13 * could occur before the document's onload event. |
| 14 */ | 14 */ |
| 15 bool onLoadFired; | 15 bool onLoadFired; |
| 16 | 16 |
| 17 /** Collections of datafeeds to show per page. */ | 17 /** Collections of datafeeds to show per page. */ |
| 18 Sections sections; | 18 Sections sections; |
| 19 | 19 |
| 20 /** The front page of the app. */ | 20 /** The front page of the app. */ |
| 21 FrontView frontView; | 21 FrontView frontView; |
| 22 | 22 |
| 23 /** Observable UI state. */ | 23 /** Observable UI state. */ |
| 24 SwarmState state; | 24 SwarmState state; |
| 25 | 25 |
| 26 Swarm() : super(), onLoadFired = false { | 26 Swarm({bool useCannedData : false}) : super(), onLoadFired = false { |
| 27 Sections.initializeFromUrl((currSections) { | 27 Sections.initializeFromUrl(useCannedData, (currSections) { |
| 28 sections = currSections; | 28 sections = currSections; |
| 29 state = new SwarmState(sections); | 29 state = new SwarmState(sections); |
| 30 setupApp(); | 30 setupApp(); |
| 31 }); | 31 }); |
| 32 // Catch user keypresses and decide whether to use them for the | 32 // Catch user keypresses and decide whether to use them for the |
| 33 // Streams app or pass them on to the browser. | 33 // Streams app or pass them on to the browser. |
| 34 document.on.keyUp.add((e) { | 34 document.on.keyUp.add((e) { |
| 35 if (frontView != null) { | 35 if (frontView != null) { |
| 36 frontView.processKeyEvent(e); | 36 frontView.processKeyEvent(e); |
| 37 } | 37 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 refresh(); | 80 refresh(); |
| 81 eraseSplashScreen(); | 81 eraseSplashScreen(); |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 void render() { | 85 void render() { |
| 86 frontView = new FrontView(this); | 86 frontView = new FrontView(this); |
| 87 frontView.addToDocument(document.body); | 87 frontView.addToDocument(document.body); |
| 88 } | 88 } |
| 89 } | 89 } |
| OLD | NEW |