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

Unified Diff: src/site/docs/tutorials/fetchdata/examples/portmanteaux_simple/portmanteaux_simple.dart

Issue 26542002: edit pass on T3,4,5, updated images (Closed) Base URL: https://github.com/dart-lang/dartlang.org.git@master
Patch Set: merging with master Created 7 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 side-by-side diff with in-line comments
Download patch
Index: src/site/docs/tutorials/fetchdata/examples/portmanteaux_simple/portmanteaux_simple.dart
diff --git a/src/site/docs/tutorials/fetchdata/examples/portmanteaux_simple/portmanteaux_simple.dart b/src/site/docs/tutorials/fetchdata/examples/portmanteaux_simple/portmanteaux_simple.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2cadceffb209f09ae382e37771b4f650060c2a3a
--- /dev/null
+++ b/src/site/docs/tutorials/fetchdata/examples/portmanteaux_simple/portmanteaux_simple.dart
@@ -0,0 +1,28 @@
+import 'dart:html';
+import 'dart:json' as json;
+import 'dart:async';
+
+var wordList;
+
+void main() {
+ query('#getWords').onClick.listen(makeRequest);
+ wordList = query('#wordList');
+}
+
+void makeRequest(Event e) {
+ var path = 'portmanteaux_simple.json';
+ HttpRequest.getString(path)
+ .then(processString)
+ .catchError(handleError);
+}
+
+processString(String jsonString) {
+ List<String> portmanteaux = json.parse(jsonString);
+ for (int i = 0; i < portmanteaux.length; i++) {
+ wordList.children.add(new LIElement()..text = portmanteaux[i]);
+ }
+}
+
+handleError(Error error) {
+ wordList.children.add(new LIElement()..text = 'Request failed.');
+}

Powered by Google App Engine
This is Rietveld 408576698