A class with static members that makes the console and the types used by the API available together with some utilty functions. Usually imported as JGConsole. Of course, the types and functions may also be imported individually.

The class is also registered as window.JGConsole for non-modular JavaScript.

Constructors

Properties

Log: typeof Log = Log
NotificationType: typeof NotificationType = NotificationType
OptionsSet: typeof OptionsSet = OptionsSet
RenderMode: typeof RenderMode = RenderMode
Renderer: typeof Renderer = Renderer
TableController: typeof TableController = TableController
formatMemorySize: ((size: number, digits: number, lang: undefined | string | number) => string) = formatMemorySize

Type declaration

    • (size, digits, lang): string
    • Utility function to format a memory size to a maximum of 4 digits for the integer part by appending the appropriate unit.

      Parameters

      • size: number

        the size value to format

      • digits: number

        the number of digits of the factional part

      • lang: undefined | string | number

        the language (BCP 47 code, used to determine the delimiter)

      Returns string

instance: Console = theConsole
parseHtml: ((html: string) => HTMLElement[]) = parseHtml

Type declaration

    • (html): HTMLElement[]
    • Converts a string with HTML source to a single or multiple DOM trees.

      Parameters

      • html: string

      Returns HTMLElement[]

      the root nodes of the DOM trees

Methods

  • Returns the data (data-* Attribute) of the specified element with the given key. If it does not exist, it set to the value provided by the supplier function.

    Parameters

    • node: HTMLElement

      the DOM element

    • key: string

      the key of the data

    • supplier: (() => string)

      the supplier function

        • (): string
        • Returns string

    Returns string

  • Finds the lang specific item in a map of items by language. The function first tests for a property as specified by lang, then removes any trailing "-..." from lang and tries again. If not successful, it tests for an entry using "en" and if still no match is found it returns null.

    Parameters

    • items: Map<string, string> | Map<string, Map<string, string>>

      the messages by language identifier

    • lang: string

      the language identifier

    • fallback: string = 'en'

      fallback language (defaults to 'en')

    Returns null | string | Map<string, string>

  • Delegates to Console.init.

    Parameters

    • connectionId: string
    • options: any

    Returns void

  • Localizes the given key, using the provided localizations and language.

    First, the implementation looks up a mapping using forLang(l10ns, lang, fallback). Then it looks for an entry for key. If none is found, it returns the value of key.

    Parameters

    • l10ns: Map<string, Map<string, string>>

      the mappings by language identifier

    • lang: string

      the language identifier

    • key: string

      the key to look up

    • fallback: string = 'en'

      fallback language (defaults to 'en')

    Returns string

  • Parameters

    • conletClass: string
    • functionName: string
    • conletFunction: ((conletId: string, ...args: any[]) => void)
        • (conletId, ...args): void
        • Parameters

          • conletId: string
          • Rest...args: any[]

          Returns void

    Returns void