Options
All
  • Public
  • Public/Protected
  • All
Menu

cgil-html-utils

Index

Variables

version

version: "2.0.1" = LIB_VERSION

version of the library

Functions

Const addClass

  • addClass(elementId: string, cssClass: string): boolean
  • add the given css class to given html element id

    Parameters

    • elementId: string
    • cssClass: string

    Returns boolean

    true if the cssclass was added successfully, otherwise false

Const addDiv

  • addDiv(innerHtml: string, id?: string, parentId?: string, className?: string): boolean
  • add a div HtmlElement with the given innerHtml to the document or the element with id parentId

    Parameters

    • innerHtml: string
    • Optional id: string
    • Optional parentId: string
    • Optional className: string

      the css class to set for the new div

    Returns boolean

    true if div tag was added successfully, otherwise false

Const addImg

  • addImg(image: string, height: string, width: string, idElement: string): boolean
  • adds an HtmlImage element as child of the HtmlElement with the idElement parameter

    Parameters

    • image: string

      string corresponding to the path of image

    • height: string
    • width: string
    • idElement: string

      HtmlElement id that will append the img tag as child

    Returns boolean

    true if img tag was added successfully, otherwise false

Const convertEnt

  • convertEnt(text: string): string
  • convert entities (&#3456) to their utf-8 characters for display

    Parameters

    • text: string

    Returns string

Const dateFr2Iso

  • dateFr2Iso(strFrDate: string): string
  • convert a date string from french europe dd-mm-yyyy to iso yyyy-mm-dd

    Parameters

    • strFrDate: string

    Returns string

    date as string in iso format yyyy-mm-dd

Const dateIso2Fr

  • dateIso2Fr(strIsoDate: string): string
  • convert a date string from iso yyyy-mm-dd in french europe dd-mm-yyyy

    Parameters

    • strIsoDate: string

      string yyyy-mm-dd

    Returns string

    date as string in format dd-mm-yyyy

Const debounce

  • debounce<T>(fn: T, delay?: number): T

Const delClass

  • delClass(elementId: string, cssClass: string): boolean
  • removes the given css class from the given html element id

    Parameters

    • elementId: string
    • cssClass: string

    Returns boolean

    true if the cssclass was removed successfully, otherwise false

Const dumpObject2String

  • dumpObject2String(objectName: Object): string
  • get a string dump of object keys properties and values.

    Parameters

    • objectName: Object

    Returns string

Const escapeHtml

  • escapeHtml(text: string): string
  • will replace critical html chars like &,<> and quote with entities & etc..

    Parameters

    • text: string

      the text to escape

    Returns string

Const eventFire

  • eventFire(el: HTMLElement, etype: string): void

Const findByKeyValue

  • findByKeyValue(arrToSearch: Object[], keyName: keyof Object, keyValue: any): null | Object
  • Parameters

    • arrToSearch: Object[]
    • keyName: keyof Object
    • keyValue: any

    Returns null | Object

Const functionExist

  • functionExist(functionName: any): boolean
  • check if the given functionName parameters exists and is a Function

    Parameters

    • functionName: any

    Returns boolean

    true if functionName exist as a Function, false in other cases

Const getArrObjectsProperties

  • getArrObjectsProperties(objectName: Object): string[]
  • get an array of properties name for an object

    Parameters

    • objectName: Object

    Returns string[]

Const getBoolParam

  • getBoolParam(paramName: keyof Object, defaultValue?: boolean): boolean
  • get the bool value of paramName from the search part of current url or defaultValue

    Parameters

    • paramName: keyof Object
    • defaultValue: boolean = false

      is used to return a valid bool value if paramName was not valid

    Returns boolean

Const getEl

  • getEl(elemntId: string): null | HTMLElement
  • returns the Html Element that have the corresponding elementId

    Parameters

    • elemntId: string

      the id of the wanted html element

    Returns null | HTMLElement

    the HTMLElement with the givven id

Const getFloatParam

  • getFloatParam(paramName: keyof Object, defaultValue?: number): number
  • get the float value of paramName from the search part of current url or defaultValue

    Parameters

    • paramName: keyof Object
    • defaultValue: number = 0.0

      is used to return a valid float value if paramName was not valid

    Returns number

Const getIntegerParam

  • getIntegerParam(paramName: keyof Object, defaultValue?: number): number
  • get the int value of paramName from the search part of current url or defaultValue

    Parameters

    • paramName: keyof Object
    • defaultValue: number = 0

      is used to return a valid int value if paramName was not valid

    Returns number

Const getParams

  • getParams(url: string): Object

Const getStringParam

  • getStringParam(paramName: keyof Object, defaultValue?: string): string
  • get the string value of paramName from the search part of current url or defaultValue

    Parameters

    • paramName: keyof Object
    • defaultValue: string = ''

    Returns string

Const isEmpty

  • isEmpty(variable: any): boolean
  • check if the given variable is null, undefined or an empty string(zero length)

    Parameters

    • variable: any

    Returns boolean

    true if given variable is null or undefined or an empty string, false in other cases

Const isEmptyField

  • isEmptyField(fieldId: string): boolean
  • check if the given fieldId is null, undefined or an empty string(zero length)

    Parameters

    • fieldId: string

    Returns boolean

    true if fieldId doesn't exist, null, undefined or an empty string, false in other cases

Const isFunction

  • isFunction(f: any): boolean
  • check if the given f is a Function

    Parameters

    • f: any

      the object that you want to check

    Returns boolean

    true if f is a Function, false in other cases

Const isNullOrUndefined

  • isNullOrUndefined(variable: any): boolean
  • check if the given variable is null or undefined

    Parameters

    • variable: any

    Returns boolean

    true if given variable is null or undefined, false in other cases

Const removeDiacritics

  • removeDiacritics(str: string): string

Const removePunctuation

  • removePunctuation(str: string): string

Const throttle

  • throttle(fn: Function, threshhold?: number, ...args: any[]): () => void

Const unescapeHtml

  • unescapeHtml(text: string): string
  • will set back escaped html chars like &,<> and quote entities & to original

    Parameters

    • text: string

      the text to unescape

    Returns string

Generated using TypeDoc