mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
Fixed IE bugs in animation, categorization, and xab versions.
This commit is contained in:
parent
c3a42dc358
commit
6656564b63
@ -22,14 +22,13 @@ function animation_create(params)
|
||||
|
||||
function animation_trial($this, block, trial, part)
|
||||
{
|
||||
animate_frame = -1;
|
||||
reps = 0;
|
||||
var animate_frame = -1;
|
||||
var reps = 0;
|
||||
switch(part)
|
||||
{
|
||||
case 1:
|
||||
animate_interval = setInterval(function(){
|
||||
showImage = true;
|
||||
$('.animate').remove();
|
||||
$this.html(""); // clear everything
|
||||
animate_frame++;
|
||||
if(animate_frame == trial.stims.length)
|
||||
@ -44,13 +43,16 @@ function animation_trial($this, block, trial, part)
|
||||
}
|
||||
}
|
||||
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); }
|
||||
}
|
||||
}, trial.frame_time);
|
||||
break;
|
||||
case 2:
|
||||
setTimeout(function(b){ b.next(); }, trial.timing[0], block);
|
||||
setTimeout(function(){ block.next(); }, trial.timing[0]);
|
||||
break;
|
||||
}
|
||||
}
|
@ -33,13 +33,15 @@ function cf_create(params)
|
||||
|
||||
function cf_trial($this, block, trial, part)
|
||||
{
|
||||
//console.log(block.trial_idx);
|
||||
switch(part){
|
||||
case 1:
|
||||
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){
|
||||
setTimeout(cf_trial, trial.timing[2], $this, block, trial, part + 1);
|
||||
setTimeout(function(){cf_trial($this, block, trial, part + 1);}, trial.timing[2]);
|
||||
} else {
|
||||
//show prompt here
|
||||
$this.append(trial.prompt);
|
||||
@ -50,7 +52,7 @@ function cf_trial($this, block, trial, part)
|
||||
p2_time = (new Date()).getTime();
|
||||
if(trial.timing[2]!=undefined){
|
||||
$('.cf').remove();
|
||||
$this.html(trial.prompt);
|
||||
$this.append(trial.prompt);
|
||||
}
|
||||
startTime = (new Date()).getTime();
|
||||
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}
|
||||
block.data[block.trial_idx] = $.extend({},trial_data,trial.data);
|
||||
$(document).unbind('keyup',resp_func);
|
||||
$('.cf').remove();
|
||||
$this.html('');
|
||||
cf_trial($this, block, trial, part + 1);
|
||||
}
|
||||
@ -91,7 +92,10 @@ function cf_trial($this, block, trial, part)
|
||||
case 3:
|
||||
if(trial.show_stim_feedback)
|
||||
{
|
||||
$.fn.jsPsych.showImage($this, trial.a_path, 'cf');
|
||||
$this.append($('<img>', {
|
||||
"src": trial.a_path,
|
||||
"class": 'cf'
|
||||
}));
|
||||
}
|
||||
// give feedback
|
||||
var atext = "";
|
||||
@ -102,11 +106,11 @@ function cf_trial($this, block, trial, part)
|
||||
atext = trial.incorrect_text.replace("&ANS&", trial.text_answer);
|
||||
}
|
||||
$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;
|
||||
case 4:
|
||||
$this.html("");
|
||||
setTimeout(function(b){b.next();}, trial.timing[1], block);
|
||||
setTimeout(function(){block.next();}, trial.timing[1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -27,9 +27,12 @@ function cu_trial($this, block, trial, part)
|
||||
switch(part){
|
||||
case 1:
|
||||
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){
|
||||
setTimeout(cu_trial, trial.timing[1], $this, block, trial, part + 1);
|
||||
setTimeout(function(){cu_trial($this, block, trial, part + 1);}, trial.timing[1]);
|
||||
} else {
|
||||
//show prompt here
|
||||
$this.append(trial.prompt);
|
||||
@ -40,7 +43,7 @@ function cu_trial($this, block, trial, part)
|
||||
p2_time = (new Date()).getTime();
|
||||
if(trial.timing[1]!=undefined){
|
||||
$('.cu').remove();
|
||||
$this.html(trial.prompt);
|
||||
$this.append(trial.prompt);
|
||||
}
|
||||
startTime = (new Date()).getTime();
|
||||
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}
|
||||
block.data[block.trial_idx] = $.extend({},trial_data,trial.data);
|
||||
$(document).unbind('keyup',resp_func);
|
||||
$('.cu').remove();
|
||||
$this.html('');
|
||||
setTimeout(function(b){b.next();}, trial.timing[0], block);
|
||||
setTimeout(function(){block.next();}, trial.timing[0]);
|
||||
}
|
||||
}
|
||||
$(document).keyup(resp_func);
|
||||
|
@ -22,13 +22,16 @@ function xab_trial($this, block, trial, part)
|
||||
switch(part){
|
||||
case 1:
|
||||
p1_time = (new Date()).getTime();
|
||||
$.fn.jsPsych.showImage($this, trial.a_path, 'xab');
|
||||
setTimeout(xab_trial, trial.timing[0], $this, block, trial, part + 1);
|
||||
$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(xab_trial, trial.timing[1], $this, block, trial, part + 1);
|
||||
setTimeout(function(){xab_trial($this, block, trial, part + 1)}, trial.timing[1]);
|
||||
break;
|
||||
case 3:
|
||||
p3_time = (new Date()).getTime();
|
||||
@ -38,7 +41,18 @@ function xab_trial($this, block, trial, part)
|
||||
if(!target_left){
|
||||
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 flag = 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);
|
||||
$(document).unbind('keyup',resp_func);
|
||||
$('.xab').remove();
|
||||
setTimeout(function(b){b.next();}, trial.timing[2], block);
|
||||
setTimeout(function(){block.next();}, trial.timing[2]);
|
||||
}
|
||||
}
|
||||
$(document).keyup(resp_func);
|
||||
|
Loading…
Reference in New Issue
Block a user