remove now unnecessary timeout clears and display clears

This commit is contained in:
Josh de Leeuw 2024-07-11 18:06:30 -04:00
parent 313edc2af5
commit d520b70fbf
48 changed files with 1 additions and 196 deletions

View File

@ -278,9 +278,6 @@ class AudioButtonResponsePlugin implements JsPsychPlugin<Info> {
// function to end trial when it is time
const end_trial = () => {
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
// stop the audio file if it is playing
// remove end event listeners if they exist
if (context !== null) {
@ -299,9 +296,6 @@ class AudioButtonResponsePlugin implements JsPsychPlugin<Info> {
response: response.button,
};
// clear the display
display_element.innerHTML = "";
// move on to the next trial
this.jsPsych.finishTrial(trial_data);

View File

@ -182,9 +182,6 @@ class AudioKeyboardResponsePlugin implements JsPsychPlugin<Info> {
// function to end trial when it is time
const end_trial = () => {
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
// stop the audio file if it is playing
// remove end event listeners if they exist
if (context !== null) {
@ -206,9 +203,6 @@ class AudioKeyboardResponsePlugin implements JsPsychPlugin<Info> {
response: response.key,
};
// clear the display
display_element.innerHTML = "";
// move on to the next trial
this.jsPsych.finishTrial(trial_data);

View File

@ -340,9 +340,6 @@ class AudioSliderResponsePlugin implements JsPsychPlugin<Info> {
}
const end_trial = () => {
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
// stop the audio file if it is playing
// remove end event listeners if they exist
if (context !== null) {
@ -362,8 +359,6 @@ class AudioSliderResponsePlugin implements JsPsychPlugin<Info> {
response: response.response,
};
display_element.innerHTML = "";
// next trial
this.jsPsych.finishTrial(trialdata);

View File

@ -447,8 +447,6 @@ class BrowserCheckPlugin implements JsPsychPlugin<Info> {
}
private end_trial(feature_data) {
this.jsPsych.getDisplayElement().innerHTML = "";
const trial_data = { ...Object.fromEntries(feature_data) };
this.jsPsych.finishTrial(trial_data);

View File

@ -200,18 +200,12 @@ class CanvasButtonResponsePlugin implements JsPsychPlugin<Info> {
// function to end trial when it is time
const end_trial = () => {
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
// gather the data to store for the trial
var trial_data = {
rt: response.rt,
response: response.button,
};
// clear the display
display_element.innerHTML = "";
// move on to the next trial
this.jsPsych.finishTrial(trial_data);
};

View File

@ -123,9 +123,6 @@ class CanvasKeyboardResponsePlugin implements JsPsychPlugin<Info> {
// function to end trial when it is time
const end_trial = () => {
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
// kill keyboard listeners
if (typeof keyboardListener !== "undefined") {
this.jsPsych.pluginAPI.cancelKeyboardResponse(keyboardListener);
@ -137,9 +134,6 @@ class CanvasKeyboardResponsePlugin implements JsPsychPlugin<Info> {
response: response.key,
};
// clear the display
display_element.innerHTML = "";
// move on to the next trial
this.jsPsych.finishTrial(trial_data);
};

View File

@ -174,8 +174,6 @@ class CanvasSliderResponsePlugin implements JsPsychPlugin<Info> {
};
const end_trial = () => {
this.jsPsych.pluginAPI.clearAllTimeouts();
// save data
var trialdata = {
rt: response.rt,
@ -183,8 +181,6 @@ class CanvasSliderResponsePlugin implements JsPsychPlugin<Info> {
slider_start: trial.slider_start,
};
display_element.innerHTML = "";
// next trial
this.jsPsych.finishTrial(trialdata);
};

View File

@ -240,7 +240,6 @@ class CategorizeAnimationPlugin implements JsPsychPlugin<Info> {
const endTrial = () => {
clearInterval(animate_interval); // stop animation!
display_element.innerHTML = ""; // clear everything
this.jsPsych.finishTrial(trial_data);
};

View File

@ -134,9 +134,6 @@ class CategorizeHtmlPlugin implements JsPsychPlugin<Info> {
// create response function
const after_response = (info: { key: string; rt: number }) => {
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
// clear keyboard listener
this.jsPsych.pluginAPI.cancelAllKeyboardResponses();
@ -153,8 +150,6 @@ class CategorizeHtmlPlugin implements JsPsychPlugin<Info> {
response: info.key,
};
display_element.innerHTML = "";
var timeout = info.rt == null;
doFeedback(correct, timeout);
};
@ -177,7 +172,6 @@ class CategorizeHtmlPlugin implements JsPsychPlugin<Info> {
}
const endTrial = () => {
display_element.innerHTML = "";
this.jsPsych.finishTrial(trial_data);
};

View File

@ -135,9 +135,6 @@ class CategorizeImagePlugin implements JsPsychPlugin<Info> {
// create response function
const after_response = (info: { key: string; rt: number }) => {
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
// clear keyboard listener
this.jsPsych.pluginAPI.cancelAllKeyboardResponses();
@ -154,8 +151,6 @@ class CategorizeImagePlugin implements JsPsychPlugin<Info> {
response: info.key,
};
display_element.innerHTML = "";
var timeout = info.rt == null;
doFeedback(correct, timeout);
};
@ -178,7 +173,6 @@ class CategorizeImagePlugin implements JsPsychPlugin<Info> {
}
const endTrial = () => {
display_element.innerHTML = "";
this.jsPsych.finishTrial(trial_data);
};

View File

@ -105,7 +105,6 @@ class ClozePlugin implements JsPsychPlugin<Info> {
response: answers,
};
display_element.innerHTML = "";
this.jsPsych.finishTrial(trial_data);
}
};

View File

@ -98,7 +98,6 @@ class ExternalHtmlPlugin implements JsPsychPlugin<Info> {
rt: Math.round(performance.now() - t0),
url: trial.url,
};
display_element.innerHTML = "";
this.jsPsych.finishTrial(trial_data);
trial_complete();
};

View File

@ -474,8 +474,6 @@ class FreeSortPlugin implements JsPsychPlugin<Info> {
rt: rt,
};
// advance to next part
display_element.innerHTML = "";
this.jsPsych.finishTrial(trial_data);
}
});

View File

@ -269,9 +269,6 @@ class HtmlAudioResponsePlugin implements JsPsychPlugin<Info> {
this.recorder.removeEventListener("start", this.start_event_handler);
this.recorder.removeEventListener("stop", this.stop_event_handler);
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
// gather the data to store for the trial
var trial_data: any = {
rt: this.rt,
@ -286,9 +283,6 @@ class HtmlAudioResponsePlugin implements JsPsychPlugin<Info> {
URL.revokeObjectURL(this.audio_url);
}
// clear the display
display_element.innerHTML = "";
// move on to the next trial
this.jsPsych.finishTrial(trial_data);
}

View File

@ -159,9 +159,6 @@ class HtmlButtonResponsePlugin implements JsPsychPlugin<Info> {
// function to end trial when it is time
const end_trial = () => {
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
// gather the data to store for the trial
var trial_data = {
rt: response.rt,
@ -169,9 +166,6 @@ class HtmlButtonResponsePlugin implements JsPsychPlugin<Info> {
response: response.button,
};
// clear the display
display_element.innerHTML = "";
// move on to the next trial
this.jsPsych.finishTrial(trial_data);
};

View File

@ -194,8 +194,6 @@ class HtmlSliderResponsePlugin implements JsPsychPlugin<Info> {
}
const end_trial = () => {
this.jsPsych.pluginAPI.clearAllTimeouts();
// save data
var trialdata = {
rt: response.rt,
@ -204,8 +202,6 @@ class HtmlSliderResponsePlugin implements JsPsychPlugin<Info> {
response: response.response,
};
display_element.innerHTML = "";
// next trial
this.jsPsych.finishTrial(trialdata);
};

View File

@ -270,9 +270,6 @@ class HtmlVideoResponsePlugin implements JsPsychPlugin<Info> {
this.recorder.removeEventListener("start", this.start_event_handler);
this.recorder.removeEventListener("stop", this.stop_event_handler);
// clear any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
// gather the data to store for the trial
var trial_data: any = {
rt: this.rt,
@ -286,9 +283,6 @@ class HtmlVideoResponsePlugin implements JsPsychPlugin<Info> {
URL.revokeObjectURL(this.video_url);
}
// clear the display
display_element.innerHTML = "";
// move on to the next trial
this.jsPsych.finishTrial(trial_data);
}

View File

@ -202,9 +202,6 @@ class IatHtmlPlugin implements JsPsychPlugin<Info> {
// function to end trial when it is time
const end_trial = () => {
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
// kill keyboard listeners
if (typeof keyboardListener !== "undefined") {
this.jsPsych.pluginAPI.cancelKeyboardResponse(keyboardListener);
@ -218,9 +215,6 @@ class IatHtmlPlugin implements JsPsychPlugin<Info> {
correct: response.correct,
};
// clears the display
display_element.innerHTML = "";
// move on to the next trial
this.jsPsych.finishTrial(trial_data);
};

View File

@ -202,9 +202,6 @@ class IatImagePlugin implements JsPsychPlugin<Info> {
// function to end trial when it is time
const end_trial = () => {
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
// kill keyboard listeners
if (typeof keyboardListener !== "undefined") {
this.jsPsych.pluginAPI.cancelKeyboardResponse(keyboardListener);
@ -218,9 +215,6 @@ class IatImagePlugin implements JsPsychPlugin<Info> {
correct: response.correct,
};
// clears the display
display_element.innerHTML = "";
// move on to the next trial
this.jsPsych.finishTrial(trial_data);
};

View File

@ -270,9 +270,6 @@ class ImageButtonResponsePlugin implements JsPsychPlugin<Info> {
// function to end trial when it is time
const end_trial = () => {
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
// gather the data to store for the trial
var trial_data = {
rt: response.rt,
@ -280,9 +277,6 @@ class ImageButtonResponsePlugin implements JsPsychPlugin<Info> {
response: response.button,
};
// clear the display
display_element.innerHTML = "";
// move on to the next trial
this.jsPsych.finishTrial(trial_data);
};

View File

@ -215,9 +215,6 @@ class ImageKeyboardResponsePlugin implements JsPsychPlugin<Info> {
// function to end trial when it is time
const end_trial = () => {
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
// kill keyboard listeners
if (typeof keyboardListener !== "undefined") {
this.jsPsych.pluginAPI.cancelKeyboardResponse(keyboardListener);
@ -230,9 +227,6 @@ class ImageKeyboardResponsePlugin implements JsPsychPlugin<Info> {
response: response.key,
};
// clear the display
display_element.innerHTML = "";
// move on to the next trial
this.jsPsych.finishTrial(trial_data);
};

View File

@ -391,8 +391,6 @@ class ImageSliderResponsePlugin implements JsPsychPlugin<Info> {
}
const end_trial = () => {
this.jsPsych.pluginAPI.clearAllTimeouts();
// save data
var trialdata = {
rt: response.rt,
@ -401,8 +399,6 @@ class ImageSliderResponsePlugin implements JsPsychPlugin<Info> {
response: response.response,
};
display_element.innerHTML = "";
// next trial
this.jsPsych.finishTrial(trialdata);
};

View File

@ -76,7 +76,6 @@ class InitializeCameraPlugin implements JsPsychPlugin<Info> {
trial(display_element: HTMLElement, trial: TrialType<Info>) {
this.run_trial(display_element, trial).then((id) => {
display_element.innerHTML = "";
this.jsPsych.finishTrial({
device_id: id,
});

View File

@ -225,8 +225,6 @@ class InstructionsPlugin implements JsPsychPlugin<Info> {
this.jsPsych.pluginAPI.cancelKeyboardResponse(keyboard_listener);
}
display_element.innerHTML = "";
var trial_data = {
view_history: view_history,
rt: Math.round(performance.now() - start_time),

View File

@ -229,9 +229,6 @@ class MaxdiffPlugin implements JsPsychPlugin<Info> {
response: { left: get_response("left"), right: get_response("right") },
};
// clear the display
display_element.innerHTML = "";
// next trial
this.jsPsych.finishTrial(trial_data);
});

View File

@ -85,7 +85,6 @@ class MirrorCameraPlugin implements JsPsychPlugin<Info> {
}
finish(display_element: HTMLElement) {
display_element.innerHTML = "";
this.jsPsych.finishTrial({
rt: performance.now() - this.start_time,
});

View File

@ -280,8 +280,6 @@ class PreloadPlugin implements JsPsychPlugin<Info> {
};
const end_trial = () => {
// clear timeout again when end_trial is called, to handle race condition with max_load_time
this.jsPsych.pluginAPI.clearAllTimeouts();
var trial_data = {
success: success,
timeout: timeout,
@ -289,8 +287,7 @@ class PreloadPlugin implements JsPsychPlugin<Info> {
failed_audio: failed_audio,
failed_video: failed_video,
};
// clear the display
display_element.innerHTML = "";
this.jsPsych.finishTrial(trial_data);
};

View File

@ -91,8 +91,6 @@ class ReconstructionPlugin implements JsPsychPlugin<Info> {
start_value: trial.starting_value,
};
display_element.innerHTML = "";
// next trial
this.jsPsych.finishTrial(trial_data);
};

View File

@ -104,9 +104,6 @@ class ResizePlugin implements JsPsychPlugin<Info> {
document.removeEventListener("mousemove", resizeevent);
document.removeEventListener("mouseup", mouseupevent);
// clear the screen
display_element.innerHTML = "";
// finishes trial
var trial_data = {

View File

@ -139,9 +139,6 @@ class SameDifferentHtmlPlugin implements JsPsychPlugin<Info> {
}
const after_response = (info: { key: string; rt: number }) => {
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
var correct = false;
var skey = trial.same_key;
@ -167,8 +164,6 @@ class SameDifferentHtmlPlugin implements JsPsychPlugin<Info> {
trial_data["response_stim1"] = first_stim_info.key;
}
display_element.innerHTML = "";
this.jsPsych.finishTrial(trial_data);
};

View File

@ -142,9 +142,6 @@ class SameDifferentImagePlugin implements JsPsychPlugin<Info> {
}
const after_response = (info: { key: string; rt: number }) => {
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
var correct = false;
var skey = trial.same_key;
@ -170,8 +167,6 @@ class SameDifferentImagePlugin implements JsPsychPlugin<Info> {
trial_data["response_stim1"] = first_stim_info.key;
}
display_element.innerHTML = "";
this.jsPsych.finishTrial(trial_data);
};

View File

@ -177,9 +177,6 @@ class SerialReactionTimeMousePlugin implements JsPsychPlugin<Info> {
}
const endTrial = () => {
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
// gather the data to store for the trial
var trial_data = {
rt: response.rt,
@ -189,9 +186,6 @@ class SerialReactionTimeMousePlugin implements JsPsychPlugin<Info> {
correct: response.row == trial.target[0] && response.column == trial.target[1],
};
// clear the display
display_element.innerHTML = "";
// move on to the next trial
this.jsPsych.finishTrial(trial_data);
};

View File

@ -133,9 +133,6 @@ class SerialReactionTimePlugin implements JsPsychPlugin<Info> {
};
const endTrial = () => {
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
// kill keyboard listeners
this.jsPsych.pluginAPI.cancelKeyboardResponse(keyboardListener);
@ -148,9 +145,6 @@ class SerialReactionTimePlugin implements JsPsychPlugin<Info> {
target: trial.target,
};
// clear the display
display_element.innerHTML = "";
// move on to the next trial
this.jsPsych.finishTrial(trial_data);
};

View File

@ -709,7 +709,6 @@ class SketchpadPlugin implements JsPsychPlugin<Info> {
}
private end_trial(response = null) {
this.jsPsych.pluginAPI.clearAllTimeouts();
this.jsPsych.pluginAPI.cancelAllKeyboardResponses();
clearInterval(this.timer_interval);
@ -726,8 +725,6 @@ class SketchpadPlugin implements JsPsychPlugin<Info> {
trial_data.strokes = this.strokes;
}
this.display.innerHTML = "";
document.querySelector("#sketchpad-styles").remove();
this.jsPsych.finishTrial(trial_data);

View File

@ -141,8 +141,6 @@ class SurveyHtmlFormPlugin implements JsPsychPlugin<Info> {
response: question_data,
};
display_element.innerHTML = "";
// next trial
this.jsPsych.finishTrial(trialdata);
});

View File

@ -229,8 +229,6 @@ class SurveyLikertPlugin implements JsPsychPlugin<Info> {
question_order: question_order,
};
display_element.innerHTML = "";
// next trial
this.jsPsych.finishTrial(trial_data);
});

View File

@ -264,7 +264,6 @@ class SurveyMultiChoicePlugin implements JsPsychPlugin<Info> {
response: question_data,
question_order: question_order,
};
display_element.innerHTML = "";
// next trial
this.jsPsych.finishTrial(trial_data);

View File

@ -299,7 +299,6 @@ class SurveyMultiSelectPlugin implements JsPsychPlugin<Info> {
response: question_data,
question_order: question_order,
};
display_element.innerHTML = "";
// next trial
this.jsPsych.finishTrial(trial_data);

View File

@ -256,8 +256,6 @@ class SurveyTextPlugin implements JsPsychPlugin<Info> {
response: question_data,
};
display_element.innerHTML = "";
// next trial
this.jsPsych.finishTrial(trialdata);
});

View File

@ -194,7 +194,6 @@ class SurveyPlugin implements JsPsychPlugin<Info> {
}
// clear display and reset flex on jspsych-content-wrapper
display_element.innerHTML = "";
document.querySelector<HTMLElement>(".jspsych-content-wrapper").style.display = "flex";
// finish trial and save data

View File

@ -187,8 +187,6 @@ class VideoButtonResponsePlugin implements JsPsychPlugin<Info> {
constructor(private jsPsych: JsPsych) {}
trial(display_element: HTMLElement, trial: TrialType<Info>) {
display_element.innerHTML = "";
// Setup stimulus
const stimulusWrapper = document.createElement("div");
display_element.appendChild(stimulusWrapper);
@ -361,9 +359,6 @@ class VideoButtonResponsePlugin implements JsPsychPlugin<Info> {
// function to end trial when it is time
const end_trial = () => {
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
// stop the video file if it is playing
// remove any remaining end event handlers
videoElement.pause();
@ -376,9 +371,6 @@ class VideoButtonResponsePlugin implements JsPsychPlugin<Info> {
response: response.button,
};
// clear the display
display_element.innerHTML = "";
// move on to the next trial
this.jsPsych.finishTrial(trial_data);
};

View File

@ -278,9 +278,6 @@ class VideoKeyboardResponsePlugin implements JsPsychPlugin<Info> {
// function to end trial when it is time
const end_trial = () => {
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
// kill keyboard listeners
this.jsPsych.pluginAPI.cancelAllKeyboardResponses();
@ -300,9 +297,6 @@ class VideoKeyboardResponsePlugin implements JsPsychPlugin<Info> {
response: response.key,
};
// clear the display
display_element.innerHTML = "";
// move on to the next trial
this.jsPsych.finishTrial(trial_data);
};

View File

@ -400,9 +400,6 @@ class VideoSliderResponsePlugin implements JsPsychPlugin<Info> {
// function to end trial when it is time
const end_trial = () => {
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
// stop the video file if it is playing
// remove any remaining end event handlers
display_element
@ -421,9 +418,6 @@ class VideoSliderResponsePlugin implements JsPsychPlugin<Info> {
response: response.response,
};
// clear the display
display_element.innerHTML = "";
// move on to the next trial
this.jsPsych.finishTrial(trial_data);
};

View File

@ -498,9 +498,6 @@ class VirtualChinrestPlugin implements JsPsychPlugin<Info> {
// compute final data
computeTransformation();
// clear the display
display_element.innerHTML = "";
// finish the trial
this.jsPsych.finishTrial(trial_data);
};

View File

@ -201,9 +201,6 @@ class VisualSearchCirclePlugin implements JsPsychPlugin<Info> {
};
const end_trial = () => {
display_element.innerHTML = "";
this.jsPsych.pluginAPI.clearAllTimeouts();
this.jsPsych.pluginAPI.cancelAllKeyboardResponses();
// data saving

View File

@ -178,15 +178,9 @@ class WebgazerCalibratePlugin implements JsPsychPlugin<Info> {
extension.hidePredictions();
extension.hideVideo();
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
// gather the data to store for the trial
var trial_data = {};
// clear the display
display_element.innerHTML = "";
// move on to the next trial
this.jsPsych.finishTrial(trial_data);
};

View File

@ -61,17 +61,11 @@ class WebgazerInitCameraPlugin implements JsPsychPlugin<Info> {
extension.pause();
extension.hideVideo();
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
// gather the data to store for the trial
var trial_data = {
load_time: load_time,
};
// clear the display
display_element.innerHTML = "";
document.querySelector("#webgazer-center-style").remove();
// move on to the next trial

View File

@ -146,12 +146,6 @@ class WebgazerValidatePlugin implements JsPsychPlugin<Info> {
const end_trial = () => {
extension.stopSampleInterval();
// kill any remaining setTimeout handlers
this.jsPsych.pluginAPI.clearAllTimeouts();
// clear the display
display_element.innerHTML = "";
// move on to the next trial
this.jsPsych.finishTrial(trial_data);
};