Created
December 3, 2010 01:01
-
-
Save marcuswestin/726413 to your computer and use it in GitHub Desktop.
A chat application written in fun with multiple chat rooms
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
import Local | |
import Global | |
<div class="rooms"> | |
<input data=Local.newRoomName /> | |
<button>"Create new room"</button onclick=handler() { | |
let newRoom = new { name:Local.newRoomName, messages:[] } | |
Global.rooms.unshift(newRoom) | |
Local.newRoomName.set('') | |
}> | |
for (room in Global.rooms) { | |
<div class="room" style={ cursor:'pointer' }> | |
<div class="name">room.name</div onclick=handler() { | |
Local.currentRoom.set(room) | |
}> | |
</div> | |
} | |
</div> | |
if (Local.currentRoom) { | |
<div class="currentChatroom"> | |
<div class="messages"> | |
for (message in Local.currentRoom.messages) { | |
<div class="message"> | |
message | |
</div> | |
} | |
</div> | |
<input data=Local.messageText /><button>"Send"</button onclick=handler() { | |
Local.currentRoom.messages.push(Local.messageText) | |
Local.messageText.set('') | |
}> | |
</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