mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00

jspsych-similarity.js : fixed data storage so that generic data object was included in the block's data. jspsych-storybook.js: included generic data object in data storage, included path to image in data storage. jspsych.js: cosmetic adjustment to code in finishExperiment() method. NEW: added call-function plugin, which calls a user-specified function. useful for saving data before completion. added paint plugin - displays a canvas element superimposed on an image and allows subjects to draw on the image to indicate areas of interest.
40 lines
884 B
JavaScript
40 lines
884 B
JavaScript
/** July 2012. Josh de Leeuw
|
|
|
|
This plugin gives the user the ability to execute an arbitrary function
|
|
during an experiment. It can be used to save data in the middle of an
|
|
experiment, for example.
|
|
|
|
Params:
|
|
"type" is "call_function"
|
|
"func" is the function that will be called
|
|
"args" is an array of arguments to pass to the function. (optional)
|
|
|
|
Data:
|
|
The return value of the function will be stored in the data.
|
|
**/
|
|
|
|
(function( $ ) {
|
|
jsPsych.call_function = (function(){
|
|
|
|
var plugin = {};
|
|
|
|
plugin.create = function(params) {
|
|
var trials = new Array(1);
|
|
trials[0] = {
|
|
"type": "call_function",
|
|
"func": params["func"],
|
|
"args": params["args"] || []
|
|
}
|
|
}
|
|
|
|
plugin.trial = function($this, block, trial, part)
|
|
{
|
|
block.data[block.trial_idx] = trial.func.apply({}, trial.args);
|
|
|
|
block.next();
|
|
}
|
|
|
|
|
|
return plugin;
|
|
})();
|
|
})(jQuery); |