scripting: expose session path as globals.session
This commit is contained in:
parent
e80711e2da
commit
ca4ccf181b
4 changed files with 9 additions and 1 deletions
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
- scripting
|
||||
- add `getVar()` and `setVar` for reading and modifying custom variables. This allows modifying properties directly from scripts.
|
||||
- expose session path as `globals.session`
|
||||
|
||||
## 1.9.3
|
||||
|
||||
|
|
|
|||
|
|
@ -81,6 +81,7 @@ A property *cannot* contain multiple `JS{{}}` blocks
|
|||
- `ip`: client's ip address,
|
||||
- `url`: server url,
|
||||
- `platform`: operating system as seen by the client
|
||||
- `session`: session file path
|
||||
|
||||
In this context, `@{} / OSC{}` are seen as variables. When they change, the whole block will be evaluated again.
|
||||
|
||||
|
|
|
|||
|
|
@ -84,6 +84,7 @@ The following variables and functions are accessible in this context.
|
|||
- `ip`: client's ip address,
|
||||
- `url`: server url,
|
||||
- `platform`: operating system as seen by the client
|
||||
- `session`: session file path
|
||||
- `clipboard`: instance of navigator [Clipboard](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,13 +7,18 @@ class Vm {
|
|||
constructor() {
|
||||
|
||||
if (!globals) {
|
||||
var sessionManager
|
||||
globals = {
|
||||
screen: {width: screen.width, height: screen.height},
|
||||
env: deepCopy(ENV),
|
||||
ip: IP,
|
||||
url: document.location.host,
|
||||
platform: navigator.platform,
|
||||
clipboard: navigator.clipboard
|
||||
clipboard: navigator.clipboard,
|
||||
get session() {
|
||||
sessionManager = sessionManager || require('../managers/session')
|
||||
return sessionManager.sessionPath
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue