diff --git a/psychopy/experiment/components/settings/__init__.py b/psychopy/experiment/components/settings/__init__.py index 7a2054f31b..086c3a923d 100644 --- a/psychopy/experiment/components/settings/__init__.py +++ b/psychopy/experiment/components/settings/__init__.py @@ -789,7 +789,7 @@ def writeEndCode(self, buff): def writeEndCodeJS(self, buff): - endLoopInteration = ("\nfunction endLoopIteration(thisScheduler, thisTrial) {\n" + endLoopInteration = ("\nfunction endLoopIteration({thisScheduler, isTrials=true}) {\n" " // ------Prepare for next entry------\n" " return function () {\n" " // ------Check if user ended loop early------\n" @@ -799,7 +799,7 @@ def writeEndCodeJS(self, buff): " psychoJS.experiment.nextEntry();\n" " }\n" " thisScheduler.stop();\n" - " } else if (typeof thisTrial === 'undefined' || !('isTrials' in thisTrial) || thisTrial.isTrials) {\n" + " } else if (isTrials) {\n" " psychoJS.experiment.nextEntry();\n" " }\n" " return Scheduler.Event.NEXT;\n" diff --git a/psychopy/experiment/loops.py b/psychopy/experiment/loops.py index b988174ec4..b67c9c112f 100755 --- a/psychopy/experiment/loops.py +++ b/psychopy/experiment/loops.py @@ -255,14 +255,12 @@ def writeLoopStartCodeJS(self, buff, modular): " thisScheduler.add({name}LoopEnd);\n" .format(params=self.params, name=thisChild.params['name'].val) ) - if self.params['isTrials'].val == True: - code += (" thisScheduler.add(endLoopIteration(thisScheduler, " - "{thisName}));\n".format(thisName=self.thisName)) - code += (" }\n" - "\n" - " return Scheduler.Event.NEXT;\n" - "}\n") + code += (" thisScheduler.add(endLoopIteration({{thisScheduler, isTrials : {isTrials}}}));\n" + " }}\n" + "\n" + " return Scheduler.Event.NEXT;\n" + "}}\n").format(isTrials=str(self.params['isTrials'].val).lower()) buff.writeIndentedLines(code) def writeLoopEndCode(self, buff):