maptool icon indicating copy to clipboard operation
maptool copied to clipboard

[Feature]: Passing data to html page via html.dialog5 etc.

Open Tdue21 opened this issue 1 year ago • 1 comments

Feature Request

Currently there is no clean way of passing data from a macro to a html page displayed via html.dialog5 and its ilk. The only way is more or less hacky methods of storing data somewhere, e.g. in a MT variable, and then read it back, once the html page is up. This is somewhat problematic and prone to errors.

The html.dialog5 is otherwise great, as it fosters a certain level of laying in the code.

The Solution you'd like

I see a couple of possible solutions.

  1. Allow query parameters in the url and implement something like Document.documentURI or window.location which exists in the DOM normally. This way, the signature of ´html.dialog5` will be unchanged.
  2. Alternatively the signature of html.dialog5 should be expanded with another parameter. This is used to pass any data in the form of a json object. Then a way of reading that object from embedded javascript is needed.

Alternatives that you've considered.

No response

Additional Context

No response

Tdue21 avatar Jul 18 '22 12:07 Tdue21

Worth noting html.dialog5 already has a userdata parameter which stores arbitrary user data tagged to the dialog (or frame) itself. The problem is this cannot be fetched by the html5 context because it must be fetched by name, and the html5 context is unaware of its own name.

It would be sufficient to set the window.name property within the html5 context to the name of the frame (probably in the form of {kind}:{name}, so dialog5:example or similar. window.name is included, but optional, in the window spec for javascript in html5.

perkinslr avatar Jul 19 '22 23:07 perkinslr