Created
August 24, 2010 03:42
-
-
Save scottharvey/546904 to your computer and use it in GitHub Desktop.
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).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