[Pas2js] Improved JS-Object to class demo

Michael Van Canneyt michael at freepascal.org
Fri May 8 14:48:48 CEST 2020


Hello,

I have improved the Javascript Object-to-Pascal class demo somewhat.

It no longer requires you to recompile the demo, everything can be done
dynamically.

Check it out:

https://www.freepascal.org/~michael/pas2js-demos/genclass/

You can load scripts dynamically 
(every URL you type can be loaded with "Load Script");

You can give: 
- a path to an object instance (relative to the window instance).
- a pascal class name for the new external definition.
- an external name for the new external definition.
- the parent name for the new external class (by default TJSObject)

When you hit 'Create class', a skeleton pascal code will be generated for you.

For instance, load the following script:

https://uselooper.com/assets/javascript/theme.min.js

Then enter
Object path: Looper
Pascal external class name: Theme
Pascal Class Name : TJSLooper

Hit "Create class" and observe your new external class definition...
The code is of course not perfect, but will help you getting started.

Code is obviously committed in the demos. Suggestions for improvements welcome.

Enjoy !

Michael.


More information about the Pas2js mailing list