Reworking the plugin structure to use the Module javascript design pattern.

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.
This commit is contained in:
Josh de Leeuw 2012-05-15 16:03:26 -04:00
parent 9c8884f356
commit 9c94b4d0b6
7 changed files with 472 additions and 422 deletions

View File

@ -5,113 +5,121 @@
// option to keep stim on screen during feedback // option to keep stim on screen during feedback
// way to provide corrective feedback // way to provide corrective feedback
function cf_create(params) (function( $ ) {
{ $.fn.jsPsych.categorize-feedback = (function(){
cf_stims = params["stimuli"];
trials = new Array(cf_stims.length); var plugin = {};
for(var i = 0; i < trials.length; i++)
{ plugin.create = function(params) {
trials[i] = {}; cf_stims = params["stimuli"];
trials[i]["type"] = "cf"; trials = new Array(cf_stims.length);
trials[i]["a_path"] = cf_stims[i]; for(var i = 0; i < trials.length; i++)
trials[i]["timing"] = params["timing"]; {
trials[i]["key_answer"] = params["key_answer"][i]; trials[i] = {};
trials[i]["text_answer"] = params["text_answer"][i]; trials[i]["type"] = "cf";
trials[i]["choices"] = params["choices"]; trials[i]["a_path"] = cf_stims[i];
trials[i]["correct_text"] = params["correct_text"]; trials[i]["timing"] = params["timing"];
trials[i]["incorrect_text"] = params["incorrect_text"]; trials[i]["key_answer"] = params["key_answer"][i];
trials[i]["show_stim_feedback"] = params["show_stim_feedback"]; trials[i]["text_answer"] = params["text_answer"][i];
if(params["prompt"] != undefined){ trials[i]["choices"] = params["choices"];
trials[i]["prompt"] = params["prompt"]; trials[i]["correct_text"] = params["correct_text"];
trials[i]["incorrect_text"] = params["incorrect_text"];
trials[i]["show_stim_feedback"] = params["show_stim_feedback"];
if(params["prompt"] != undefined){
trials[i]["prompt"] = params["prompt"];
}
if(params["data"]!=undefined){
trials[i]["data"] = params["data"][i];
}
}
return trials;
} }
if(params["data"]!=undefined){
trials[i]["data"] = params["data"][i];
}
}
return trials;
}
function cf_trial($this, block, trial, part) plugin.trial = function($this, block, trial, part)
{ {
switch(part){ switch(part){
case 1: case 1:
p1_time = (new Date()).getTime(); p1_time = (new Date()).getTime();
$this.append($('<img>', { $this.append($('<img>', {
"src": trial.a_path, "src": trial.a_path,
"class": 'cf' "class": 'cf'
})); }));
if(trial.timing[2]!=undefined){ if(trial.timing[2]!=undefined){
setTimeout(function(){cf_trial($this, block, trial, part + 1);}, trial.timing[2]); setTimeout(function(){cf_trial($this, block, trial, part + 1);}, trial.timing[2]);
} else { } else {
//show prompt here //show prompt here
$this.append(trial.prompt); $this.append(trial.prompt);
cf_trial($this, block, trial, part + 1); cf_trial($this, block, trial, part + 1);
} }
break; break;
case 2: case 2:
p2_time = (new Date()).getTime(); p2_time = (new Date()).getTime();
if(trial.timing[2]!=undefined){ if(trial.timing[2]!=undefined){
$('.cf').remove(); $('.cf').remove();
$this.append(trial.prompt); $this.append(trial.prompt);
} }
startTime = (new Date()).getTime(); startTime = (new Date()).getTime();
var resp_func = function(e) { var resp_func = function(e) {
var flag = false; var flag = false;
var correct = false; var correct = false;
if(e.which==trial.key_answer) // correct category if(e.which==trial.key_answer) // correct category
{ {
flag = true;
correct = true;
}
else
{
// check if the key is any of the options, or if it is an accidental keystroke
for(var i=0;i<trial.choices.length;i++)
{
if(e.which==trial.choices[i])
{
flag = true; flag = true;
correct = false; correct = true;
}
else
{
// check if the key is any of the options, or if it is an accidental keystroke
for(var i=0;i<trial.choices.length;i++)
{
if(e.which==trial.choices[i])
{
flag = true;
correct = false;
}
}
}
if(flag)
{
endTime = (new Date()).getTime();
rt = (endTime-startTime);
stim1_time = (p2_time-p1_time);
var trial_data = {"rt": rt, "correct": correct, "a_path": trial.a_path, "key_press": e.which, "stim1_time": stim1_time}
block.data[block.trial_idx] = $.extend({},trial_data,trial.data);
$(document).unbind('keyup',resp_func);
$this.html('');
cf_trial($this, block, trial, part + 1);
} }
} }
} $(document).keyup(resp_func);
if(flag) break;
{ case 3:
endTime = (new Date()).getTime(); if(trial.show_stim_feedback)
rt = (endTime-startTime); {
stim1_time = (p2_time-p1_time); $this.append($('<img>', {
var trial_data = {"rt": rt, "correct": correct, "a_path": trial.a_path, "key_press": e.which, "stim1_time": stim1_time} "src": trial.a_path,
block.data[block.trial_idx] = $.extend({},trial_data,trial.data); "class": 'cf'
$(document).unbind('keyup',resp_func); }));
$this.html(''); }
cf_trial($this, block, trial, part + 1); // give feedback
} var atext = "";
if(block.data[block.trial_idx]["correct"])
{
atext = trial.correct_text.replace("&ANS&", trial.text_answer);
} else {
atext = trial.incorrect_text.replace("&ANS&", trial.text_answer);
}
$this.append(atext);
setTimeout(function(){cf_trial($this, block, trial, part + 1);}, trial.timing[0]);
break;
case 4:
$this.html("");
setTimeout(function(){block.next();}, trial.timing[1]);
break;
} }
$(document).keyup(resp_func); }
break;
case 3: return plugin;
if(trial.show_stim_feedback) })();
{ })(jQuery);
$this.append($('<img>', {
"src": trial.a_path,
"class": 'cf'
}));
}
// give feedback
var atext = "";
if(block.data[block.trial_idx]["correct"])
{
atext = trial.correct_text.replace("&ANS&", trial.text_answer);
} else {
atext = trial.incorrect_text.replace("&ANS&", trial.text_answer);
}
$this.append(atext);
setTimeout(function(){cf_trial($this, block, trial, part + 1);}, trial.timing[0]);
break;
case 4:
$this.html("");
setTimeout(function(){block.next();}, trial.timing[1]);
break;
}
}

