Category: programming
05/27/06 12:11 - 64ºF - ID#32629
Javascript Prototypes
SIDENOTE ON SUREBERT
If you want to use surebert for any AJAX stuff at artvoice, feel free. It allows you to easily post data to any page. Here is the non-compressed js version so you can see what is going on.
Prototypes
(e:zobar,59) if you already know this then maybe this is a waste because no one else is going to read it besides maybe (e:enknot) who already knows this because we talk shop all day at work, but in case you haven't thought about it, you can write very extensible objects in javascript using protypes.
In fact, I would argue that the prototype if the basis of complicated OOP in javascript. The prototype is applied to every instance of the object without having to copy the function as it is when declared as a function within the constructor.
Here is how I would write it
Greeter = function(yourName){
this.yourName = yourName;
}
Greeter.prototype.getTimeOfDay = function(timeOfDay){
alert('Good ' + timeOfDay + ', ' + this.yourName);
}
greetZ = new Greeter('Zobar');
greetP = new Greeter('Paul');
greetZ.getTimeOfDay('afternoon');//'Good afternoon, Zobar'
greetZ.getTimeOfDay('evening');// 'Good evening, Zobar'
greetZ.getTimeOfDay('evening');// 'Good evening, Paul'
[/box]
Because everything is an object in javascript, if you have mutliple prototypes for an object you can easily write them like below which look very neat and organized when used with large objects.
[box]
Greeter = function(yourName){
this.yourName = yourName;
}
//javascript object notation for attaching multiple protoypes to an object.Although you could write each one as Greeter.prototype.name of function, I think when have lots of protypes this looks neater. You can also add any of properties as a prototype. In this case I am also creating a property called job. that can be referred to as instanceName.job e.g. greetZ.job you can even attach protoype arrays this way
Greeter.prototype = {
'job' : 'programmer',
getTimeOfDay : function(timeOfDay){
alert('Good ' + timeOfDay + ', ' + this.yourName);
},
getRandNumber : function(min,max){
min = min || 0;
max = max || 100;
alert(Math.floor(Math.random()*max+min));
},
sayHello : function(){
alert("Hello, "+this.yourName);
}
}
greetZ = new Greeter('Zobar');
greetP = new Greeter('Paul');
greetZ.getTimeOfDay('afternoon');//'Good afternoon, Zobar'
greetZ.sayHello();// 'Hello, Zobar'
greetZ.getRandNumber(10,30);// 'Good evening, Paul'
Permalink: Javascript_Prototypes.html
Words: 389
Location: Buffalo, NY
Category: pets
05/26/06 01:16 - 69ºF - ID#32628
My house at 3:30am
Permalink: My_house_at_3_30am.html
Words: 74
Location: Buffalo, NY
Category: dance
05/26/06 11:27 - 64ºF - ID#32627
Terrible Feeling
Permalink: Terrible_Feeling.html
Words: 78
Location: Buffalo, NY
Category: food
05/25/06 11:35 - 69ºF - ID#32626
Lunches
Besides the walking and beautiful weather it was a waste. The food was really bad, as was the service. The counter girl was kind of nice, but the kitchen dude was kind of a jerk. The atomsphere was ueber tacky and the paneling wasn't even sheik in the 70s.
I didn't even take a picture of the food. My french fries tasted like fish and not in a good way.
It was so pale in comparison to the roswelll lunches. I feel bad that it was so plain the day (e:jenks) visited. The next day, this was the entree.
This morning at work we had a fire alarm that freaked me the hell out. I didn't even breathe because I was so scared of what could be burning in the cell and virology building. The alarm was so loud and scary.
Permalink: Lunches.html
Words: 205
Location: Buffalo, NY
Category: downtown
05/25/06 07:58 - 73ºF - ID#32625
Thursday at the square
I have 4 bumper sticker with me in case I met anyone.
Beer makes my face numb.
Missing Image ;(
Why do these satan worshipping freaks come to protest.
Permalink: Thursday_at_the_square.html
Words: 94
Location: Buffalo, NY
Category: nonna
05/25/06 12:08 - 59ºF - ID#32624
I miss you Nonna
I still often think that she is there when I go to the house. I always expect her to answer the door.
Permalink: I_miss_you_Nonna.html
Words: 48
Location: Buffalo, NY
Category: programming
05/24/06 02:53 - 65ºF - ID#32623
New programming style
Bye bye
mover.prototype
mover.prototype
mover.prototype
mover.prototype
mover.prototype
mover.prototype
mover.prototype
mover.prototype
mover.prototype
mover.prototype
mover.prototype
mover.prototype
mover.prototype
mover.prototype
mover.prototype
Permalink: New_programming_style.html
Words: 58
Location: Buffalo, NY
Category: hair
05/23/06 11:18 - 50ºF - ID#32622
A new Haircut
I was sick of getting zits from my hair dripping sweat in my face during gym workouts. I refuse to use shampoo, as I never really have. I also never used deoderant but I suppose anyone who has met me knows that ;)
Anyways so instead of starting to use shampoo, I decided to just cut all my hair of again. Bye, bye hair and bye bye zits.
The old hair cuts
(e:paul,4120) - the big haircut
(e:paul,3745) - the facial shave
(e:paul,2428) - the scandalous mirror pic
(e:paul,2780) - beard cut
(e:paul,3517) - full body shave - the sidekick bugs
(e:paul,1495) - shaved face - wow I look young - I guess it was 2 years ago
(e:paul,893) - the most shaved head ever
At least I didn't let my hair get as out of control as then (e:paul,4226)
Permalink: A_new_Haircut.html
Words: 163
Location: Buffalo, NY
Category: mobile
05/23/06 09:05 - 55ºF - ID#32621
Nice Day
(e:jenks) and (e:enknot) having my favorite kind of dorky discussion about computers and social networking.
Afterwards, I had a pleasant afternoon working on a programming project I not so fond of but am making the best of.
I worked a lot on this magicTable object for the project. That part was fun. I seem to never tire of javascript.
I finally asked my supervisor about getting a patent on one of my latest creations. I hope it works out.
On the way home there was this computer sitting on the lawn looking really sad. I hope they never put me outside like that when my technology is outdated.
Permalink: Nice_Day.html
Words: 135
Location: Buffalo, NY
Category: photos
05/22/06 11:33 - 46ºF - ID#32620
Mobile Snaps in Time
Here I am being a freak about to go mobile.
(e:twisted) says I don't look nearly as evil as here (e:paul,3822)
Someone left this apple and candy on a table in the hallways at Roswell. Did they really think someone was going to pick up some candy or an apple in a hospital and eat it? It seems so intentional. I mean it is screaming danger to me. Was I brought up to be too careful?
The city removed those orange barrels from the street near the BAC next to the courthouse and jail but forgot to remove the tire rims that held them in place. They have been there for a while now. It;s kind of trashy.
(e:paul,4339) - here are those ants from the other day
Permalink: Mobile_Snaps_in_Time.html
Words: 151
Location: Buffalo, NY
Author Info
Date Cloud
- 03/24
- 11/23
- 02/23
- 01/23
- 12/22
- 01/22
- 12/21
- 11/21
- 12/20
- 11/20
- 01/19
- 12/18
- 08/18
- 04/18
- 03/18
- 02/17
- 01/17
- 12/16
- 11/16
- 09/16
- 08/16
- 07/16
- 06/16
- 05/16
- 04/16
- 03/16
- 02/16
- 01/16
- 12/15
- 11/15
- 10/15
- 09/15
- 08/15
- 07/15
- 06/15
- 05/15
- 04/15
- 03/15
- 02/15
- 01/15
- 12/14
- 11/14
- 10/14
- 09/14
- 08/14
- 07/14
- 06/14
- 05/14
- 04/14
- 03/14
- 02/14
- 01/14
- 12/13
- 11/13
- 10/13
- 09/13
- 08/13
- 07/13
- 06/13
- 05/13
- 04/13
- 03/13
- 02/13
- 01/13
- 12/12
- 11/12
- 10/12
- 09/12
- 08/12
- 07/12
- 06/12
- 05/12
- 04/12
- 03/12
- 02/12
- 01/12
- 12/11
- 11/11
- 10/11
- 09/11
- 08/11
- 07/11
- 06/11
- 05/11
- 04/11
- 03/11
- 02/11
- 01/11
- 12/10
- 11/10
- 10/10
- 09/10
- 08/10
- 07/10
- 06/10
- 05/10
- 04/10
- 03/10
- 02/10
- 01/10
- 12/09
- 11/09
- 10/09
- 09/09
- 08/09
- 07/09
- 06/09
- 05/09
- 04/09
- 03/09
- 02/09
- 01/09
- 12/08
- 11/08
- 10/08
- 09/08
- 08/08
- 07/08
- 06/08
- 05/08
- 04/08
- 03/08
- 02/08
- 01/08
- 12/07
- 11/07
- 10/07
- 09/07
- 08/07
- 07/07
- 06/07
- 05/07
- 04/07
- 03/07
- 02/07
- 01/07
- 12/06
- 11/06
- 10/06
- 09/06
- 08/06
- 07/06
- 06/06
- 05/06
- 04/06
- 03/06
- 02/06
- 01/06
- 12/05
- 11/05
- 10/05
- 09/05
- 08/05
- 07/05
- 06/05
- 05/05
- 04/05
- 03/05
- 02/05
- 01/05
- 12/04
- 11/04
- 10/04
- 09/04
- 08/04
- 07/04
- 06/04
- 05/04
- 04/04
- 03/04
- 02/04
- 01/04
- 12/03
- 11/03
- 10/03
- 09/03
- 08/03
- 07/03
Category Cloud
- 24 linwood
- animals
- art
- basra
- bathroom
- biking
- birthdays
- body
- botanical gardens
- brushwood
- buffalo
- camping
- cars
- clothes
- clothing
- computers
- dancing
- food
- furniture
- games
- haircut
- haircuts
- halloween
- hiking
- holidays
- house
- key west
- mobile
- music
- nature
- pets
- provincetown
- rochester
- swimming
- toronto
- toys
- travel
- vacation
- weather
- wedding
- weddings
- work
- accidents
- allentown
- android
- animals
- apple
- architecture
- art
- artvoice
- bars
- bathroom
- beach
- bikes
- biking
- birthdays
- body
- books
- brushwood
- buffalo
- buffalo rising
- bugs
- buildings
- camping
- cancer
- cars
- cats
- central terminal
- childhood
- church of the ascension
- clothes
- clothing
- computer
- computers
- conference
- crohns
- dance
- dancing
- dentist
- design
- downtown
- drugs
- electronics
- elmwood
- energy
- environment
- estrip
- events
- exercise
- family
- festivals
- firecracker
- food
- friends
- furniture
- gadgets
- games
- garden
- gay
- government
- gym
- hair
- haircut
- haircuts
- halloween
- hardware
- health
- hiking
- history
- holiday
- holidays
- house
- housing
- jewlery
- kenmore
- key west
- life
- linux
- linwood
- love
- marriage
- media
- mobile
- mobl
- movies
- music
- mustache
- nature
- nikon
- opinion
- orange tongue
- party
- peeptalk
- people
- pets
- photos
- poetry
- politics
- portland
- pride
- programming
- property
- protest
- random
- recycling
- religion
- rememberbuffalo
- renting
- school
- shoes
- shopping
- sports
- stress
- stuff
- swimming
- technology
- television
- thesis
- thursday
- thursdays
- toys
- transportation
- travel
- vacation
- vegas
- war
- water
- weather
- web
- wedding
- weddings
- weekend
- windows
- winter
- work
- world
- youtube
- zooey
[The reason I'm all into this now is that I'm doing the database backend for our calendar in XUL :::link::: , and since XUL does not provide any kind of transactional form processing like X/HTML does, the only way to interact with the server is through XMLHttpRequest and its ilk.]
- Z