Skip to content

Instantly share code, notes, and snippets.

View scottharvey's full-sized avatar

Scott Harvey scottharvey

View GitHub Profile
app.flash("You have signed in.");
var app = {
flash: function(message) {
$("#flash").html(message);
}
}
views.rooms.room("Seaside room");
// "<div class='room' id='room_5'> <p>Seaside room</p> </div>"
views.rooms.room = function(name) {
return "<div class='room' id='room_"+(Room.count() + 1)+"'>\
<p>"+name+"</p>\
</div>";
};
if (views.rooms == undefined) { views.rooms = {}; }
if (views.rooms == undefined) { views.rooms = {}; }
views.rooms.room = function(name) {
return "<div class='room' id='room_"+(Room.count() + 1)+"'>\
<p>"+name+"</p>\
</div>";
};
<script type='text/javascript'>
var views = {};
</script>
window.rooms = [];
$(".room").each(function() {
rooms.push(new Room(this.id));
});
(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 () {
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>