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

Plugins now have a consistent internal structure, with better variable scoping. This version breaks backward compatibility due to a change in the syntax of how experiment objects are declared.
36 lines
847 B
JavaScript
Executable File
36 lines
847 B
JavaScript
Executable File
|
|
(function( $ ) {
|
|
$.fn.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); |