OLD | NEW |
(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 import 'dart:html'; |
| 6 |
| 7 ButtonElement genButton; |
| 8 |
| 9 void main() { |
| 10 query('#inputName').onInput.listen(updateBadge); |
| 11 genButton = query('#generateButton') |
| 12 ..onClick.listen(generateBadge); |
| 13 } |
| 14 |
| 15 void updateBadge(Event e) { |
| 16 String inputName = (e.target as InputElement).value; |
| 17 |
| 18 badgeName = inputName; |
| 19 if (inputName.trim().isEmpty) { |
| 20 genButton..disabled = false |
| 21 ..text = 'Generate badge'; |
| 22 } else { |
| 23 genButton..disabled = true |
| 24 ..text = 'Arrr! Remove the text!'; |
| 25 } |
| 26 } |
| 27 |
| 28 void generateBadge(Event e) { |
| 29 badgeName = 'Anne Bonney'; |
| 30 } |
| 31 |
| 32 set badgeName(String newName) { |
| 33 query('#badgeName').text = newName; |
| 34 } |
OLD | NEW |