Please login or register. Welcome to the Studio, guest!


Quick Links:


newBookmarkLockedFalling

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
String.prototype.capatilize = function(_type){
// type 1 capatilizes first word. type 2 capatilizes all
var _type = (_type?_type:1);
switch(_type.toString()){
case "1":
return this.substring(0,1).toUpperCase()+this.substring(1);
break;
case "2":
var data = "";
var si = this.split(/\s/);
while(si[0]){
data += si[0].substring(0,1).toUpperCase()+si[0].substring(1)+" ";
si.splice(0,1);
}
return data;
}
}


There's actually two types in this. Type "1" capatilizes the first word of the string. Type "2" capatilizes every word in the string. I'm thinking about adding a type "3" which would capatilize the first word in a sentence.


hpmad

hpmad Avatar



858


September 2005
I've noticed a lot of your variables start with _ lately, what's with that :P

Aaron

Aaron Avatar
Bad Wolf

****
Dedicated Studio Member

859


November 2006
I'm starting to do that too actually. Reason being I find the gImage and all a little tacky and writing plain Image or whatever can be interpreted as something I didn't intend.

In truth it just looks cleaner as the variables blend right in with the script.


Last Edit: Jul 20, 2006 2:07:00 GMT by Aaron

Chris

Chris Avatar

******
Head Coder

19,519


June 2005
I mainly do it for variables inside of functions. IT makes them more.... unique. :P

newBookmarkLockedFalling