Functions

Functions

Functions



AddCookie

AddDays

AddMonths

ClearElement

Contains

Culture

DateDiffInDays

EndsWith

EvaluatePath

FilterArray

Format

FormatANSIDateTime

GetCookie

Guid

IfNull

IndexOf

IsEmpty

IsFunction

NN

NZ

PadEnd

PadStart

RandomColor

ReadFile

RemoveByIndex

RemoveCookie

RemoveFromArray

Replace

RequestValue

Round

SortItems

StartsWith

AddCookie

(name: string, value: string, days: number)
: void
Adds a cookie




AddDays

(dt: Date, days: number)
: Date
Add days to a date object




AddMonths

(dt: Date, months: number)
: Date



ClearElement

(element: HTMLElement)
: void
Clears all child nodes from any html element




Contains

(a: any, obj: any)
: boolean
Searches inside an array for a specific object




Culture

(culture: string)
: void
Sets the current culture for controls

Example
pf.Culture("en-GB");
pf.Culture("en-US");



DateDiffInDays

(date1: any, date2: any)
: number
Calculates the difference between 2 dates in days




EndsWith

(str: string, suffix: string)
: boolean



EvaluatePath

(context: any, path: string, sep: string)
: any



FilterArray

(array: T[], comparer: )
:
Returns a new array containing the items from the original array that pass from the comparer method parameter

Example
var data = [1, 2, 3, 4];
var result = pf.FilterArray(data, function(x) { return x < 3; });



Format

(obj: any, fmt: string, locale: string)
: any
Formats a number or a date

Example
var d = new
Date();
var result = pf.Format(d, "dd MMM yyyy");



FormatANSIDateTime

(dt: any)
: any
Returns a string in ANSI date format: yyyy-MM-dd HH:mm:ss




GetCookie

(name: string)
: string
Retrieves a cookie by its name




Guid

()
: string
Returns a random GUID-like string




IfNull

(value: T, fallback: T)
: T
Returns fallback value if value is null




IndexOf

(array: any, item: any)
: number
Returns the index of a specific item inside an array.
If the item is not found, -1 is returned




IsEmpty

(s: any)
: boolean
Checks if the passed value is empty or null




IsFunction

(v: any)
: boolean
Checks if the passed value is a function




NN

(str: any)
: number
Converts to a number. If the value is not a number, zero is returned




NZ

(str: any)
: string
Returns an empty string if parameter is null. Leaves non-string intact

Example
pf.NZ(null) === ""; //true
pf.NZ("test") === "test"; //true
pf.NZ(5) == "5"; //implicitly true. The number remains intact
pf.NZ(5) !== "5"; //not equal because no string conversion takes place



PadEnd

(s: string, maxLen: number, padChar: string)
: string



PadStart

(s: string, maxLen: number, padChar: string)
: string



RandomColor

()
: string



ReadFile

(file: File, base64: boolean, callback: )
: void



RemoveByIndex

(array: any, index: any)
: void
Removes an items from an array by index




RemoveCookie

(name: any)
: void
Removes a cookie




RemoveFromArray

(array: any, item: any)
: boolean
Removes an item from an array




Replace

(original: any, searchText: any, replaceWith: any)
: any
Replaces a string with another string




RequestValue

(key: any)
: string
Returns the value of a querystring key

Example
var id = pf.RequestValue("id");



Round

(num: number, decimals: number)
: number



SortItems

(items: any, sortFieldName: any, ascending: boolean, dataType: string)
: any
Returns a sorted array




StartsWith

(s: string, prefix: string)
: boolean