From 3eba68c20e7d21c91f3fdef6012dbc95ebbf5996 Mon Sep 17 00:00:00 2001 From: Josh de Leeuw Date: Thu, 29 Jan 2015 19:57:07 -0500 Subject: [PATCH] fix function as stimuli parameter issue issue #109 --- plugins/jspsych-same-different.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/jspsych-same-different.js b/plugins/jspsych-same-different.js index a39b73af..c23adba5 100644 --- a/plugins/jspsych-same-different.js +++ b/plugins/jspsych-same-different.js @@ -19,8 +19,7 @@ var trials = new Array(params.stimuli.length); for (var i = 0; i < trials.length; i++) { trials[i] = {}; - trials[i].a_path = params.stimuli[i][0]; - trials[i].b_path = params.stimuli[i][1]; + trials[i].stimuli = params.stimuli[i]; trials[i].answer = params.answer[i]; trials[i].same_key = params.same_key || 81; // default is 'q' trials[i].different_key = params.different_key || 80; // default is 'p' @@ -41,7 +40,11 @@ // this evaluates the function and replaces // it with the output of the function trial = jsPsych.pluginAPI.normalizeTrialVariables(trial); - + + // unpack the stimuli array (for backwards code compatibility. this could be cleaned up in the future) + trial.a_path = trial.stimuli[0]; + trial.b_path = trial.stimuli[1]; + // this array holds handlers from setTimeout calls // that need to be cleared if the trial ends early var setTimeoutHandlers = [];