jsPsych/plugins/jspsych-call-function.js
2017-07-12 14:29:47 -04:00

49 lines
1.0 KiB
JavaScript

/**
* jspsych-call-function
* plugin for calling an arbitrary function during a jspsych experiment
* Josh de Leeuw
*
* documentation: docs.jspsych.org
*
**/
jsPsych.plugins['call-function'] = (function() {
var plugin = {};
plugin.info = {
name: 'call-function',
description: '',
parameters: {
func: {
type: jsPsych.plugins.parameterType.FUNCTION,
default: undefined,
no_function: false,
description: ''
},
// a rare case where we override the default experiment level
// value of this parameter, since this plugin should be invisible
// to the subject of the experiment
post_trial_gap: {
type: jsPsych.plugins.parameterType.INT,
default: 0,
no_function: false,
description: ''
}
}
}
plugin.trial = function(display_element, trial) {
var return_val = trial.func();
var trial_data = {
value: return_val
};
jsPsych.finishTrial(trial_data);
};
return plugin;
})();