GlobalHelper
Summary
Various methods to handle the HTML structure modification.
Constructor
GlobalHelper
Syntax
GlobalHelper
()
Summary
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
Syntax
__forceMobileDevice
-
value
Summary
Forces the device mode (mobile or desktop).
Parameters:
-
value
BooleanSet to true to force the mobile detection or false for desktop.
addScript
Syntax
addScript
-
scriptUrl
-
params
-
successCallback
-
errorCallback
Summary
Insert a script to the page.
addScripts
Syntax
addScripts
-
scripts
-
options
-
successCallback
-
errorCallback
-
interval
Summary
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
Syntax
addStylesheet
-
stylesheet
-
params
-
successCallback
-
errorCallback
Summary
Add a CSS file to the page.
createScreenshot3D
Syntax
createScreenshot3D
-
engine
-
[quality]
-
[callback]
Summary
Creates a screenshot of the 3D scene.
generateRandomString
Syntax
generateRandomString
-
[length]
Summary
Generates a random string
Parameters:
-
[length]
Number optionalThe size of the string, default is 5.
getCapabilities
Syntax
Summary
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
Syntax
Summary
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
Syntax
Summary
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
Syntax
Summary
Indicates whether the browser has Canvas 2D support.
Returns:
Return true if the canvas 2D is supported, otherwise return false.
hasWebGL
Syntax
Summary
Indicates whether the browser has WebGL support.
Returns:
Return true if WebGL is supported, otherwise return false.
insertHTML
Syntax
insertHTML
-
htmlPath
-
domNode
-
successCallback
-
errorCallback
Summary
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
Syntax
Summary
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
Syntax
Summary
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
Syntax
Summary
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
Syntax
Summary
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
Syntax
Summary
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
Syntax
Summary
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
Syntax
Summary
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
Syntax
Summary
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
Syntax
Summary
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
Syntax
simulateClick
-
element
-
x
-
y
-
(optional)
-
(optional)
-
(optional)
Summary
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
Syntax
simulateKey
-
keyCode
-
type
-
modifiers
Summary
This method simulate a key event. It's used for testing purpose.
stripDomainUrl
Syntax
stripDomainUrl
-
url
-
racine
Summary
Strips the url of its domain. eg. it replaces http://v2.wanaplan.com/data/stuff.ext => /data/stuff.ext