View File

@ -1,75 +1,83 @@
// timing parameters: [intertrial gap, optional length to display target] // timing parameters: [intertrial gap, optional length to display target]
// if optional length to display target is missing, then target is displayed until subject responds. // if optional length to display target is missing, then target is displayed until subject responds.
function cu_create(params) (function( $ ) {
{ $.fn.jsPsych.categorize-unknown = (function(){
cu_stims = params["stimuli"];
trials = new Array(cu_stims.length); var plugin = {};
for(var i = 0; i < trials.length; i++)
{ plugin.create = function(params) {
trials[i] = {}; cu_stims = params["stimuli"];
trials[i]["type"] = "cu"; trials = new Array(cu_stims.length);
trials[i]["a_path"] = cu_stims[i]; for(var i = 0; i < trials.length; i++)
trials[i]["timing"] = params["timing"]; {
trials[i]["choices"] = params["choices"]; trials[i] = {};
if(params["prompt"] != undefined){ trials[i]["type"] = "cu";
trials[i]["prompt"] = params["prompt"]; trials[i]["a_path"] = cu_stims[i];
trials[i]["timing"] = params["timing"];
trials[i]["choices"] = params["choices"];
if(params["prompt"] != undefined){
trials[i]["prompt"] = params["prompt"];
}
if(params["data"]!=undefined){
trials[i]["data"] = params["data"][i];
}
}
return trials;
} }
if(params["data"]!=undefined){
trials[i]["data"] = params["data"][i];
}
}
return trials;
}
function cu_trial($this, block, trial, part) plugin.trial = function($this, block, trial, part)
{ {
switch(part){ switch(part){
case 1: case 1:
p1_time = (new Date()).getTime(); p1_time = (new Date()).getTime();
$this.append($('<img>', { $this.append($('<img>', {
"src": trial.a_path, "src": trial.a_path,
"class": 'cu' "class": 'cu'
})); }));
if(trial.timing[1]!=undefined){ if(trial.timing[1]!=undefined){
setTimeout(function(){cu_trial($this, block, trial, part + 1);}, trial.timing[1]); setTimeout(function(){cu_trial($this, block, trial, part + 1);}, trial.timing[1]);
} else { } else {
//show prompt here //show prompt here
$this.append(trial.prompt); $this.append(trial.prompt);
cu_trial($this, block, trial, part + 1); cu_trial($this, block, trial, part + 1);
}
break;
case 2:
p2_time = (new Date()).getTime();
if(trial.timing[1]!=undefined){
$('.cu').remove();
$this.append(trial.prompt);
}
startTime = (new Date()).getTime();
var resp_func = function(e) {
var flag = false;
// check if the key is any of the options, or if it is an accidental keystroke
for(var i=0;i<trial.choices.length;i++)
{
if(e.which==trial.choices[i])
{
flag = true;
} }
} break;
if(flag) case 2:
{ p2_time = (new Date()).getTime();
endTime = (new Date()).getTime(); if(trial.timing[1]!=undefined){
rt = (endTime-startTime); $('.cu').remove();
stim1_time = (p2_time-p1_time); $this.append(trial.prompt);
var trial_data = {"rt": rt, "a_path": trial.a_path, "key_press": e.which, "stim1_time": stim1_time} }
block.data[block.trial_idx] = $.extend({},trial_data,trial.data); startTime = (new Date()).getTime();
$(document).unbind('keyup',resp_func); var resp_func = function(e) {
$this.html(''); var flag = false;
setTimeout(function(){block.next();}, trial.timing[0]); // check if the key is any of the options, or if it is an accidental keystroke
} for(var i=0;i<trial.choices.length;i++)
{
if(e.which==trial.choices[i])
{
flag = true;
}
}
if(flag)
{
endTime = (new Date()).getTime();
rt = (endTime-startTime);
stim1_time = (p2_time-p1_time);
var trial_data = {"rt": rt, "a_path": trial.a_path, "key_press": e.which, "stim1_time": stim1_time}
block.data[block.trial_idx] = $.extend({},trial_data,trial.data);
$(document).unbind('keyup',resp_func);
$this.html('');
setTimeout(function(){block.next();}, trial.timing[0]);
}
}
$(document).keyup(resp_func);
break;
} }
$(document).keyup(resp_func); }
break;
} return plugin;
} })();
})(jQuery);

