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
git clone http://github.com/ry/node.git | |
cd node | |
./configure | |
make | |
sudo make install |
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 Room = function (elementId) { | |
// public properties | |
this.element = $("#" + elementId); | |
this.tooltip = this.element.find(".tooltip"); | |
// Any function calls in here will be executed when a room object is instantiated | |
this.initalizeTooltip(); | |
} | |
// Here we are defining a class method that can be called like this: Room.count(); |
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 Room = function (elementId) { |
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 Room(elementId) { |
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
// public properties | |
this.element = $("#" + elementId); | |
this.tooltip = this.element.find(".tooltip"); | |
// Any function calls in here will be executed when a room object is instantiated | |
this.initalizeTooltip(); |
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
Room.count = function() { | |
return $(".room").length; | |
} |
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
Room.prototype.roomText = function() { | |
return this.element.find("p").text(); | |
}; |
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
<div id="#rooms"> | |
<div id="room_1">Room 1</div> | |
<div id="room_2">Room 2</div> | |
</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
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> |
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 () { |