diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b768ae7..095d425b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/resources/docs/docs/widgets/advanced-syntaxes.md b/resources/docs/docs/widgets/advanced-syntaxes.md index 82229fd3..c153ecc9 100644 --- a/resources/docs/docs/widgets/advanced-syntaxes.md +++ b/resources/docs/docs/widgets/advanced-syntaxes.md @@ -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. diff --git a/resources/docs/docs/widgets/scripting.md b/resources/docs/docs/widgets/scripting.md index 9594e467..4b8abffa 100644 --- a/resources/docs/docs/widgets/scripting.md +++ b/resources/docs/docs/widgets/scripting.md @@ -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) diff --git a/src/client/widgets/vm.js b/src/client/widgets/vm.js index 85d26dd7..11671108 100644 --- a/src/client/widgets/vm.js +++ b/src/client/widgets/vm.js @@ -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 + } } }