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

The top level object is jsPsych, and plugins are defined as jsPsych.PLUGIN. The library also loads everything dynamically now, so the user only needs to load the main jsPsych script (and specify the src for any plugins). This also changes how the library is loaded initially, since it is not based on the jQuery method anymore. See wiki.
36 lines
842 B
JavaScript
Executable File
36 lines
842 B
JavaScript
Executable File
|
|
(function( $ ) {
|
|
jsPsych.text = (function(){
|
|
|
|
var plugin = {};
|
|
|
|
plugin.create = function(params) {
|
|
var trials = new Array(params.text.length);
|
|
for(var i = 0; i < trials.length; i++)
|
|
{
|
|
trials[i] = {};
|
|
trials[i]["type"] = "text";
|
|
trials[i]["text"] = params.text[i];
|
|
trials[i]["cont_key"] = params.cont_key;
|
|
trials[i]["timing"] = params.timing;
|
|
}
|
|
return trials;
|
|
}
|
|
|
|
plugin.trial = function($this, block, trial, part) {
|
|
$this.html(trial.text);
|
|
var key_listener = function(e) {
|
|
if(e.which==trial.cont_key)
|
|
{
|
|
flag = true;
|
|
$(document).unbind('keyup',key_listener);
|
|
$this.html('');
|
|
setTimeout(function(){block.next();}, trial.timing[0]);
|
|
}
|
|
}
|
|
$(document).keyup(key_listener);
|
|
}
|
|
|
|
return plugin;
|
|
})();
|
|
}) (jQuery); |