Created
August 7, 2015 02:03
-
-
Save kasperpeulen/4e9aad5001cbec2faed1 to your computer and use it in GitHub Desktop.
portmanteaux
This file contains hidden or 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
| <!-- Copyright (c) 2012, the Dart project authors. | |
| Please see the AUTHORS file for details. | |
| All rights reserved. Use of this source code | |
| is governed by a BSD-style license that can be | |
| found in the LICENSE file. | |
| --> | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Portmanteaux</title> | |
| <link rel="stylesheet" href="styles.css"> | |
| </head> | |
| <body> | |
| <h1>Portmanteaux</h1> | |
| <button id="getWords">Get portmanteaux</button> | |
| <ul id="wordList"> | |
| </ul> | |
| <script type="application/dart" src="main.dart"></script> | |
| <script src="packages/browser/dart.js"></script> | |
| </body> | |
| </html> |
This file contains hidden or 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
| // Copyright (c) 2012, the Dart project authors. | |
| // Please see the AUTHORS file for details. | |
| // All rights reserved. Use of this source code | |
| // is governed by a BSD-style license that can be | |
| // found in the LICENSE file. | |
| import 'dart:html'; | |
| import 'dart:convert'; | |
| var wordList; | |
| void main() { | |
| querySelector('#getWords').onClick.listen(makeRequest); | |
| wordList = querySelector('#wordList'); | |
| } | |
| void makeRequest(Event e) { | |
| var path = 'https://www.dartlang.org/samples-files/portmanteaux.json'; | |
| var httpRequest = new HttpRequest(); | |
| httpRequest | |
| ..open('GET', path) | |
| ..onLoadEnd.listen((e) => requestComplete(httpRequest)) | |
| ..send(''); | |
| } | |
| requestComplete(HttpRequest request) { | |
| if (request.status == 200) { | |
| List<String> portmanteaux = JSON.decode(request.responseText); | |
| for (int i = 0; i < portmanteaux.length; i++) { | |
| wordList.children.add(new LIElement()..text = portmanteaux[i]); | |
| } | |
| } else { | |
| wordList.children.add(new LIElement() | |
| ..text = 'Request failed, status=${request.status}'); | |
| } | |
| } |
This file contains hidden or 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
| body { | |
| background-color: #F8F8F8; | |
| font-family: 'Open Sans', sans-serif; | |
| font-size: 14px; | |
| font-weight: normal; | |
| line-height: 1.2em; | |
| margin: 15px; | |
| } | |
| h1, p, li { | |
| color: #333; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment