Melior - Documentation (back)

Utility Methods

$

Alias to document.getElementById('DOMID'). $('elementID');

Returns object

"String" Methods

contains(string pattern)

Checks if a pattern exists in a string. "User passed test!".contains('passed');

"User passed test!"

Returns boolean

ltrim

Strip whitespace (or other characters) from the beginning of a string. " Spaces before! ".trim();

" Spaces before! "

Returns string

isEmail

Checks if string is a valid email address. "test@test.com".isEmail();

"test@test.com"

Returns boolean

isHostname

Check if string is a valid host name. Hostnames must use a-z,0-9, and '-'. A hostname cannot have any spaces nor can it start with a '-'. "www.google.com".isHostname();

"www.google.com"

Returns boolean

isNumber

Checks if string is a valid number. "-12345".isNumber();

"-12345"

Returns boolean

reverse

Reverse the order of the characters in a string. "abcdef".reverse();

"abcdef"

Returns string

rtrim

Strip whitespace (or other characters) from the end of a string. " Spaces after! ".trim();

" Spaces after! "

Returns string

strpos(string neddle [, integer offset])

Find position of first occurrence of a string. "abcdef".strpos('c');

"abcdef"

Returns string

substr(integer start [, integer length])

Return part of a string. See samples. "abcdef".substr(-2);

"abcdef"

Returns string

substrReplace(string replace, integer start [, integer length])

Replace text within a portion of a string. "abcdef".substrReplace('CD', 2, 2);

"abcdef"

Returns string

toNumber

Retrieve a number from a string. "Update user #5555".toNumber();

"Update user #5555"

Returns string

trim

Strip whitespace (or other characters) from the beginning and end of a string. " Spaces before and after! ".trim();

" Spaces before and after! "

Returns string

truncate(integer length, [, string tail "..." [, boolean strict false]])

Truncates a string and adds trailing periods to it. "Description here, this is a very description.".truncate(10);

"Description here, this is a very description."

Returns string

[Array] Methods

contains

Checks if a pattern, object, array exists in an array. ['a','b','c','d','e','f'].contains('d');

['a','b','c','d','e','f']

Returns boolean

each

Iterate through an array and execute function for each element in the array. ['a','b','c','d','e','f'].each( function(o, i){alert(o);} );

['a','b','c','d','e','f']

Returns void

first

Returns the value of the first element or FALSE for empty array. ['a','b','c','d','e','f'].last();

['a','b','c','d','e','f']

Returns mixed

last

Returns the value of the last element or FALSE for empty array. ['a','b','c','d','e','f'].last();

['a','b','c','d','e','f']

Returns mixed

© 2009 Nesbert Hidalgo. All rights reserved.