Skip to content

Instantly share code, notes, and snippets.

@scottharvey
Created August 24, 2010 03:42
Show Gist options
  • Save scottharvey/546904 to your computer and use it in GitHub Desktop.
Save scottharvey/546904 to your computer and use it in GitHub Desktop.
(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).toggleClass("dark");
return false;
});
$("#new_room").click(function () {
var name = prompt("What is the name of the new room?");
$("#rooms").append(views.rooms.room(name));
return false;
});
$("#show_flash").click(function () {
var message = prompt("What message do you want to show?");
app.flash("<p>"+message+"</p>");
return false;
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment