Module: util

Members

(static) getDatabaseDirectoryName

Get the private documents directory
Source:

Methods

(static) buildQuery(obj, prepend) → {String}

Generate URL-encoded query string.
Parameters:
Name Type Description
obj Object Object key-value to parse.
prepend String The prepended char
Source:
Returns:
Type
String

(static) bytesForHumans(bytes) → {String}

Get a human representation of bytes
Parameters:
Name Type Description
bytes Number
Source:
Returns:
Type
String

(static) compareVersions(a, b) → {Number}

Compare two app versions
Parameters:
Name Type Description
a String
b String
Source:
Returns:
Type
Number

(static) decodeHtmlEntity(str) → {String}

Decode html entities into text
Parameters:
Name Type Description
str String The string to decode
Source:
Returns:
The decoded string
Type
String

(static) dial(tel)

Dial a number.
Parameters:
Name Type Description
tel String The number to call.
Source:

(static) encodeHtmlEntity(str) → {String}

Encode a string into html entities
Parameters:
Name Type Description
str String The string to encode
Source:
Returns:
The encoded string
Type
String

(static) errorAlert(err, callbackopt)

Parameters:
Name Type Attributes Description
err Object The object error
callback function <optional>
The callback
Source:

(static) fromNow(topt) → {Number}

Get the UNIX timestamp from now with delay expressed in seconds.
Parameters:
Name Type Attributes Description
t Number <optional>
Seconds from now.
Source:
Returns:
Type
Number

(static) getAppDataDirectory() → {String}

Return the app-data directory.
Source:
Returns:
Type
String

(static) getDeployType() → {String}

Returns the build type. It differs from Ti.Platform.deployType, as it returns "development" both for "test" and "development" builds.
Source:
Returns:
Type
String

(static) getDomainFromURL(url) → {String}

Return the clean domain of an URL
Parameters:
Name Type Description
url String The URL to parse
Source:
Returns:
Clean domain
Type
String

(static) getErrorMessage()

An error parser that parse a String/Object
Source:

(static) getFacebookAvatar(fbid, wopt, hopt) → {String}

Get the Facebook avatar from the graph
Parameters:
Name Type Attributes Description
fbid String Facebook ID
w Number <optional>
Width
h Number <optional>
Height
Source:
Returns:
The open graph url pointing to the image
Type
String

(static) getIOSVersion() → {Number}

Return the iOS major version
Source:
Returns:
Type
Number

(static) getOS() → {String}

Returns the OS name. It differs from Ti.Platform.osname, as it returns "ios" both for iPhone and iPad.
Source:
Returns:
Type
String

(static) getPlatformFullName() → {String}

Get the full platform name
Source:
Returns:
Type
String

(static) getResourcesDirectory() → {String}

Get the resources directory path
Source:
Returns:
Type
String

(static) guid() → {String}

Get a UUID
Source:
Returns:
Type
String

(static) hashJavascriptObject(obj) → {String}

Return the seralized representation of any JS object.
Parameters:
Name Type Description
obj Object
Source:
Returns:
The hash
Type
String

(static) isIOS6() → {Boolean}

Check if is iOS 6
Source:
Returns:
Type
Boolean

(static) isIOS7() → {Boolean}

Check if is iOS 7
Source:
Returns:
Type
Boolean

(static) isIOS8() → {Boolean}

Check if is iOS 8
Source:
Returns:
Type
Boolean

(static) isIOS9() → {Boolean}

Check if is iOS 9
Source:
Returns:
Type
Boolean

(static) now() → {Number}

Get the current UNIX timestamp.
Source:
Returns:
Type
Number

(static) openFacebookProfile(fb_id)

Open a Facebook profile in the Facebook application
Parameters:
Name Type Description
fb_id String Facebook ID
Source:
Parameters:
Name Type Description
url String
Source:

(static) openInstagramProfile(ig_username)

Open an Instagram profile in the Instagram application
Parameters:
Name Type Description
ig_username String The user's id
Source:

(static) openInStore()

Open the iTunes Store or Google Play Store of specified appid
Properties:
Name Type Description
appid The appid
Source:

(static) openTwitterProfile(tw_username)

Open a Twitter profile in the Twitter application
Parameters:
Name Type Description
tw_username String Twitter screen name
Source:

(static) openTwitterStatus(tw_username, status_id)

Open a Twitter status in the Twitter application
Parameters:
Name Type Description
tw_username String The user id
status_id String The status id
Source:

(static) openURL(url, fallbackopt, erroropt)

Try to open the URL with `Ti.Platform.openURL`, catching errors. If can't open the primary argument (url), open the fallback. If can't open the fallback, and `error` is set, show the error dialog.
Parameters:
Name Type Attributes Description
url String The URL to open
fallback String | function <optional>
If is a string, try to open the URL. If is a functions, call it.
error String <optional>
The error to show
Source:

(static) openYoutubeProfile(ytid)

Open a Youtube profile in the Yotube application
Parameters:
Name Type Description
ytid String Youtube ID
Source:

(static) parseAsXCallbackURL(url) → {XCallbackURL}

Parameters:
Name Type Description
url String The URL to parse
Source:
Returns:
Type
XCallbackURL

(static) parseJSON(json) → {Object}

Try to parse a JSON, and silently fail on error, returning a `null` in this case.
Parameters:
Name Type Description
json String The JSON to parse.
Source:
Returns:
Type
Object

(static) parseSchema() → {String}

Parse the initial arguments URL schema
Source:
Returns:
Type
String

(static) requireOrNull(name) → {Object}

Require a module, or return a null object
Parameters:
Name Type Description
name String
Source:
Returns:
Type
Object

(static) rot13(s)

Get the rot13 of a string
Parameters:
Name Type Description
s String
Source:

(static) startActivity(opt, erroropt)

Valid only on Android, start the activity catching any possible errors. If `error` is provided, show the error dialog with this message.
Parameters:
Name Type Attributes Description
opt Object Options for `createIntent(...)`
error String <optional>
Error message
Source:

(static) timestamp(argopt) → {Number}

Get the UNIX timestamp.
Parameters:
Name Type Attributes Description
arg Object <optional>
The date to parse.
Source:
Returns:
Type
Number

(static) timestampForHumans(ts) → {String}

Return in human readable format a timestamp
Parameters:
Name Type Description
ts Number The timestamp
Source:
Returns:
Type
String

(static) tryOpenURLs(urls) → {Boolean}

Try to open all URLs in the array
Parameters:
Name Type Description
urls Array
Source:
Returns:
`true` if at least one url has been opened.
Type
Boolean

(static) zeroPad(num, size) → {String}

Add leading zeros
Parameters:
Name Type Description
num String The number
size Number The final size
Source:
Returns:
Type
String

(inner) alertError()

Source:
See:
  • errorAlert