HTML5 - JavaScript functions
This article describes a feature or macro function that is experimental and may be subject to change.
A special class is available to JavaScript code running inside HTML5 pages. It allows access to a few values and functions.
The class itself is static and is called MapTool
.
Functions
MapTool.getName()
- Returns the name of the panel.
MapTool.getUserData()
- Returns the data passed to the panel via thevalue
option.
[html.frame5("Example Dialog",
"lib://myAddon/index.html",
'value={"key": "some arbitrary data"}')]
The variable value
is injected into the JavaScript as a global variable (ie. as a property of the window
object), such that it can be accessed as either window.value
or just value
.
// There's an implied assignment to 'value' here, prior to your JavaScript code
window.addEventListener("load", function() {
console.log("Loaded");
console.log(JSON.stringify(MapTool.getUserData()));
})
MapTool.log()
- Anything passed to this method will be sent to the chat window, just like a broadcast() toself
.
Additionally, console.log()
will be redirected to the chat window as well.