Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 12th, 2010  |  syntax: HTML  |  size: 1.05 KB  |  views: 147  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <html>
  2.     <head>
  3.         <title>Ohi</title>
  4.         <script>
  5.         test = { "People": { }, 'addPerson': function ( sName ) { this.People[ sName ] = new Person( sName ); } }
  6.  
  7.  
  8.   test.addPerson( 'Fred' );
  9.  
  10.  
  11. function Person( sName )
  12. {
  13.       this.sName = sName;
  14.  
  15.       this.Hats = [];
  16.       var oPar = this;
  17.       this.Hats[ "Red" ] = new Hat( oPar, "red" );
  18.       this.Hats[ "Yellow" ] = new Hat( oPar, "yellow" );
  19.  
  20.  
  21. }
  22.        
  23.        
  24. function Hat( oParent, sColor )
  25. {
  26.      this.parent = oParent;
  27.  
  28.       this.sColor = sColor;
  29.  
  30.      this.changeColor = function( sNewColor )
  31.        {
  32.          this.sColor = sNewColor;
  33.          return true;
  34.          
  35.        }
  36.        
  37.      this.OwnerName = function ( )
  38.        {
  39.          return this.parent.sName;
  40.        
  41.        }
  42.        
  43.        
  44.        }
  45.      
  46.        
  47.   console.log( test.People[ "Fred" ] );
  48.   console.log( test.People[ "Fred" ].Hats );
  49.   console.log( test.People[ "Fred" ].Hats.length );
  50.         </script>
  51.     </head>
  52.     <body>
  53.         Ohi
  54.         </body>
  55. </html>