Created
November 27, 2012 19:46
-
-
Save jjinux/4156541 to your computer and use it in GitHub Desktop.
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
<html><body> | |
<element name="x-chat-window" constructor="ChatWindowComponent" extends="div"> | |
<template> | |
<div> | |
<textarea rows="10" class="chat-window" disabled> | |
<template iterate="s in chatWindowText"> | |
{{s}} | |
</template> | |
</textarea> | |
</div> | |
</template> | |
<script type="application/dart"> | |
import 'package:web_components/web_components.dart'; | |
class ChatWindowComponent extends WebComponent { | |
List<String> chatWindowText = new List<String>(); | |
displayMessage(String from, String msg) { | |
_display("$from: $msg\n"); | |
} | |
displayNotice(String notice) { | |
_display("[system]: $notice\n"); | |
} | |
_display(String str) { | |
chatWindowText.add(str); | |
// You have to call dispatch whenever Web Component data changes | |
// and it's not the result of a user event. That happens a lot | |
// for this method. | |
dispatch(); | |
} | |
} | |
</script> | |
</element> | |
</body></html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment