Class SAGE2_runtime
Class defined in:public/src/SAGE2_runtime.js:15
Generic functions used by all SAGE2 applications
addCookie
( sKey, sValue
)
public/src/SAGE2_runtime.js:851
Add a key-value pair as a cookie
Parameters:true/false
allTrueDict
( dict
)
public/src/SAGE2_runtime.js:581
Test if all values of an object are true
Parameters:-
dict
<Object>values
true if all values are true
average
( arr
)
public/src/SAGE2_runtime.js:562
Calculate the average value of an array
Parameters:-
arr
<Array>values to be averaged
the average
base64ToString
( base64
)
public/src/SAGE2_runtime.js:385
Decode base64 into string
Parameters:-
base64
<String>content to be decoded
string content
base64ToUint8Array
( base64
)
public/src/SAGE2_runtime.js:443
Convert a string to Uint8Array typed array
Parameters:-
base64
<String>string to be converted
resulting array
broadcast
( dataObject
)
public/src/SAGE2_runtime.js:334
Send the broadcast call to the server
Parameters:-
dataObject
<Object>data to be sent
byteBufferToInt
( buff
)
public/src/SAGE2_runtime.js:802
Convert an array of byte to an integer
Parameters:-
buff
<Array>buffer to be processed
resulting value
byteBufferToString
( buff
)
public/src/SAGE2_runtime.js:817
Convert an array of byte to a string (using fromCharCode on every character)
Parameters:-
buff
<Array>buffer to be processed
string
cleanURL
( url
)
public/src/SAGE2_runtime.js:670
Cleanup a URL and replace the origin to match the client (to mitigate CORS problems, cross-origin resource sharing)
Parameters:-
url
<String>URL to clenaup
new URL
copyToClipboard
( text
)
public/src/SAGE2_runtime.js:965
From stackoverflow: Copies a string to the clipboard. Must be called from within an event handler such as click. May return false if it failed, but this is not always possible. Browser support for Chrome 43+, Firefox 42+, Safari 10+, Edge and IE 10+. IE: The clipboard feature may be disabled by an administrator. By default a prompt is shown the first time the clipboard is used (per session)
Parameters:-
text
<String>The text to be copied
A Boolean that is false if the command is not supported or enabled
createDrawingElement
( id, className, posx, posy, width, height, depth
)
public/src/SAGE2_runtime.js:150
Basic function for creating a canvas in the DOM
Parameters:-
id
<String>DOM id to be created
-
className
<String>CSS class
-
posx
<Number>position x
-
posy
<Number>position y
-
width
<Number>width (number in pixel)
-
height
<Number>height (number in pixel)
-
depth
<Number>z index
DOM canvas element
csvToArray
( strData, strDelimiter
)
public/src/SAGE2_runtime.js:495
Convert CSV data to an array (used by the readFile function)
Parameters:array containing the parsed data
deleteCookie
( sKey
)
public/src/SAGE2_runtime.js:901
Delete a cookie for a given key
Parameters:-
sKey
<String>key
true/false
deleteElement
( id
)
public/src/SAGE2_runtime.js:641
Delete an element in the DOM
Parameters:-
id
<Element>DOM element to delete
format24Hr
( date
)
public/src/SAGE2_runtime.js:355
Convert date into 24h string format
Parameters:-
date
<Object>momentjs object for time
formatted date
formatAMPM
( date
)
public/src/SAGE2_runtime.js:344
Pretty print a date object into string
Parameters:-
date
<Object>momentjs object for time
formatted date
formatHHMMSS
( duration
)
public/src/SAGE2_runtime.js:366
Convert a duration number into readable string
Parameters:-
duration
<Number>duration
formatted duration
getCookie
( sKey
)
public/src/SAGE2_runtime.js:916
Return a cookie value for given key
Parameters:-
sKey
<String>key
value found or null
getParameterByName
( name
)
public/src/SAGE2_runtime.js:598
Extract the parameter value from the current URL (?clientID=0¶m=4)
Parameters:-
name
<String>parameter to search for
null or the value found
getTransform
( elem
)
public/src/SAGE2_runtime.js:932
Extract translate and scale from a DOM element
Parameters:-
elem
<Object>DOM element
contains translate and scale specification
initializeArray
( size, value
)
public/src/SAGE2_runtime.js:786
Create an array of given size filled with a value
Parameters:-
size
<Number>size of the array
-
value
<Value>initial value
new array
isEmpty
( obj
)
public/src/SAGE2_runtime.js:753
Test is an object is equivalen to 'empty'
Parameters:-
obj
<Object>value to be tested
true if empty
isTrue
( element, index, array
)
public/src/SAGE2_runtime.js:740
Test if element is equal to true (used in .every call on an array)
Parameters:-
element
<Bool>The current element being processed in the array
-
index
<Number>The index of the current element being processed in the array
-
array
<Array>The array every was called upon
true if element is true
log
( obj
)
public/src/SAGE2_runtime.js:129
Debug log function: send parameters to server for printout if mutiple paramters, sent as one array
Parameters:-
obj
<Object>data to be printed
Math.seed
( s
)
public/src/SAGE2_runtime.js:834
Overload Math.seed and Math.random to be deterministic, for distributed work
Parameters:-
s
<Number>seed
moveItemToFront
( elem
)
public/src/SAGE2_runtime.js:627
Reorder elements at given level in the DOM
Parameters:-
elem
<Element>DOM element to reorder
parseBool
( value
)
public/src/SAGE2_runtime.js:714
Utility function to test if a string or number represents a true value. Used for parsing JSON values
Parameters:-
value
<Object>value to test
playPauseVideo
( elemId
)
public/src/SAGE2_runtime.js:612
Search for a video tag and switch its state
Parameters:-
elemId
<String>video element to search
readFile
( filename, callback, type
)
public/src/SAGE2_runtime.js:460
Do a HTTP GET request to the server to retrieve a file content
Parameters:removeAllChildren
( node
)
public/src/SAGE2_runtime.js:654
Remove of children of a DOM element
Parameters:SAGE2_initialize
( data_seed
)
public/src/SAGE2_runtime.js:42
Initializes global settings: random generator, ...
Parameters:-
data_seed
<Date>seed number
sage2Log
( msgObject
)
public/src/SAGE2_runtime.js:316
Pretty print in browser and send to server
Parameters:-
msgObject
<Object>data to be printed
smallTansparentGIF
(
)
public/src/SAGE2_runtime.js:407
Smallest transparent image, put in a image tag source
small GIF image in base64 content
smallWhiteGIF
(
)
public/src/SAGE2_runtime.js:417
Smallest white image, put in a image tag source
small GIF image in base64 content
stringToBase64
( string
)
public/src/SAGE2_runtime.js:396
Encode a string to base64
Parameters:-
string
<String>content to be encoded
base64 content
stringToUint8Array
( string
)
public/src/SAGE2_runtime.js:428
Convert a string to Uint8Array typed array
Parameters:-
string
<String>string to be converted
resulting array
SAGE2types
<Object>public/src/SAGE2_runtime.js:176
Basic data types for inter-application communications