How to share functions between inline_javascript
Hello everyone,
I am currently working on an online experiment that includes multiple inline_javascript and many long self-defined functions. I find it really painful to define those functions in every script. I found the 'persistent' object mentioned on the website (https://osdoc.cogsci.nl/3.3/manual/javascript/about/#available-javascript-libraries) which states that functions can be shared across different scripts (you could also see the picture below). However, I didn't find a specific example of how to implement this feature. I tried many times, but it didn't work.
Can anyone teach me how to achieve this functionality? Thank you very much for your help.
Comments
Hi @Siyang ,
Indeed, the lack of a persistent workspace was a serious limitation in OpenSesame 3.3 / OSWeb 1.4. However, in OpenSesame 4.0 / OSWeb 2.0, this has been resolved, so there is no longer a need to use the
persistentobject or other hacks to share objects across multipleinline_javascriptitems.OpenSesame 4.0 is not officially released yet, but it's already fairly stable, and if you're currently developing a new experiment it's probably worthwhile to do this in 4.0 already.
— Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!
Hi @sebastiaan,
Thank you so much for your reply! I will try it with OpenSesame 4.0 / OSWeb 2.0. I will post my subsequent progress. Hope everything goes fine.
Thanks again.
Siyang