View File

@ -1,89 +1,97 @@
function sd_create(params) (function( $ ) {
{ $.fn.jsPsych.samedifferent = (function(){
sd_stims = params["stimuli"];
trials = new Array(sd_stims.length);
for(var i = 0; i < trials.length; i++)
{
trials[i] = {};
trials[i]["type"] = "sd";
trials[i]["a_path"] = sd_stims[i][0];
trials[i]["b_path"] = sd_stims[i][1];
trials[i]["timing"] = params["timing"];
trials[i]["answer"] = params["answer"][i];
if(params["prompt"] != undefined){
trials[i]["prompt"] = params["prompt"];
}
if(params["data"]!=undefined){
trials[i]["data"] = params["data"][i];
}
}
return trials;
}
function sd_trial($this, block, trial, part) var plugin = {};
{
switch(part){ plugin.create = function(params) {
case 1: sd_stims = params["stimuli"];
p1_time = (new Date()).getTime(); trials = new Array(sd_stims.length);
$this.append($('<img>', { for(var i = 0; i < trials.length; i++)
"src": trial.a_path, {
"class": 'sd' trials[i] = {};
})); trials[i]["type"] = "sd";
setTimeout(function(){sd_trial($this, block, trial, part + 1);}, trial.timing[0]); trials[i]["a_path"] = sd_stims[i][0];
break; trials[i]["b_path"] = sd_stims[i][1];
case 2: trials[i]["timing"] = params["timing"];
p2_time = (new Date()).getTime(); trials[i]["answer"] = params["answer"][i];
$('.sd').remove(); if(params["prompt"] != undefined){
setTimeout(function(){sd_trial($this, block, trial, part + 1);}, trial.timing[1]); trials[i]["prompt"] = params["prompt"];
break;
case 3:
p3_time = (new Date()).getTime();
$this.append($('<img>', {
"src": trial.b_path,
"class": 'sd'
}));
if(trial.timing[3]!=undefined){
setTimeout(function(){sd_trial($this, block, trial, part + 1);}, trial.timing[3]);
} else {
sd_trial($this, block, trial, part + 1);
}
break;
case 4:
p4_time = (new Date()).getTime();
if(trial.timing[3]!=undefined){
$('.sd').remove();
$this.html(trial.prompt);
}
startTime = (new Date()).getTime();
var resp_func = function(e) {
var flag = false;
var correct = false;
if(e.which=='80') // 'p' key -- same
{
flag = true;
if(trial.answer == "same") { correct = true; }
} else if(e.which=='81') // 'q' key -- different
{
flag = true;
if(trial.answer == "different"){ correct = true; }
} }
if(flag) if(params["data"]!=undefined){
{ trials[i]["data"] = params["data"][i];
endTime = (new Date()).getTime(); }
rt = (endTime-startTime); }
stim1_time = (p2_time-p1_time); return trials;
isi_time = (p3_time-p2_time); }
stim2_time = (p4_time-p3_time);
var trial_data = {"rt": rt, "correct": correct, "a_path": trial.a_path, "b_path": trial.b_path, "key_press": e.which, "stim1_time": stim1_time, "stim2_time":stim2_time, "isi_time":isi_time} plugin.trial = function($this, block, trial, part)
block.data[block.trial_idx] = $.extend({},trial_data,trial.data); {
$(document).unbind('keyup',resp_func); switch(part){
case 1:
p1_time = (new Date()).getTime();
$this.append($('<img>', {
"src": trial.a_path,
"class": 'sd'
}));
setTimeout(function(){sd_trial($this, block, trial, part + 1);}, trial.timing[0]);
break;
case 2:
p2_time = (new Date()).getTime();
$('.sd').remove(); $('.sd').remove();
$this.html(''); setTimeout(function(){sd_trial($this, block, trial, part + 1);}, trial.timing[1]);
setTimeout(function(){block.next();}, trial.timing[2]); break;
} case 3:
p3_time = (new Date()).getTime();
$this.append($('<img>', {
"src": trial.b_path,
"class": 'sd'
}));
if(trial.timing[3]!=undefined){
setTimeout(function(){sd_trial($this, block, trial, part + 1);}, trial.timing[3]);
} else {
sd_trial($this, block, trial, part + 1);
}
break;
case 4:
p4_time = (new Date()).getTime();
if(trial.timing[3]!=undefined){
$('.sd').remove();
$this.html(trial.prompt);
}
startTime = (new Date()).getTime();
var resp_func = function(e) {
var flag = false;
var correct = false;
if(e.which=='80') // 'p' key -- same
{
flag = true;
if(trial.answer == "same") { correct = true; }
} else if(e.which=='81') // 'q' key -- different
{
flag = true;
if(trial.answer == "different"){ correct = true; }
}
if(flag)
{
endTime = (new Date()).getTime();
rt = (endTime-startTime);
stim1_time = (p2_time-p1_time);
isi_time = (p3_time-p2_time);
stim2_time = (p4_time-p3_time);
var trial_data = {"rt": rt, "correct": correct, "a_path": trial.a_path, "b_path": trial.b_path, "key_press": e.which, "stim1_time": stim1_time, "stim2_time":stim2_time, "isi_time":isi_time}
block.data[block.trial_idx] = $.extend({},trial_data,trial.data);
$(document).unbind('keyup',resp_func);
$('.sd').remove();
$this.html('');
setTimeout(function(){block.next();}, trial.timing[2]);
}
}
$(document).keyup(resp_func);
break;
} }
$(document).keyup(resp_func); }
break;
} return plugin;
} })();
}) (jQuery);

