forked from jspsych/jsPsych
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjspsych-call-function.js
44 lines (35 loc) · 981 Bytes
/
jspsych-call-function.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* 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: ''
}
}
}
plugin.trial = function(display_element, trial) {
// 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
trial.timing_post_trial = typeof trial.timing_post_trial == 'undefined' ? 0 : trial.timing_post_trial
var return_val = trial.func();
var trial_data = {
value: return_val
};
jsPsych.finishTrial(trial_data);
};
return plugin;
})();