This repository has been archived by the owner on Feb 22, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from a14n/issue-120
fix #120 replace jsonp example
- Loading branch information
Showing
5 changed files
with
74 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
library jsonp_sample; | ||
|
||
import 'dart:html'; | ||
|
||
import 'package:js/js.dart'; | ||
|
||
const List<String> FIELDS = const ['name', 'description', 'size', | ||
'watchers', 'forks']; | ||
|
||
TableElement table = querySelector('#repo-table'); | ||
|
||
addTableHeadRow() { | ||
var tr = new TableRowElement(); | ||
for (var field in FIELDS) { | ||
tr.append(new Element.tag('th')..text = field); | ||
} | ||
table.querySelector('thead').append(tr); | ||
} | ||
|
||
addTableBodyRow(Proxy repo) { | ||
var tr = new TableRowElement(); | ||
for (var field in FIELDS) { | ||
var td = new TableCellElement(); | ||
if (field == 'name') { | ||
td.append(new AnchorElement() | ||
..href = repo.html_url | ||
..text = repo[field]); | ||
} else { | ||
td.text = repo[field].toString(); | ||
} | ||
tr.append(td); | ||
} | ||
table.querySelector('tbody').append(tr); | ||
} | ||
|
||
void main() { | ||
// Create a jsObject to handle the response. | ||
context.processData = (response) { | ||
addTableHeadRow(); | ||
for (var i = 0; i < response.data.length; i++) { | ||
addTableBodyRow(response.data[i]); | ||
} | ||
}; | ||
|
||
ScriptElement script = new Element.tag("script"); | ||
script.src = "https://api.github.com/users/dart-lang/repos?callback=processData"; | ||
document.body.children.add(script); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8"> | ||
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" | ||
rel="stylesheet"> | ||
<title>Using JSONP with Dart</title> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>Dart Repos on Github</h1> | ||
|
||
<table id="repo-table" class="table table-bordered table-striped"> | ||
<thead></thead> | ||
<tbody></tbody> | ||
</table> | ||
</div> | ||
<script type="application/dart" src="jsonp.dart"></script> | ||
<script src="packages/browser/dart.js"></script> | ||
<script src="packages/browser/interop.js"></script> | ||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters