Have questions? Stuck? Please check our FAQ for some common questions and answers.

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

This page is a work in progress.

FnService - Function Service

FnService is an Angular Factory in the Util module with the name fn.js. It provides general purpose functions that are useful throughout the client-side application. To use these functions, see the documentation on injecting Angular services.

Note: some of these functions are repeats of jQuery functions. Since we are not using jQuery, we wrote our own implementations.

NameSummary
isFChecks if argument is a function.
isAChecks if argument is an array.
isS

Checks if argument is a string.

isOChecks if argument is an object.
containsChecks if an array contains a value.
areFunctionsChecks if given strings are names of functions on an API and whether the API has functions that are not listed.
areFunctionsNonStrictChecks if given strings are names of functions on an API. (Doesn't care about unlisted functions.)
windowSizeReturns inner dimensions of the window minus given values.
isMobileReturns true if the device viewing the GUI is a mobile device.
debugOnReturns true if the debug flag is turned on in query params.
findSearches through an array of objects looking for the one with the tagged property with a given key.
inArrayChecks if an item is in the array.
removeFromArrayRemoves specified item from the array.
isEmptyObjectReturns true if the object is empty.
capReturns the string with only the first letter capitalized.
noPxReturn the argument without the 'px' suffix.
noPxStyle

Return the element's style property without the 'px' suffix.

endsWithChecks if the given string ends with a given suffix.
parseBitRateReturns a Number version of the given string bit rate.

 

Function Descriptions

Note: Green Text means that the return value is truthy. Red Text means that the return value is falsy.

isF

Short for "is Function". Checks if argument is a function.

Example UsageArgumentsReturn Values
fs.isF(f);f - the variable to check if it is a function

f if typeof is 'function'

null if f is not a function

isA

Short for "is Array". Checks if argument is an array.

Example UsageArgumentsReturn Values
fs.isA(a);a - the variable to check if it is an array

a if isArray (ECMA5) returns true

null if a is not an array

isS

Short for "is String". Checks if argument is a string.

Example UsageArgumentsReturn Values
fs.isS(s);s - the variable to check if it is a string

 s if typeof is 'string'

null if s is not a string

isO

Short for "is Object". Checks if argument is an object.

Example UsageArgumentsReturn Values
fs.isO(o);o - the variable to check if it is an object

o if typeof is 'object' and the constructor is Object

null if o is not an object

contains

Checks if an array contains an item.

Example UsageArgumentsReturn Values
fs.contains(ax);

a - the array to search

x - the item to look for

the index of x if it is in a

false if a isn't an array

-1 if x isn't in the array

areFunctions

areFunctionsNonStrict

windowSize

Returns inner dimensions of the browser window minus given values.

Example UsageArgumentsDefault ParamsReturn Value
fs.windowSize(offH, offW);

offH - number value to be subtracted from the browser window height

offW - number value to be subtracted from the browser window width

offH: 0 (if offH is falsy)

offV: 0 (if offW is falsy)

an object with members:

  • height: window inner height minus offH (if given)
  • width: window inner width minus offW (if given)

isMobile

Returns true if the device viewing the GUI is a mobile device.

Example UsageArgumentsReturn Values
fs.isMobile();none

true if the device viewing the GUI is a mobile device

false otherwise

debugOn

Returns true if the debug flag is turned on in query params.

Example UsageArgumentsReturn Values
fs.debugOn(tag);tag: string of which debug flag you are looking for

true if debug flag is turned on for tag

undefined otherwise


find

inArray

removeFromArray

isEmptyObject

cap

noPx

noPxStyle

endsWith

parseBitRate

  • No labels