How can this Python-code become translatable to JS

I don’t think JS understands “with x as y”. Also, I don’t think your code will work online.

Have a look at my Moving Cue and Trial Switching online demos for how to load a spreadsheet in a code component online.