View File

@ -1,60 +1,68 @@
function similarity_create(params) (function( $ ) {
{ $.fn.jsPsych.text = (function(){
sim_stims = params["stimuli"];
trials = new Array(sim_stims.length); var plugin = {};
for(var i = 0; i < trials.length; i++)
{ plugin.create = function(params) {
trials[i] = {}; sim_stims = params["stimuli"];
trials[i]["type"] = "sim"; trials = new Array(sim_stims.length);
trials[i]["a_path"] = sim_stims[i][0]; for(var i = 0; i < trials.length; i++)
trials[i]["b_path"] = sim_stims[i][1]; {
trials[i]["timing"] = params["timing"]; trials[i] = {};
} trials[i]["type"] = "sim";
return trials; trials[i]["a_path"] = sim_stims[i][0];
} trials[i]["b_path"] = sim_stims[i][1];
trials[i]["timing"] = params["timing"];
function similarity_trial($this, block, trial, part)
{
switch(part){
case 1:
images = [trial.a_path, trial.b_path];
if(Math.floor(Math.random()*2)==0){
images = [trial.b_path, trial.a_path];
} }
// show the images return trials;
$this.append($('<img>', { }
"src": images[0],
"class": 'sim'
}));
$this.append($('<img>', {
"src": images[1],
"class": 'sim'
}));
// create slider plugin.trial = function($this, block, trial, part)
$this.append($('<div>', { "id": 'slider', "class": 'sim' })); {
$("#slider").slider( switch(part){
{ case 1:
value:50, images = [trial.a_path, trial.b_path];
min:0, if(Math.floor(Math.random()*2)==0){
max:100, images = [trial.b_path, trial.a_path];
step:1, }
}); // show the images
$this.append($('<img>', {
// create button "src": images[0],
$this.append($('<button>', {'id':'next','class':'sim'})); "class": 'sim'
$("#next").html('Next'); }));
$("#next").click(function(){ $this.append($('<img>', {
similarity_trial($this,block,trial,part+1); "src": images[1],
}); "class": 'sim'
break; }));
case 2:
// get data // create slider
var score = $("#slider").slider("value"); $this.append($('<div>', { "id": 'slider', "class": 'sim' }));
block.data[block.trial_idx] = {"score": score, "a_path": trial.a_path, "b_path": trial.b_path} $("#slider").slider(
// goto next trial in block {
$('.sim').remove(); value:50,
setTimeout(function(){block.next();}, trial.timing[0]); min:0,
break; max:100,
} step:1,
} });
// create button
$this.append($('<button>', {'id':'next','class':'sim'}));
$("#next").html('Next');
$("#next").click(function(){
similarity_trial($this,block,trial,part+1);
});
break;
case 2:
// get data
var score = $("#slider").slider("value");
block.data[block.trial_idx] = {"score": score, "a_path": trial.a_path, "b_path": trial.b_path}
// goto next trial in block
$('.sim').remove();
setTimeout(function(){block.next();}, trial.timing[0]);
break;
}
}
return plugin;
})();
})(jQuery);

