Options
All
  • Public
  • Public/Protected
  • All
Menu

@tspower/core

Index

Variables

htmlParse

htmlParse: htmlParse = (function() {var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,rtagName = /<([\w:]+)/,rhtml = /<|&#?\w+;/,// We have to close these tags to support XHTML (#13200)wrapMap = {// Support: IE9option: [1, "<select multiple='multiple'>", "</select>"],thead: [1, "<table>", "</table>"],col: [2, "<table><colgroup>", "</colgroup></table>"],tr: [2, "<table><tbody>", "</tbody></table>"],td: [3, "<table><tbody><tr>", "</tr></tbody></table>"],_default: [0, "", ""]};/*** @param {String} elem A string containing html* @param {Document} context*/return function htmlParse(elem:string, context?:any) {context = context || document;var tmp, tag, wrap, j,fragment = context.createDocumentFragment();if (!rhtml.test(elem)) {fragment.appendChild(context.createTextNode(elem));// Convert html into DOM nodes} else {tmp = fragment.appendChild(context.createElement("div"));// Deserialize a standard representationtag = (rtagName.exec(elem) || ["", ""])[1].toLowerCase();wrap = wrapMap[tag] || wrapMap._default;tmp.innerHTML = wrap[1] + elem.replace(rxhtmlTag, "<$1></$2>") + wrap[2];// Descend through wrappers to the right contentj = wrap[0];while (j--) {tmp = tmp.lastChild;}// Remove wrappers and append created nodes to fragmentfragment.removeChild(fragment.firstChild);while (tmp.firstChild) {fragment.appendChild(tmp.firstChild);}}return fragment;};}())

Functions

Let collToArray

  • collToArray(collection: NodeListOf<Element>): Array<any>
  • transform a collection to an array

    Parameters

    • collection: NodeListOf<Element>

      collection of HTMLElement

    Returns Array<any>

Let empty

  • empty(node: HTMLElement): void
  • Parameters

    • node: HTMLElement

      HTMLElement

    Returns void

    none - remove all childs of node

Let emptyLocal

  • emptyLocal(): void
  • clear local storage

    Returns void

Let err

  • err(s: any, label?: string, time?: boolean): void
  • Parameters

    • s: any

      any error s

    • Default value label: string = ""

      string to identify log

    • Default value time: boolean = false

      stamp datetime of log

    Returns void

Let escapeTag

  • escapeTag(s: string): string
  • Parameters

    • s: string

      string to be escape

    Returns string

    string escaped

Let getCookie

  • getCookie(name: string): any
  • get saved cookie

    Parameters

    • name: string

      cookie name

    Returns any

Let getLocal

  • getLocal(name: string): any
  • get item value

    Parameters

    • name: string

      item name

    Returns any

Let htmlParseNT

  • htmlParseNT(s: string): HTMLElement
  • Parameters

    • s: string

      string

    Returns HTMLElement

    HTMLElement result of string parse

Let log

  • log(s: any, label?: string, time?: boolean): void
  • Parameters

    • s: any

      any log s

    • Default value label: string = ""

      string to identify log

    • Default value time: boolean = false

      stamp datetime of log

    Returns void

Let removeCookie

  • removeCookie(name: string): void
  • erase cookie

    Parameters

    • name: string

      cookie name

    Returns void

Let removeLocal

  • removeLocal(name: string): void
  • remove item from local storage

    Parameters

    • name: string

      item name

    Returns void

Let replaceAll

  • replaceAll(str: string, find: string, replace: string): string
  • Parameters

    • str: string

      original string

    • find: string

      string to be find

    • replace: string

      string replace

    Returns string

Let setCookie

  • setCookie(name: string, value: any, days?: any): void
  • set cookie

    Parameters

    • name: string

      cookie name

    • value: any

      cookie value

    • Optional days: any

      days expire

    Returns void

Let setLocal

  • setLocal(name: string, value: any): void
  • set item in local storage

    Parameters

    • name: string

      item name

    • value: any

      item value

    Returns void

Let unique

  • unique(array: Array<any>): Array<any>
  • Parameters

    • array: Array<any>

    Returns Array<any>

Let uniqueObj

  • uniqueObj(array: Array<object>, objProperty: string): Array<any>
  • Parameters

    • array: Array<object>
    • objProperty: string

    Returns Array<any>

Generated using TypeDoc