Skip to content

Instantly share code, notes, and snippets.

@marcuswestin
Created November 24, 2010 17:18
Show Gist options
  • Save marcuswestin/714019 to your computer and use it in GitHub Desktop.
Save marcuswestin/714019 to your computer and use it in GitHub Desktop.
<div class="rooms">
<input data=Local.newRoomName />
<button>"Create new room"</button onclick=handler() {
Global.rooms.unshift(new { name:Local.newRoomName, messages:[] })
Local.newRoomName.set('')
}>
for (room in Global.rooms) {
<div class="room">
<div class="name">room.name</div onclick=handler() { Local.currentRoom = room }>
</div>
}
</div>
if (Local.currentChatroom) {
"Username "<input data=Local.username />
<div class="currentChatroom">
<div class="messages">
for (message in Local.currentRoom.messages) {
<div class="message">
message.sender ': "' message.text '"'
</div>
}
</div>
<input data=Local.messageText /><button>"Send"</button onclick=handler() {
let newMessage = new { sender: Local.username, text: Local.messageText }
Local.messageText.set('')
Local.currentChatroom.messages.push(newMessage)
}>
</div>
} else {
"Click on a room to join it"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment