| Reference | Downloads | Github

Replicate online experiment

I am trying to replicate some experiments found online in the public pavlovia repository. When I download them and sync (making some minor changes), they do not work. I realized this is because the code-components are not populated for javascript. When I try the AutoJS option, it causes a lot of errors. For example, something as simple as checking whether an item is in the key pressed list doesn’t work as key_resp.keys.includes() is undefined for JS.

I tried to write my own JS, but simple functions like

function inArray(needle,haystack)
    var count=haystack.length;
    for(var i=0;i<count;i++)
        if(haystack[i]===needle){return true;}
    return false;

don’t work because ‘length’ is not recognized.

Can anyone help with 1. determining how to maintain JS code from cloned experiments,
2. understanding what version of javascript or what modules needs to be used to circumvent the issues if making my own code.


Hi @haaleemur, it will be helpful if you can provide a working URL with a simplified example of your study for debugging

hey @dvbridges ,

thanks for responding. It was actually a general question about cloning and forking studies from pavlovia. It seems like the JS code components are not there for them? Here is the one I tried

@haaleemur, it does not look like this user has any JS code in their PsychoPy task. If you want a digit span task, there is a demo digit span task made by the PsychoPy team

ah, how silly. I assumed if it’s posted online it must have JS.

Okay, thanks, i’ll adapt this one for my needs!

1 Like