/**
* jspsych-same-different
* Josh de Leeuw
*
* plugin for showing two stimuli sequentially and getting a same / different judgment
*
* documentation: docs.jspsych.org
*
*/
jsPsych.plugins['same-different'] = (function() {
var plugin = {};
jsPsych.pluginAPI.registerPreload('same-different', 'stimuli', 'image',function(t){ return !t.is_html || t.is_html == 'undefined'});
plugin.info = {
name: 'same-different',
description: '',
parameters: {
stimuli: {
type: [jsPsych.plugins.parameterType.STRING],
default: undefined,
array: true,
no_function: false,
description: ''
},
is_html: {
type: [jsPsych.plugins.parameterType.BOOL],
default: false,
no_function: false,
description: ''
},
answer: {
type: [jsPsych.plugins.parameterType.SELECT],
options: ['same', 'different'],
default: 75,
no_function: false,
description: ''
},
same_key: {
type: [jsPsych.plugins.parameterType.KEYCODE],
default: 'Q',
no_function: false,
description: ''
},
different_key: {
type: [jsPsych.plugins.parameterType.KEYCODE],
default: 'P',
no_function: false,
description: ''
},
timing_first_stim: {
type: [jsPsych.plugins.parameterType.INT],
default: 1000,
no_function: false,
description: ''
},
timing_gap: {
type: [jsPsych.plugins.parameterType.INT],
default: 500,
no_function: false,
description: ''
},
timing_second_stim: {
type: [jsPsych.plugins.parameterType.INT],
default: 1000,
no_function: false,
description: ''
},
prompt: {
type: [jsPsych.plugins.parameterType.STRING],
default: '',
no_function: false,
description: ''
}
}
}
plugin.trial = function(display_element, trial) {
// default parameters
trial.same_key = trial.same_key || 81; // default is 'q'
trial.different_key = trial.different_key || 80; // default is 'p'
// timing parameters
trial.timing_first_stim = trial.timing_first_stim || 1000; // if -1, the first stim is shown until any key is pressed
trial.timing_second_stim = trial.timing_second_stim || 1000; // if -1, then second stim is shown until response.
trial.timing_gap = trial.timing_gap || 500;
// optional parameters
trial.is_html = (typeof trial.is_html === 'undefined') ? false : trial.is_html;
trial.prompt = (typeof trial.prompt === 'undefined') ? "" : trial.prompt;
// if any trial variables are functions
// this evaluates the function and replaces
// it with the output of the function
trial = jsPsych.pluginAPI.evaluateFunctionParameters(trial);
// show image
if (!trial.is_html) {
display_element.innerHTML = '';
} else {
display_element.innerHTML = '