Source code

CERNY.util

Some general purpose utility functions.

Functions

createComparator

Create a compare function, that allows sorting according to an arbitrary order.

order (Array) : the arbitrary order, an array of numbers
compare (undefined,function) : the compare function, default is natural order
return (function) : the comparator
cutNumber

Return the last n digits from the decimal String representation of number.

number (number) : the number to get the digits from
n (number) : how many digits to get
return (string) : the last n digits
fillNumber

Return (at least) two digit number as a String. If number smaller than 10 return "0" + number.

number (number) : the number to fill
return (string) : the filled number
getNameFromFqName

Return the short name from a fully qualified name.

fqName (string) : the fully qualified name
return (string) : the short name
getUriParameterValue

Return the value of a paramter passed in the query part of an URL.

parameter (string) : the name of the parameter
url (string,undefined) : the url to look in, if undefined the url of the current document
indent

Create an indentation string, a line feed followed by n spaces, where n = indentation.

indentation (number) : the number of spaces to append to the line feed
return (string) : a string
parseUri

Parses an URI into its components.

Right now it cannot handle: "mailto:mduerst@ifi.unizh.ch" "news:comp.infosystems.www.servers.unix"

uri (string) : the uri to parse
return (object) : an object containing the parts of the uri

History

2007-06-15 : Added compare, createComparator.
2007-05-17 : Refactored.
2007-04-30 : Added getUriParameterValue
2007-03-20 : Corrected signature of CERNY.util.indent.
2007-03-15 : Added signatures.
2007-02-23 : Fixed bug in CERNY.parseUri (Result of "dev/".split(/\//) differs in IE and Firefox).
2007-02-23 : Added logger to CERNY.util.
2007-02-19 : Added getNameFromFqName.
2007-02-09 : Added parseUri.
2006-11-12 : Created.

API Documentation for version

2.0

Scripts

Scripts

util