View File

@ -1,28 +1,36 @@
function text_create(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;
}
function text_trial($this, block, trial, part) (function( $ ) {
{ $.fn.jsPsych.text = (function(){
$this.html(trial.text);
var key_listener = function(e) { var plugin = {};
if(e.which==trial.cont_key)
{ plugin.create = function(params) {
flag = true; var trials = new Array(params.text.length);
$(document).unbind('keyup',key_listener); for(var i = 0; i < trials.length; i++)
$this.html(''); {
setTimeout(function(){block.next();}, trial.timing[0]); 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;
} }
}
$(document).keyup(key_listener); 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);

View File

@ -1,86 +1,96 @@
function xab_create(params)
{
//xab_stims = shuffle(xab_stims);
xab_stims = params["stimuli"];
trials = new Array(xab_stims.length);
for(var i = 0; i < trials.length; i++)
{
trials[i] = {};
trials[i]["type"] = "xab";
trials[i]["a_path"] = xab_stims[i][0];
trials[i]["b_path"] = xab_stims[i][1];
trials[i]["timing"] = params["timing"];
if(params["data"]!=undefined){
trials[i]["data"] = params["data"][i];
}
}
return trials;
}
function xab_trial($this, block, trial, part) (function( $ ) {
{ $.fn.jsPsych.xab = (function(){
switch(part){
case 1: var plugin = {}
p1_time = (new Date()).getTime();
$this.append($('<img>', { plugin.create = function(params)
"src": trial.a_path, {
"class": 'xab' //xab_stims = shuffle(xab_stims);
})); xab_stims = params["stimuli"];
setTimeout(function(){xab_trial($this, block, trial, part + 1)}, trial.timing[0]); trials = new Array(xab_stims.length);
break; for(var i = 0; i < trials.length; i++)
case 2: {
p2_time = (new Date()).getTime(); trials[i] = {};
$('.xab').remove(); trials[i]["type"] = "xab";
setTimeout(function(){xab_trial($this, block, trial, part + 1)}, trial.timing[1]); trials[i]["a_path"] = xab_stims[i][0];
break; trials[i]["b_path"] = xab_stims[i][1];
case 3: trials[i]["timing"] = params["timing"];
p3_time = (new Date()).getTime(); if(params["data"]!=undefined){
startTime = (new Date()).getTime(); trials[i]["data"] = params["data"][i];
var images = [trial.a_path, trial.b_path];
var target_left = (Math.floor(Math.random()*2)==0); // binary true/false choice
if(!target_left){
images = [trial.b_path, trial.a_path];
}
// show the images
$this.append($('<img>', {
"src": images[0],
"class": 'xab'
}));
$this.append($('<img>', {
"src": images[1],
"class": 'xab'
}));
var resp_func = function(e) {
var flag = false;
var correct = false;
if(e.which=='80') // 'p' key
{
flag = true;
if(!target_left) { correct = true; }
} else if(e.which=='81') // 'q' key
{
flag = true;
if(target_left){ correct = true; }
} }
if(flag) }
{ return trials;
endTime = (new Date()).getTime(); }
rt = (endTime-startTime);
stim1_time = (p2_time-p1_time); plugin.trial = function($this, block, trial, part)
isi_time = (p3_time-p2_time); {
var trial_data = {"rt": rt, "correct": correct, "a_path": trial.a_path, "b_path": trial.b_path, "key_press": e.which, "key_press": e.which, "stim1_time": stim1_time, "isi_time":isi_time} switch(part){
block.data[block.trial_idx] = $.extend({},trial_data,trial.data); case 1:
$(document).unbind('keyup',resp_func); p1_time = (new Date()).getTime();
$this.append($('<img>', {
"src": trial.a_path,
"class": 'xab'
}));
setTimeout(function(){xab_trial($this, block, trial, part + 1)}, trial.timing[0]);
break;
case 2:
p2_time = (new Date()).getTime();
$('.xab').remove(); $('.xab').remove();
setTimeout(function(){block.next();}, trial.timing[2]); setTimeout(function(){xab_trial($this, block, trial, part + 1)}, trial.timing[1]);
} break;
case 3:
p3_time = (new Date()).getTime();
startTime = (new Date()).getTime();
var images = [trial.a_path, trial.b_path];
var target_left = (Math.floor(Math.random()*2)==0); // binary true/false choice
if(!target_left){
images = [trial.b_path, trial.a_path];
}
// show the images
$this.append($('<img>', {
"src": images[0],
"class": 'xab'
}));
$this.append($('<img>', {
"src": images[1],
"class": 'xab'
}));
var resp_func = function(e) {
var flag = false;
var correct = false;
if(e.which=='80') // 'p' key
{
flag = true;
if(!target_left) { correct = true; }
} else if(e.which=='81') // 'q' key
{
flag = true;
if(target_left){ correct = true; }
}
if(flag)
{
endTime = (new Date()).getTime();
rt = (endTime-startTime);
stim1_time = (p2_time-p1_time);
isi_time = (p3_time-p2_time);
var trial_data = {"rt": rt, "correct": correct, "a_path": trial.a_path, "b_path": trial.b_path, "key_press": e.which, "key_press": e.which, "stim1_time": stim1_time, "isi_time":isi_time}
block.data[block.trial_idx] = $.extend({},trial_data,trial.data);
$(document).unbind('keyup',resp_func);
$('.xab').remove();
setTimeout(function(){block.next();}, trial.timing[2]);
}
}
$(document).keyup(resp_func);
//TODO: CHECK IF IMAGE SHOULD DISAPPEAR
//based on timings
break;
} }
$(document).keyup(resp_func); }
//TODO: CHECK IF IMAGE SHOULD DISAPPEAR
//based on timings return plugin;
break; })();
} })(jQuery);
}

View File

@ -25,7 +25,7 @@
{ {
if(opts["experiment_structure"][i]["type"] == opts["plugins"][j]["type"]) if(opts["experiment_structure"][i]["type"] == opts["plugins"][j]["type"])
{ {
trials = opts["plugins"][j]["createFunc"].call(null, opts["experiment_structure"][i]); trials = opts["plugins"][j]["src"]["create"].call(null, opts["experiment_structure"][i]);
} }
} }
@ -94,7 +94,7 @@
{ {
if(trial.type == opts["plugins"][j]["type"]) if(trial.type == opts["plugins"][j]["type"])
{ {
opts["plugins"][j]["trialFunc"].call(this, $this, block, trial, 1); opts["plugins"][j]["src"]["trial"].call(this, $this, block, trial, 1);
} }
} }
} }