mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-12 08:38:11 +00:00
parent
9b617435e8
commit
e262c52ee9
@ -46,8 +46,6 @@
|
||||
return trials;
|
||||
};
|
||||
|
||||
var xab_trial_complete = false;
|
||||
|
||||
plugin.trial = function(display_element, trial) {
|
||||
|
||||
// if any trial variables are functions
|
||||
@ -55,7 +53,9 @@
|
||||
// it with the output of the function
|
||||
trial = jsPsych.pluginAPI.normalizeTrialVariables(trial);
|
||||
|
||||
xab_trial_complete = false;
|
||||
// this array holds handlers from setTimeout calls
|
||||
// that need to be cleared if the trial ends early
|
||||
var setTimeoutHandlers = [];
|
||||
|
||||
// how we display the content depends on whether the content is
|
||||
// HTML code or an image path.
|
||||
@ -124,16 +124,19 @@
|
||||
|
||||
// if timing_ab is > 0, then we hide the stimuli after timing_ab milliseconds
|
||||
if (trial.timing_ab > 0) {
|
||||
setTimeout(function() {
|
||||
if (!xab_trial_complete) {
|
||||
setTimeoutHandlers.push(setTimeout(function() {
|
||||
$('.jspsych-xab-stimulus').css('visibility', 'hidden');
|
||||
}
|
||||
}, trial.timing_ab);
|
||||
}, trial.timing_ab));
|
||||
}
|
||||
|
||||
// create the function that triggers when a key is pressed.
|
||||
var after_response = function(info) {
|
||||
|
||||
// kill any remaining setTimeout handlers
|
||||
for (var i = 0; i < setTimeoutHandlers.length; i++) {
|
||||
clearTimeout(setTimeoutHandlers[i]);
|
||||
}
|
||||
|
||||
var correct = false; // true when the correct response is chosen
|
||||
|
||||
if (info.key == trial.left_key) // 'q' key by default
|
||||
|
Loading…
Reference in New Issue
Block a user