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
// way to provide corrective feedback
function cf_create(params)
{
cf_stims = params["stimuli"];
trials = new Array(cf_stims.length);
for(var i = 0; i < trials.length; i++)
{
trials[i] = {};
trials[i]["type"] = "cf";
trials[i]["a_path"] = cf_stims[i];
trials[i]["timing"] = params["timing"];
trials[i]["key_answer"] = params["key_answer"][i];
trials[i]["text_answer"] = params["text_answer"][i];
trials[i]["choices"] = params["choices"];
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;
}
(function( $ ) {
$.fn.jsPsych.categorize-feedback = (function(){
function cf_trial($this, block, trial, part)
{
switch(part){
case 1:
p1_time = (new Date()).getTime();
$this.append($('<img>', {
"src": trial.a_path,
"class": 'cf'
}));
if(trial.timing[2]!=undefined){
setTimeout(function(){cf_trial($this, block, trial, part + 1);}, trial.timing[2]);
} else {
//show prompt here
$this.append(trial.prompt);
cf_trial($this, block, trial, part + 1);
}
break;
case 2:
p2_time = (new Date()).getTime();
if(trial.timing[2]!=undefined){
$('.cf').remove();
$this.append(trial.prompt);
}
startTime = (new Date()).getTime();
var resp_func = function(e) {
var flag = false;
var correct = false;
if(e.which==trial.key_answer) // correct category
{
flag = true;
correct = true;
var plugin = {};
plugin.create = function(params) {
cf_stims = params["stimuli"];
trials = new Array(cf_stims.length);
for(var i = 0; i < trials.length; i++)
{
trials[i] = {};
trials[i]["type"] = "cf";
trials[i]["a_path"] = cf_stims[i];
trials[i]["timing"] = params["timing"];
trials[i]["key_answer"] = params["key_answer"][i];
trials[i]["text_answer"] = params["text_answer"][i];
trials[i]["choices"] = params["choices"];
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"];
}
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])
if(params["data"]!=undefined){
trials[i]["data"] = params["data"][i];
}
}
return trials;
}
plugin.trial = function($this, block, trial, part)
{
switch(part){
case 1:
p1_time = (new Date()).getTime();
$this.append($('<img>', {
"src": trial.a_path,
"class": 'cf'
}));
if(trial.timing[2]!=undefined){
setTimeout(function(){cf_trial($this, block, trial, part + 1);}, trial.timing[2]);
} else {
//show prompt here
$this.append(trial.prompt);
cf_trial($this, block, trial, part + 1);
}
break;
case 2:
p2_time = (new Date()).getTime();
if(trial.timing[2]!=undefined){
$('.cf').remove();
$this.append(trial.prompt);
}
startTime = (new Date()).getTime();
var resp_func = function(e) {
var flag = false;
var correct = false;
if(e.which==trial.key_answer) // correct category
{
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);
}
}
}
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);
break;
case 3:
if(trial.show_stim_feedback)
{
$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;
}
$(document).keyup(resp_func);
break;
case 3:
if(trial.show_stim_feedback)
{
$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;
}
}
}
return plugin;
})();
})(jQuery);

View File

@ -1,75 +1,83 @@
// timing parameters: [intertrial gap, optional length to display target]
// if optional length to display target is missing, then target is displayed until subject responds.
function cu_create(params)
{
cu_stims = params["stimuli"];
trials = new Array(cu_stims.length);
for(var i = 0; i < trials.length; i++)
{
trials[i] = {};
trials[i]["type"] = "cu";
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;
}
(function( $ ) {
$.fn.jsPsych.categorize-unknown = (function(){
function cu_trial($this, block, trial, part)
{
switch(part){
case 1:
p1_time = (new Date()).getTime();
$this.append($('<img>', {
"src": trial.a_path,
"class": 'cu'
}));
if(trial.timing[1]!=undefined){
setTimeout(function(){cu_trial($this, block, trial, part + 1);}, trial.timing[1]);
} else {
//show prompt here
$this.append(trial.prompt);
cu_trial($this, block, trial, part + 1);
var plugin = {};
plugin.create = function(params) {
cu_stims = params["stimuli"];
trials = new Array(cu_stims.length);
for(var i = 0; i < trials.length; i++)
{
trials[i] = {};
trials[i]["type"] = "cu";
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];
}
}
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;
return trials;
}
plugin.trial = function($this, block, trial, part)
{
switch(part){
case 1:
p1_time = (new Date()).getTime();
$this.append($('<img>', {
"src": trial.a_path,
"class": 'cu'
}));
if(trial.timing[1]!=undefined){
setTimeout(function(){cu_trial($this, block, trial, part + 1);}, trial.timing[1]);
} else {
//show prompt here
$this.append(trial.prompt);
cu_trial($this, block, trial, part + 1);
}
}
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]);
}
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;
}
}
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)
{
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( $ ) {
$.fn.jsPsych.samedifferent = (function(){
function sd_trial($this, block, trial, part)
{
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();
setTimeout(function(){sd_trial($this, block, trial, part + 1);}, trial.timing[1]);
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; }
var plugin = {};
plugin.create = function(params) {
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(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);
if(params["data"]!=undefined){
trials[i]["data"] = params["data"][i];
}
}
return trials;
}
plugin.trial = function($this, block, trial, part)
{
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();
$this.html('');
setTimeout(function(){block.next();}, trial.timing[2]);
}
setTimeout(function(){sd_trial($this, block, trial, part + 1);}, trial.timing[1]);
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)
{
sim_stims = params["stimuli"];
trials = new Array(sim_stims.length);
for(var i = 0; i < trials.length; i++)
{
trials[i] = {};
trials[i]["type"] = "sim";
trials[i]["a_path"] = sim_stims[i][0];
trials[i]["b_path"] = sim_stims[i][1];
trials[i]["timing"] = params["timing"];
}
return trials;
}
(function( $ ) {
$.fn.jsPsych.text = (function(){
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];
var plugin = {};
plugin.create = function(params) {
sim_stims = params["stimuli"];
trials = new Array(sim_stims.length);
for(var i = 0; i < trials.length; i++)
{
trials[i] = {};
trials[i]["type"] = "sim";
trials[i]["a_path"] = sim_stims[i][0];
trials[i]["b_path"] = sim_stims[i][1];
trials[i]["timing"] = params["timing"];
}
// show the images
$this.append($('<img>', {
"src": images[0],
"class": 'sim'
}));
$this.append($('<img>', {
"src": images[1],
"class": 'sim'
}));
return trials;
}
// create slider
$this.append($('<div>', { "id": 'slider', "class": 'sim' }));
$("#slider").slider(
{
value:50,
min:0,
max:100,
step:1,
});
plugin.trial = function($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
$this.append($('<img>', {
"src": images[0],
"class": 'sim'
}));
$this.append($('<img>', {
"src": images[1],
"class": 'sim'
}));
// 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;
}
}
// create slider
$this.append($('<div>', { "id": 'slider', "class": 'sim' }));
$("#slider").slider(
{
value:50,
min:0,
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)
{
$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]);
(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;
}
}
$(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];
(function( $ ) {
$.fn.jsPsych.xab = (function(){
var plugin = {}
plugin.create = function(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;
}
}
return trials;
}
function xab_trial($this, block, trial, part)
{
switch(part){
case 1:
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();
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);
plugin.trial = function($this, block, trial, part)
{
switch(part){
case 1:
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();
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
break;
}
}
}
return plugin;
})();
})(jQuery);

View File

@ -25,7 +25,7 @@
{
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"])
{
opts["plugins"][j]["trialFunc"].call(this, $this, block, trial, 1);
opts["plugins"][j]["src"]["trial"].call(this, $this, block, trial, 1);
}
}
}