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
app.flash("You have signed in."); |
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
var app = { | |
flash: function(message) { | |
$("#flash").html(message); | |
} | |
} |
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
views.rooms.room("Seaside room"); | |
// "<div class='room' id='room_5'> <p>Seaside room</p> </div>" |
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
views.rooms.room = function(name) { | |
return "<div class='room' id='room_"+(Room.count() + 1)+"'>\ | |
<p>"+name+"</p>\ | |
</div>"; | |
}; |
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
if (views.rooms == undefined) { views.rooms = {}; } |
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
if (views.rooms == undefined) { views.rooms = {}; } | |
views.rooms.room = function(name) { | |
return "<div class='room' id='room_"+(Room.count() + 1)+"'>\ | |
<p>"+name+"</p>\ | |
</div>"; | |
}; |
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
<script type='text/javascript'> | |
var views = {}; | |
</script> |
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
window.rooms = []; | |
$(".room").each(function() { | |
rooms.push(new Room(this.id)); | |
}); |
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
(function () { | |
// For each room div that is on the page we want to create a new Room object. | |
// In this example we are then saving the objects into a global 'rooms' array. | |
window.rooms = []; | |
$(".room").each(function() { | |
rooms.push(new Room(this.id)); | |
}); | |
// Here we are defining an event listener to listen for when a room div is clicked. | |
$("#rooms").delegate(".room", "click", function () { |
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
var room1 = new Room("room_1"); | |
var room2 = new Room("room_2"); | |
room1.roomText(); // Room 1 | |
room1.next(); // <div id="room_2">Room 2</div> |