GlobalHelper Class
Various methods to handle the HTML structure modification.
Constructor
GlobalHelper
()
Item Index
Methods
- __forceMobileDevice
- addScript
- addScripts
- addStylesheet static
- createScreenshot3D static
- generateRandomString
- getCapabilities static
- getWrappedMouseEventNames static
- hasAzertyKeyboard static
- hasCanvas2D static
- hasWebGL static
- insertHTML
- isAndroidDevice static
- isAppleDevice static
- isIE static
- isIE9 static
- isIE9 static
- isMobileDevice static
- isSamsungDevice static
- isWindowsDevice static
- isWindowsPhoneDevice static
- simulateClick static
- simulateKey static
- stripDomainUrl
Methods
__forceMobileDevice
-
value
Forces the device mode (mobile or desktop).
Parameters:
-
value
BooleanSet to true to force the mobile detection or false for desktop.
addScript
-
scriptUrl
-
params
-
successCallback
-
errorCallback
Insert a script to the page.
addScripts
-
scripts
-
options
-
successCallback
-
errorCallback
-
interval
Load a collection of scripts. Here are two methods to load scripts.
- A simple array with urls [ "script.js", "script2.js" ]
- 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
ArrayAn 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
Add a CSS file to the page.
createScreenshot3D
-
engine
-
[quality]
-
[callback]
Creates a screenshot of the 3D scene.
generateRandomString
-
[length]
Generates a random string
Parameters:
-
[length]
Number optionalThe 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:
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:
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:
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:
Return true if the canvas 2D is supported, otherwise return false.
hasWebGL
()
Boolean
static
Indicates whether the browser has WebGL support.
Returns:
Return true if WebGL is supported, otherwise return false.
insertHTML
-
htmlPath
-
domNode
-
successCallback
-
errorCallback
Insert an HTML file into the specified node.
Parameters:
-
htmlPath
StringThe URL of the HTML file to load.
-
domNode
String | HTMLElementThe element's ID or the element itself.
-
successCallback
FunctionA function called when the HTML file is insered.
-
errorCallback
FunctionA function called if the process fail.
isAndroidDevice
()
Boolean
static
Indicates whether the user's device is an Android device.
Returns:
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:
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:
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:
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:
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:
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:
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:
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:
Return true if the user's device is a Windows Phone device, otherwise return false.
simulateClick
-
element
-
x
-
y
-
(optional)
-
(optional)
-
(optional)
This method simulate a mouse event. It's used for testing purpose.
Parameters:
-
element
HTMLElementAn element which will trigger the mouse event.
-
x
Number(optional) The horizontal coordinate.
-
y
Number(optional) The vertical coordinate.
-
(optional)
Stringtype The type of mouse event: down, up, move.
-
(optional)
Numberbutton The button index (ex. 0 for the left button).
-
(optional)
Numberwheel The wheel value.
simulateKey
-
keyCode
-
type
-
modifiers
This method simulate a key event. It's used for testing purpose.
stripDomainUrl
-
url
-
racine
Strips the url of its domain. eg. it replaces http://v2.wanaplan.com/data/stuff.ext => /data/stuff.ext