/* jspsych-xab.js * Josh de Leeuw * * This plugin runs a single XAB trial, where X is an image presented in isolation, and A and B are choices, with A or B being equal to X. * The subject's goal is to identify whether A or B is identical to X. * * documentation: docs.jspsych.org * */ jsPsych.plugins['xab-html'] = (function() { var plugin = {}; plugin.info = { name: 'xab-html', description: '', parameters: { stimuli: { type: jsPsych.plugins.parameterType.HTML_STRING, pretty_name: 'Stimuli', array: true, default: undefined, description: 'Array of 2 or 3 paths to images.' }, left_key: { type: jsPsych.plugins.parameterType.KEYCODE, pretty_name: 'Left key', default: 'q', description: 'Which key the subject should press to indicate that the target is on the left side.' }, right_key: { type: jsPsych.plugins.parameterType.KEYCODE, pretty_name: 'Right key', default: 'p', description: 'Which key the subject should press to indicate that the target is on the right side.' }, prompt: { type: jsPsych.plugins.parameterType.STRING, pretty_name: 'Prompt', default: '', description: 'Any content here will be displayed below the stimulus.' }, x_duration: { type: jsPsych.plugins.parameterType.INT, pretty_name: 'X duration', default: 1000, description: 'How long to show the X stimulus for in milliseconds.' }, x_durationab_gap: { type: jsPsych.plugins.parameterType.INT, pretty_name: 'X durationab gap', default: 1000, description: 'How long to show a blank screen in between X and AB in milliseconds.' }, ab_duration: { type: jsPsych.plugins.parameterType.INT, pretty_name: 'AB duration', default: -1, description: 'How long to show A and B in milliseconds.' }, trial_duration: { type: jsPsych.plugins.parameterType.INT, pretty_name: 'Trial duration', default: -1, description: 'The maximum duration to wait for a response.' } } } plugin.trial = function(display_element, trial) { // unpack the stimuli array trial.x_path = trial.stimuli[0]; // if there is only a pair of stimuli, then the first is the target and is shown twice. // if there is a triplet, then the first is X, the second is the target, and the third is foil (useful for non-exact-match XAB). if (trial.stimuli.length == 2) { trial.a_path = trial.stimuli[0]; trial.b_path = trial.stimuli[1]; } else { trial.a_path = trial.stimuli[1]; trial.b_path = trial.stimuli[2]; } // how we display the content depends on whether the content is // HTML code or an image path. display_element.innerHTML = '