diff --git a/CHANGELOG.md b/CHANGELOG.md index e135246c..462a06a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,9 @@ - widgets - menu/switch/dropdown: reset value to `undefined` when receiving a value that's not defined in `values` +- scripting + - expose instance of navigator [Clipboard](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard) as `globals.clipboard` + - midi - allow sending note off with velocity - add option for receiving note off with velocity diff --git a/resources/docs/docs/widgets/scripting.md b/resources/docs/docs/widgets/scripting.md index 3b7e14a8..de7cdc73 100644 --- a/resources/docs/docs/widgets/scripting.md +++ b/resources/docs/docs/widgets/scripting.md @@ -73,7 +73,19 @@ To avoid unwanted script executions, touch state events will only be catched if ## Available variables -Besides the variables available in the [javascript property syntax ](./advanced-syntaxes.md#available-variables) and the ones listed above, the following variables and functions are accessible in this context. +The following variables and functions are accessible in this context. + + +- `console`: javascript console +- `locals`: object for storing/reading arbitrary values. Changing its properties *does not* trigger any synchronisation even if the value is used somewhere else. +- `globals`: same as `locals` but shared between all widgets, contains a few useful variables: + - `screen`: client screen dimensions (`{width, height}`) + - `env`: client options (ie: url query options), + - `ip`: client's ip address, + - `url`: server url, + - `platform`: operating system as seen by the client + - `clipboard`: instance of navigator [Clipboard](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard) + ---- diff --git a/src/client/widgets/vm.js b/src/client/widgets/vm.js index 7e0a6155..85d26dd7 100644 --- a/src/client/widgets/vm.js +++ b/src/client/widgets/vm.js @@ -12,7 +12,8 @@ class Vm { env: deepCopy(ENV), ip: IP, url: document.location.host, - platform: navigator.platform + platform: navigator.platform, + clipboard: navigator.clipboard } }