API Docs for: 2.7.3
Show:

GlobalHelper Class

Module: Helpers
Parent Module: Wanaplan

Various methods to handle the HTML structure modification.

Constructor

GlobalHelper

()

Methods

__forceMobileDevice

(
  • value
)

Forces the device mode (mobile or desktop).

Parameters:

  • value Boolean

    Set to true to force the mobile detection or false for desktop.

addScript

(
  • scriptUrl
  • params
  • successCallback
  • errorCallback
)

Insert a script to the page.

Parameters:

  • scriptUrl String

    The URL of the script to load.

  • params Object

    A dictionary of parameters (ex. { "async": "true" }).

  • successCallback Function

    A function called when the script is ready.

  • errorCallback Function

    A function called if the process fail.

addScripts

(
  • scripts
  • options
  • successCallback
  • errorCallback
  • interval
)

Load a collection of scripts. Here are two methods to load scripts.

  1. A simple array with urls [ "script.js", "script2.js" ]
  2. An array of dictionary [ { MyObject: "myObjectScript.js" } ]. In this case the function will test if the script is already loaded by using the key of the dictionary as object name.

Parameters:

  • scripts Array

    An array that contains all url to load or an array of.

  • options Object

    (Optional) A dictionary of parameters (ex. { "async": "true" }).

  • successCallback Function

    (Optional) A function called when the script is ready.

  • errorCallback Function

    (Optional) A function called if the process fail.

  • interval Number

    (Optional) The value of check interval.

addStylesheet

(
  • stylesheet
  • params
  • successCallback
  • errorCallback
)
static

Add a CSS file to the page.

Parameters:

  • stylesheet String

    The URL of the file to load.

  • params Object

    A dictionary of parameters (ex. { "media": "print" }).

  • successCallback Function

    A function called when the file is insered.

  • errorCallback Function

    A function called if the process fail.

createScreenshot3D

(
  • engine
  • [quality]
  • [callback]
)
static

Creates a screenshot of the 3D scene.

Parameters:

  • engine BABYLON.Engine

    The 3D engine.

  • [quality] String optional

    The desired quality of output ("native", "Thumb", "HD", "FullHD" or "4K").

  • [callback] Function optional

    A function called on the screenshot after it is created.

generateRandomString

(
  • [length]
)

Generates a random string

Parameters:

  • [length] Number optional

    The size of the string, default is 5.

getCapabilities

() Object static

Gets the supported GPU capabilities of the browser eg. the list of GL extensions or maximum texture size.

Returns:

Object:

an object that contains GPU capabilities.

getWrappedMouseEventNames

() Object static

Gets an object which contains the correct event names to use (touch, mouse or pointer).

Returns:

Object:

Return a dictionary with correct event names * Result on Android: { down: "touchstart", move: "touchmove", up: "touchend", cancel: "touchcancel" } * Result on WindowsPhone: { down: "pointerdown", move: "pointermove", up: "pointerup", cancel: "pointercancel", out: "pointerout" } * Result on Desktop: { down: "mousedown", move: "mousemove", up: "mouseup", cancel: "mouseup" }

hasAzertyKeyboard

() Boolean static

Indicates whether the user's keyboard has an AZERTY layout.

Returns:

Boolean:

Return true if the user's keyboard has an AZERTY layout, otherwise return false.

hasCanvas2D

() Boolean static

Indicates whether the browser has Canvas 2D support.

Returns:

Boolean:

Return true if the canvas 2D is supported, otherwise return false.

hasWebGL

() Boolean static

Indicates whether the browser has WebGL support.

Returns:

Boolean:

Return true if WebGL is supported, otherwise return false.

insertHTML

(
  • htmlPath
  • domNode
  • successCallback
  • errorCallback
)

Insert an HTML file into the specified node.

Parameters:

  • htmlPath String

    The URL of the HTML file to load.

  • domNode String | HTMLElement

    The element's ID or the element itself.

  • successCallback Function

    A function called when the HTML file is insered.

  • errorCallback Function

    A function called if the process fail.

isAndroidDevice

() Boolean static

Indicates whether the user's device is an Android device.

Returns:

Boolean:

Return true if the user's device is an Android device, otherwise return false.

isAppleDevice

() Boolean static

Indicates whether the user's device is an Apple device.

Returns:

Boolean:

Return true if the user's device is an Apple device, otherwise return false.

isIE

() Number static

Indicates whether the user's browser is Internet Explorer and return its version if it is.

Returns:

Number:

Return the version of Internet Explorer if it is used, otherwise return -1.

isIE9

() Boolean static

Indicates if the user's browser is Internet Explorer 10.

Returns:

Boolean:

Return true if the user's browser is Internet Explorer 10, otherwise return false.

isIE9

() Boolean static

Indicates if the user's browser is Internet Explorer 9.

Returns:

Boolean:

Return true if the user's browser is Internet Explorer 9, otherwise return false.

isMobileDevice

() Boolean static

Indicates whether the user's device is a mobile device.

Returns:

Boolean:

Return true if the user's device is a mobile device, otherwise return false.

isSamsungDevice

() Boolean static

Indicates whether the user's device is a Samsung Mobile device.

Returns:

Boolean:

Return true if the user's device is a Samsung Mobile device, otherwise return false.

isWindowsDevice

() Boolean static

Indicates whether the user's device is a Windows Mobile device.

Returns:

Boolean:

Return true if the user's device is a Windows Mobile device, otherwise return false.

isWindowsPhoneDevice

() Boolean static

Indicates whether the user's device is a Windows Phone device.

Returns:

Boolean:

Return true if the user's device is a Windows Phone device, otherwise return false.

simulateClick

(
  • element
  • x
  • y
  • (optional)
  • (optional)
  • (optional)
)
static

This method simulate a mouse event. It's used for testing purpose.

Parameters:

  • element HTMLElement

    An element which will trigger the mouse event.

  • x Number

    (optional) The horizontal coordinate.

  • y Number

    (optional) The vertical coordinate.

  • (optional) String

    type The type of mouse event: down, up, move.

  • (optional) Number

    button The button index (ex. 0 for the left button).

  • (optional) Number

    wheel The wheel value.

simulateKey

(
  • keyCode
  • type
  • modifiers
)
static

This method simulate a key event. It's used for testing purpose.

Parameters:

  • keyCode Number

    The Key Code of the key to simulate.

  • type String

    The type of event: down, up or press.

  • modifiers Object

    A dictionary of modifier keys (ex. { "ctrl": "true" }).

stripDomainUrl

(
  • url
  • racine
)

Strips the url of its domain. eg. it replaces http://v2.wanaplan.com/data/stuff.ext => /data/stuff.ext

Parameters:

  • url String

    The url to clean

  • racine String

    Check if this pattern is in the url before cleaning it