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

Side by Side Diff: third_party/pkg/js/example/jsonp/jsonp.dart

Issue 176943008: Update the Angular/DI tests to latest from github. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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) 2012, the Dart project authors. Please see the AUTHORS file
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.
4
5 library jsonp_sample; 1 library jsonp_sample;
6 2
7 import 'dart:html'; 3 import 'dart:html';
8 import 'dart:js'; 4
5 import 'package:js/js.dart';
9 6
10 const List<String> FIELDS = const ['name', 'description', 'size', 7 const List<String> FIELDS = const ['name', 'description', 'size',
11 'watchers', 'forks']; 8 'watchers', 'forks'];
12 9
13 TableElement table = querySelector('#repo-table'); 10 TableElement table = querySelector('#repo-table');
14 11
15 addTableHeadRow() { 12 addTableHeadRow() {
16 var tr = new TableRowElement(); 13 var tr = new TableRowElement();
17 for (var field in FIELDS) { 14 for (var field in FIELDS) {
18 tr.append(new Element.tag('th')..text = field); 15 tr.append(new Element.tag('th')..text = field);
19 } 16 }
20 table.querySelector('thead').append(tr); 17 table.querySelector('thead').append(tr);
21 } 18 }
22 19
23 addTableBodyRow(JsObject repo) { 20 addTableBodyRow(Proxy repo) {
24 var tr = new TableRowElement(); 21 var tr = new TableRowElement();
25 for (var field in FIELDS) { 22 for (var field in FIELDS) {
26 var td = new TableCellElement(); 23 var td = new TableCellElement();
27 if (field == 'name') { 24 if (field == 'name') {
28 td.append(new AnchorElement() 25 td.append(new AnchorElement()
29 ..href = repo['html_url'] 26 ..href = repo.html_url
30 ..text = repo[field]); 27 ..text = repo[field]);
31 } else { 28 } else {
32 td.text = repo[field].toString(); 29 td.text = repo[field].toString();
33 } 30 }
34 tr.append(td); 31 tr.append(td);
35 } 32 }
36 table.querySelector('tbody').append(tr); 33 table.querySelector('tbody').append(tr);
37 } 34 }
38 35
39 void main() { 36 void main() {
40 // Create a jsObject to handle the response. 37 // Create a jsObject to handle the response.
41 context['processData'] = (response) { 38 context.processData = (response) {
42 addTableHeadRow(); 39 addTableHeadRow();
43 for (var repo in response['data']) { 40 for (var i = 0; i < response.data.length; i++) {
44 addTableBodyRow(repo); 41 addTableBodyRow(response.data[i]);
45 } 42 }
46 }; 43 };
47 44
48 ScriptElement script = new Element.tag("script"); 45 ScriptElement script = new Element.tag("script");
49 script.src = "https://api.github.com/users/dart-lang/repos?callback=processDat a"; 46 script.src = "https://api.github.com/users/dart-lang/repos?callback=processDat a";
50 document.body.children.add(script); 47 document.body.children.add(script);
51 } 48 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698