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 /** The top-level collection of all sections for a user. */ | 7 /** The top-level collection of all sections for a user. */ |
8 // TODO(jimhug): This is known as UserData in the server model. | 8 // TODO(jimhug): This is known as UserData in the server model. |
9 class Sections extends Collection<Section> { | 9 class Sections extends Collection<Section> { |
10 final List<Section> _sections; | 10 final List<Section> _sections; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 // add support for preloading. | 216 // add support for preloading. |
217 void _ensureLoaded() { | 217 void _ensureLoaded() { |
218 if (_htmlBody != null) return; | 218 if (_htmlBody != null) return; |
219 | 219 |
220 var name = '$dataUri.html'; | 220 var name = '$dataUri.html'; |
221 if (Sections.runningFromFile) { | 221 if (Sections.runningFromFile) { |
222 _htmlBody = CannedData.data[name]; | 222 _htmlBody = CannedData.data[name]; |
223 } else { | 223 } else { |
224 // TODO(jimhug): Remove this truly evil synchronoush xhr. | 224 // TODO(jimhug): Remove this truly evil synchronoush xhr. |
225 final req = new HttpRequest(); | 225 final req = new HttpRequest(); |
226 req.open('GET', 'data/$name', async: false); | 226 req.open('GET', 'data/$name', false); |
227 req.send(); | 227 req.send(); |
228 _htmlBody = req.responseText; | 228 _htmlBody = req.responseText; |
229 } | 229 } |
230 } | 230 } |
231 | 231 |
232 static Article decodeHeader(Feed source, Decoder decoder) { | 232 static Article decodeHeader(Feed source, Decoder decoder) { |
233 final id = decoder.readString(); | 233 final id = decoder.readString(); |
234 final title = decoder.readString(); | 234 final title = decoder.readString(); |
235 final srcUrl = decoder.readString(); | 235 final srcUrl = decoder.readString(); |
236 final hasThumbnail = decoder.readBool(); | 236 final hasThumbnail = decoder.readBool(); |
237 final author = decoder.readString(); | 237 final author = decoder.readString(); |
238 final dateInSeconds = decoder.readInt(); | 238 final dateInSeconds = decoder.readInt(); |
239 final snippet = decoder.readString(); | 239 final snippet = decoder.readString(); |
240 final date = | 240 final date = |
241 new DateTime.fromMillisecondsSinceEpoch(dateInSeconds*1000, isUtc: true)
; | 241 new DateTime.fromMillisecondsSinceEpoch(dateInSeconds*1000, isUtc: true)
; |
242 return new Article(source, id, date, title, author, srcUrl, hasThumbnail, | 242 return new Article(source, id, date, title, author, srcUrl, hasThumbnail, |
243 snippet); | 243 snippet); |
244 } | 244 } |
245 } | 245 } |
OLD | NEW |