Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

app.utils

Leonardo Laureti edited this page Jul 23, 2019 · 3 revisions

app.utils

Utils functions

<Object>

 

app.utils.system

Detects system environment

<Function>

arguments:

<String> purpose   ( name | platform | architecture | release )

returns.

position:

 

app.utils.addEvent

Helper to add element event listener

<Function>

arguments:

<String> event
<ElementNode> element
<Function> func

returns.

position:

 

app.utils.removeEvent

Helper to remove element event listener

<Function>

arguments:

<String> event
<ElementNode> element
<Function> func

returns.

position:

 

app.utils.proxy

Proxy function with passed arguments

<Function>

arguments:

<Boolean> deep
<Object> | <Function> obj

returns:

<Object> |

position:

 

app.utils.storage

Storage utility, it stores persistent (across the session) and non-persistent data

<Function> prototype   constructor

available prototype methods:

 - set (key, value)
 - get (key)
 - has (key, value)
 - del (key)
 - reset ()
 - fake ()

arguments:

<String> persists
<String> method
<String> key
value

returns.

position:

 

app.utils.cookie

Helper to handle cookie

<Function> prototype   constructor

available prototype methods:

 - set (key, value, expire_time)
 - get (key)
 - has (key, value)
 - del (key)
 - reset ()

arguments:

<String> method
<String> key
value
<Date> expire_time

returns.

position:

 

app.utils.base64

Base64 encoder and decoder

<Function> prototype   constructor

available prototype methods:

 - encode (to_encode)
 - decode (to_decode)

arguments:

to_encode

returns.

position:

 

app.utils.transform

Transforms type of passed value

<Function>

arguments:

<String> purpose   ( lowercase | uppercase | numeric | integer | json )
value

returns.

position:

 

app.utils.sanitize

Sanitizes passed value

<Function>

arguments:

<String> purpose   ( whitespace | breakline | date | datetime | datetime-local | array )
value

returns.

position:

 

app.utils.classify

Transforms object to classnames

<Function>

arguments:

<Object> | <Array> data
<String> prefix
<Boolean> to_array

returns:

classes

position:

 

app.utils.numberFormat

Formats number float within decimal and thousand groups

<Function>

arguments:

<Number> number
<Number> decimals
<String> decimals_separator
<String> thousands_separator

returns:

<String>

position:

 

app.utils.dateFormat

Formats date, supported format specifiers are like used in strftime() C library function,

it accepts Date time format or boolean true for 'now', default: "Y-m-d H:M"

<Function>

format specifiers:

 - d  // Day of the month, digits preceded by zero (01-31)
 - J  // Day of the month (1-31)
 - w  // Day of the week (1 Mon - 7 Sun)
 - m  // Month, digits preceded by zero (01-12)
 - n  // Month (1-12)
 - N  // Month, start from zero (0-11)
 - Y  // Year, four digits (1970)
 - y  // Year, two digits (70)
 - H  // Hours, digits preceded by zero (00-23)
 - G  // Hours (0-23)
 - M  // Minutes, digits preceded by zero (00-59)
 - I  // Minutes (0-59)
 - S  // Seconds, digits preceded by zero (00-59)
 - K  // Seconds (0-59)
 - v  // Milliseconds, three digits
 - a  // Abbreviated day of the week name (Thu)
 - b  // Abbreviated month name (Jan)
 - x  // Date representation (1970/01/01)
 - X  // Time representation (01:00:00)
 - s  // Seconds since the Unix Epoch
 - V  // Milliseconds since the Unix Epoch
 - O  // Difference to Greenwich time GMT in hours (+0100)
 - z  // Time zone offset (+0100 (CEST))
 - C  // Date and time representation (Thu, 01 Jan 1970 00:00:00 GMT)
 - Q  // ISO 8601 date representation (1970-01-01T00:00:00.000Z)

arguments:

<Date> | <Boolean> time

returns:

formatted_date

position:

 

app.utils.numberLendingZero

Pads number from left with zero

<Function>

arguments:

number

returns.

position:

 

app.utils.isPlainObject

Checks if object is a plain object

(jQuery.fn.isPlainObject)
jQuery JavaScript Library

links: https://jquery.com/

license: MIT license https://jquery.org/license

copyright: Copyright JS Foundation and other contributors

<Function>

arguments:

<Object> obj

returns:

<Boolean>

position:

 

app.utils.extendObject

Deep extend and merge objects

(jQuery.fn.extend)
jQuery JavaScript Library

links: https://jquery.com/

license: MIT license https://jquery.org/license

copyright: Copyright JS Foundation and other contributors

<Function>

returns:

<Object> target

position:

 

Clone this wiki locally