Skip to content

Instantly share code, notes, and snippets.

@conspirator
Created October 8, 2010 04:29
Show Gist options
  • Save conspirator/616358 to your computer and use it in GitHub Desktop.
Save conspirator/616358 to your computer and use it in GitHub Desktop.
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>OOJS Test Page</title>
<script type="text/javascript">
var Person = function(){
this.firstName = "Barack";
this.lastName = "Obama";
this.job = "President";
}
Person.prototype.writePerson = function(x){
var y = document.getElementsByTagName('h1')[x];
y.innerHTML = this.getPerson();
}
Person.prototype.setFirstName = function(x){
this.firstName = x;
}
Person.prototype.setLastName = function(x){
this.lastName = x;
}
Person.prototype.setJob = function(x){
this.job = x;
}
Person.prototype.getPerson = function(){
return this.firstName + " " + this.lastName + " - " + this.job;
}
function init() {
var me = new Person();
me.setFirstName('Christopher');
me.setLastName('Webb');
me.setJob('Developer');
me.writePerson(1);
var president = new Person();
president.writePerson(0);
}
</script>
</head>
<body onload="init()">
<h1>One</h1>
<h1>Two</h1>
<h1>Three</h1>
<h1>Four</h1>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment