Fixed IE bugs in animation, categorization, and xab versions.

This commit is contained in:
Josh de Leeuw 2012-05-14 15:28:20 -04:00
parent c3a42dc358
commit 6656564b63
4 changed files with 45 additions and 23 deletions

View File

@ -22,14 +22,13 @@ function animation_create(params)
function animation_trial($this, block, trial, part) function animation_trial($this, block, trial, part)
{ {
animate_frame = -1; var animate_frame = -1;
reps = 0; var reps = 0;
switch(part) switch(part)
{ {
case 1: case 1:
animate_interval = setInterval(function(){ animate_interval = setInterval(function(){
showImage = true; showImage = true;
$('.animate').remove();
$this.html(""); // clear everything $this.html(""); // clear everything
animate_frame++; animate_frame++;
if(animate_frame == trial.stims.length) if(animate_frame == trial.stims.length)
@ -44,13 +43,16 @@ function animation_trial($this, block, trial, part)
} }
} }
if(showImage){ if(showImage){
$.fn.jsPsych.showImage($this, trial.stims[animate_frame], 'animate'); $this.append($('<img>', {
"src": trial.stims[animate_frame],
"class": 'animate'
}));
if(trial.prompt != undefined) { $this.append(trial.prompt); } if(trial.prompt != undefined) { $this.append(trial.prompt); }
} }
}, trial.frame_time); }, trial.frame_time);
break; break;
case 2: case 2:
setTimeout(function(b){ b.next(); }, trial.timing[0], block); setTimeout(function(){ block.next(); }, trial.timing[0]);
break; break;
} }
} }

View File

@ -33,13 +33,15 @@ function cf_create(params)
function cf_trial($this, block, trial, part) function cf_trial($this, block, trial, part)
{ {
//console.log(block.trial_idx);
switch(part){ switch(part){
case 1: case 1:
p1_time = (new Date()).getTime(); p1_time = (new Date()).getTime();
$.fn.jsPsych.showImage($this, trial.a_path, 'cf'); $this.append($('<img>', {
"src": trial.a_path,
"class": 'cf'
}));
if(trial.timing[2]!=undefined){ if(trial.timing[2]!=undefined){
setTimeout(cf_trial, trial.timing[2], $this, block, trial, part + 1); 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);
@ -50,7 +52,7 @@ function cf_trial($this, block, trial, part)
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.html(trial.prompt); $this.append(trial.prompt);
} }
startTime = (new Date()).getTime(); startTime = (new Date()).getTime();
var resp_func = function(e) { var resp_func = function(e) {
@ -81,7 +83,6 @@ function cf_trial($this, block, trial, part)
var trial_data = {"rt": rt, "correct": correct, "a_path": trial.a_path, "key_press": e.which, "stim1_time": stim1_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); block.data[block.trial_idx] = $.extend({},trial_data,trial.data);
$(document).unbind('keyup',resp_func); $(document).unbind('keyup',resp_func);
$('.cf').remove();
$this.html(''); $this.html('');
cf_trial($this, block, trial, part + 1); cf_trial($this, block, trial, part + 1);
} }
@ -91,7 +92,10 @@ function cf_trial($this, block, trial, part)
case 3: case 3:
if(trial.show_stim_feedback) if(trial.show_stim_feedback)
{ {
$.fn.jsPsych.showImage($this, trial.a_path, 'cf'); $this.append($('<img>', {
"src": trial.a_path,
"class": 'cf'
}));
} }
// give feedback // give feedback
var atext = ""; var atext = "";
@ -102,11 +106,11 @@ function cf_trial($this, block, trial, part)
atext = trial.incorrect_text.replace("&ANS&", trial.text_answer); atext = trial.incorrect_text.replace("&ANS&", trial.text_answer);
} }
$this.append(atext); $this.append(atext);
setTimeout(cf_trial, trial.timing[0], $this, block, trial, part + 1); setTimeout(function(){cf_trial($this, block, trial, part + 1);}, trial.timing[0]);
break; break;
case 4: case 4:
$this.html(""); $this.html("");
setTimeout(function(b){b.next();}, trial.timing[1], block); setTimeout(function(){block.next();}, trial.timing[1]);
break; break;
} }
} }

View File

@ -27,9 +27,12 @@ function cu_trial($this, block, trial, part)
switch(part){ switch(part){
case 1: case 1:
p1_time = (new Date()).getTime(); p1_time = (new Date()).getTime();
$.fn.jsPsych.showImage($this, trial.a_path, 'cu'); $this.append($('<img>', {
"src": trial.a_path,
"class": 'cu'
}));
if(trial.timing[1]!=undefined){ if(trial.timing[1]!=undefined){
setTimeout(cu_trial, trial.timing[1], $this, block, trial, part + 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);
@ -40,7 +43,7 @@ function cu_trial($this, block, trial, part)
p2_time = (new Date()).getTime(); p2_time = (new Date()).getTime();
if(trial.timing[1]!=undefined){ if(trial.timing[1]!=undefined){
$('.cu').remove(); $('.cu').remove();
$this.html(trial.prompt); $this.append(trial.prompt);
} }
startTime = (new Date()).getTime(); startTime = (new Date()).getTime();
var resp_func = function(e) { var resp_func = function(e) {
@ -61,9 +64,8 @@ function cu_trial($this, block, trial, part)
var trial_data = {"rt": rt, "a_path": trial.a_path, "key_press": e.which, "stim1_time": stim1_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); block.data[block.trial_idx] = $.extend({},trial_data,trial.data);
$(document).unbind('keyup',resp_func); $(document).unbind('keyup',resp_func);
$('.cu').remove();
$this.html(''); $this.html('');
setTimeout(function(b){b.next();}, trial.timing[0], block); setTimeout(function(){block.next();}, trial.timing[0]);
} }
} }
$(document).keyup(resp_func); $(document).keyup(resp_func);

View File

@ -22,13 +22,16 @@ function xab_trial($this, block, trial, part)
switch(part){ switch(part){
case 1: case 1:
p1_time = (new Date()).getTime(); p1_time = (new Date()).getTime();
$.fn.jsPsych.showImage($this, trial.a_path, 'xab'); $this.append($('<img>', {
setTimeout(xab_trial, trial.timing[0], $this, block, trial, part + 1); "src": trial.a_path,
"class": 'xab'
}));
setTimeout(function(){xab_trial($this, block, trial, part + 1)}, trial.timing[0]);
break; break;
case 2: case 2:
p2_time = (new Date()).getTime(); p2_time = (new Date()).getTime();
$('.xab').remove(); $('.xab').remove();
setTimeout(xab_trial, trial.timing[1], $this, block, trial, part + 1); setTimeout(function(){xab_trial($this, block, trial, part + 1)}, trial.timing[1]);
break; break;
case 3: case 3:
p3_time = (new Date()).getTime(); p3_time = (new Date()).getTime();
@ -38,7 +41,18 @@ function xab_trial($this, block, trial, part)
if(!target_left){ if(!target_left){
images = [trial.b_path, trial.a_path]; images = [trial.b_path, trial.a_path];
} }
$.fn.jsPsych.showImages($this, images, 'xab');
// 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 resp_func = function(e) {
var flag = false; var flag = false;
var correct = false; var correct = false;
@ -61,7 +75,7 @@ function xab_trial($this, block, trial, part)
block.data[block.trial_idx] = $.extend({},trial_data,trial.data); block.data[block.trial_idx] = $.extend({},trial_data,trial.data);
$(document).unbind('keyup',resp_func); $(document).unbind('keyup',resp_func);
$('.xab').remove(); $('.xab').remove();
setTimeout(function(b){b.next();}, trial.timing[2], block); setTimeout(function(){block.next();}, trial.timing[2]);
} }
} }
$(document).keyup(resp_func); $(document).keyup(resp_func);