This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| libtf:documentation:api:util [2018/02/25 12:21] – created lee | libtf:documentation:api:util [2018/09/24 17:31] (current) – removed lee | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | [[libtf: | ||
| - | |||
| - | |||
| - | ====== LibTF.Util====== | ||
| - | |||
| - | Miscellaneous internal utility functions that don't seem to fit anywhere else. | ||
| - | |||
| - | You probably won't every need to use any of these, except maybe // | ||
| - | |||
| - | ===== Methods ===== | ||
| - | |||
| - | |||
| - | ==== LibTF.Util.commaList( list ) ==== | ||
| - | |||
| - | * **Arguments: | ||
| - | * **// | ||
| - | * **Returns: | ||
| - | * **Throws:** Nothing. | ||
| - | |||
| - | Returns a comma-separated description of the list, including " | ||
| - | |||
| - | <code javascript> | ||
| - | alert( LibTF.commaList([ "a two-dollar pistol", | ||
| - | // prints "a two-dollar pistol, a Stetson hat, and a shotgun" | ||
| - | </ | ||
| - | |||
| - | <code javascript> | ||
| - | alert( LibTF.commaList([ "a two-dollar pistol", | ||
| - | // prints "a two-dollar pistol and a Stetson hat" | ||
| - | </ | ||
| - | |||
| - | <code javascript> | ||
| - | alert( LibTF.commaList([ "a two-dollar pistol" | ||
| - | // prints "a two-dollar pistol" | ||
| - | </ | ||
| - | |||
| - | <code javascript> | ||
| - | alert( LibTF.commaList([ ]) ); | ||
| - | // prints " | ||
| - | </ | ||
| - | |||
| - | ==== LibTF.Util.capitalize( s ) ==== | ||
| - | |||
| - | * **Arguments: | ||
| - | * **//s://** a string to capitalize | ||
| - | * **Returns: | ||
| - | * **Throws:** Nothing. | ||
| - | |||
| - | Returns a string matching //s//, but with the first character capitalized. | ||
| - | |||
| - | FIXME: This doesn' | ||
| - | |||
| - | <code javascript> | ||
| - | // given that some_widget.name == " | ||
| - | alert( LibTF.Util.capitalize(tfGet(" | ||
| - | // prints "A widget sure is a good thing to have!" | ||
| - | </ | ||
| - | |||
| - | ==== LibTF.Util.yourHisHer( person, thirdPerson ) ==== | ||
| - | |||
| - | * **Arguments: | ||
| - | * **// | ||
| - | * **// | ||
| - | * **Returns: | ||
| - | * **Throws:** Nothing. | ||
| - | |||
| - | If // | ||
| - | |||
| - | If // | ||
| - | |||
| - | <code javascript> | ||
| - | // if Joe is male... | ||
| - | alert( "There is a fire on " + Util.yourHisHer(tfGet(" | ||
| - | // prints "There is a fire on his head!" | ||
| - | </ | ||
| - | |||
| - | <code javascript> | ||
| - | // if Joe is female... | ||
| - | alert( "There is a fire on " + Util.yourHisHer(tfGet(" | ||
| - | // prints "There is a fire on her head!" | ||
| - | </ | ||
| - | |||
| - | <code javascript> | ||
| - | // regardless of Joe's sex, if Joe is the player character and we pass thirdPerson=false... | ||
| - | alert( "There is a fire on " + Util.yourHisHer(tfGet(" | ||
| - | // prints "There is a fire on your head!" | ||
| - | </ | ||
| - | |||
| - | ==== LibTF.Util.YourHisHer( person, thirdPerson ) ==== | ||
| - | |||
| - | This method is identical to // | ||
| - | |||
| - | <code javascript> | ||
| - | alert( Util.YourHisHer(tfGet(" | ||
| - | // prints "His head is on fire!" | ||
| - | </ | ||
| - | |||
| - | ==== LibTF.Util.youHeShe( person, thirdPerson, | ||
| - | |||
| - | * **Arguments: | ||
| - | * **// | ||
| - | * **// | ||
| - | * **// | ||
| - | * **// | ||
| - | * **Returns: | ||
| - | * **Throws:** Nothing. | ||
| - | |||
| - | Chooses " | ||
| - | |||
| - | If a // | ||
| - | |||
| - | If **no** // | ||
| - | |||
| - | <code javascript> | ||
| - | alert( LibTF.Util.youHeShe(tfGet(" | ||
| - | alert( LibTF.Util.youHeShe(tfGet(" | ||
| - | alert( LibTF.Util.youHeShe(tfGet(" | ||
| - | alert( LibTF.Util.youHeShe(tfGet(" | ||
| - | </ | ||
| - | |||
| - | ==== LibTF.Util.YouHeShe( person, thirdPerson, | ||
| - | |||
| - | This method is identical to // | ||
| - | |||
| - | <code javascript> | ||
| - | alert( LibTF.Util.YouHeShe(tfGet(" | ||
| - | alert( LibTF.Util.YouHeShe(tfGet(" | ||
| - | alert( LibTF.Util.YouHeShe(tfGet(" | ||
| - | alert( LibTF.Util.YouHeShe(tfGet(" | ||
| - | </ | ||
| - | |||
| - | |||
| - | [[libtf: | ||