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

Side by Side Diff: src/site/samples/jsonp/example/index.dart

Issue 1387723002: Updating the samples page to reflect the examples that have been retired. (Closed) Base URL: https://github.com/dart-lang/www.dartlang.org.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « src/site/samples/index.markdown ('k') | src/site/samples/jsonp/example/index.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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;
6
7 import 'dart:html';
8 import 'dart:js';
9
10 const List<String> FIELDS = const ['name', 'description', 'size',
11 'watchers', 'forks'];
12
13 TableElement table = querySelector('#repo-table');
14
15 addTableHeadRow() {
16 var tr = new TableRowElement();
17 for (var field in FIELDS) {
18 tr.append(new Element.tag('th')..text = field);
19 }
20 table.querySelector('thead').append(tr);
21 }
22
23 addTableBodyRow(JsObject repo) {
24 var tr = new TableRowElement();
25 for (var field in FIELDS) {
26 var td = new TableCellElement();
27 if (field == 'name') {
28 td.append(new AnchorElement()
29 ..href = repo['html_url']
30 ..text = repo[field]);
31 } else {
32 td.text = repo[field].toString();
33 }
34 tr.append(td);
35 }
36 table.querySelector('tbody').append(tr);
37 }
38
39 void main() {
40 // Create a jsObject to handle the response.
41 context['processData'] = (response) {
42 addTableHeadRow();
43 for (var repo in response['data']) {
44 addTableBodyRow(repo);
45 }
46 };
47
48 ScriptElement script = new Element.tag("script");
49 script.src = "https://api.github.com/users/dart-lang/repos?callback=processDat a";
50 document.body.children.add(script);
51 }
OLDNEW
« no previous file with comments | « src/site/samples/index.markdown ('k') | src/site/samples/jsonp/example/index.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698