Author Topic: Javascript libraries in EAScriptLib  (Read 8263 times)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1374
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Javascript libraries in EAScriptLib
« on: July 07, 2020, 07:23:25 pm »
Hello,

Would it be possible to have a Javascript version of the EA libraries to enable a reuse of common /built-in librairies (with a class declaration if possible) ?

Thanks
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Sunshine

  • EA Practitioner
  • ***
  • Posts: 1324
  • Karma: +121/-10
  • Its the results that count
    • View Profile
Re: Javascript libraries in EAScriptLib
« Reply #1 on: July 19, 2020, 08:35:14 am »
Good idea Guillaume. I second the idea.
Thinking about it further JavaScript is probably the language to invest in from now on as both VBScript and JScript days  appear to be numbered.

With recent releases of Sparx EA we've seen an upgrade in the JavaScript Engine to SpiderMonkey 63, an added ability to do JavaScript Model Addins and in V15.2 there is JavaScript math library support too so it makes sense to provide JavaScript versions of EA Libraries.

And to extend the thought we ought to have example LocalScripts in JavaScript similar to those already provided in JScript and VBScript to complete support of the language.

NOTE:
Now you've reminded me I actually started porting the JScripts versions of LocalScript and EALibrary over to JavaScript and managed to get through most of them just a few left. Didn't finish it off due to time constraints at work. Once I've got past the current deadlines I might finish it off. It wasn't too hard as JScript and JavaScript share syntax history and mostly its just changing references from ActiveXObject to COMObject.
« Last Edit: July 19, 2020, 12:17:19 pm by Sunshine »
Happy to help
:)

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1324
  • Karma: +121/-10
  • Its the results that count
    • View Profile
Re: Javascript libraries in EAScriptLib
« Reply #2 on: July 19, 2020, 12:16:29 pm »
After checking where I'd put that JavaScript conversion I've found it again. Think I might have completed it after all but had forgotten all about it.
I've uploaded to GitHub so here are the URLs for the model and the reference data file if you want them.
https://github.com/EASunshine/Sparx-EA/blob/master/JavaScript.eapx
https://github.com/EASunshine/Sparx-EA/blob/master/JavaScript.xml
You can import the JavaScript.xml using import reference data

No warranties or support. Take them as is.
Happy to help
:)

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8085
  • Karma: +118/-20
    • View Profile
Re: Javascript libraries in EAScriptLib
« Reply #3 on: July 20, 2020, 08:30:20 am »
There currently isn't a separate import, but importing the Jscript library will have the same effect.

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1374
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Javascript libraries in EAScriptLib
« Reply #4 on: July 20, 2020, 09:45:30 pm »
Hi Sunshine,

Thanks, I retrieved the EAPx and started splitting the examples from the libs into 2 separate groups. I will try using the libraries and will send you an updated file if there's relevant additions or fix to include.

Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Sunshine

  • EA Practitioner
  • ***
  • Posts: 1324
  • Karma: +121/-10
  • Its the results that count
    • View Profile
Re: Javascript libraries in EAScriptLib
« Reply #5 on: July 21, 2020, 06:01:28 am »
Hi Sunshine,

Thanks, I retrieved the EAPx and started splitting the examples from the libs into 2 separate groups. I will try using the libraries and will send you an updated file if there's relevant additions or fix to include.

Yes that's a good move. I started off just doing the examples but discovered they had dependencies upon the library so as I came across dependencies I moved a script to JavaScript folder and converted it. In hindsight I should have just put them straight into a separate library but was doing it piecemeal between other work so wasn't thinking too much about it. Too much context switching.
Happy to help
:)

shimon

  • EA User
  • **
  • Posts: 167
  • Karma: +5/-0
    • View Profile
Re: Javascript libraries in EAScriptLib
« Reply #6 on: January 22, 2025, 02:18:24 am »
Hi,
Is there an updated eapx with the JavaScript examples?
Thanks,
Shimon