function end_trial() {

      // kill any remaining setTimeout handlers
      jsPsych.pluginAPI.clearAllTimeouts();

      // confirm image loading
      const loaded = Array.from(document.getElementsByTagName('img')).map(x => (x.complete) && (x.naturalWidth != 0));
      const all_loaded = loaded.every(x => x);

      // gather the data to store for the trial
      var trial_data = {
        item: trial.item,
        shape_set: trial.shape_set,
        distractor: trial.distractor,
        choice_order: item_order,
        correct: trial.correct,
        choice: response.choice,
        accuracy: response.accuracy,
        rt: response.rt,
        screen_resolution: screen_resolution,
        minimum_resolution: minimum_resolution,
        all_loaded: all_loaded
      };

      // clear the display
      display_element.innerHTML = '';

      // move on to the next trial
      jsPsych.finishTrial(trial_data);
    }
// function to end trial when it is time

function to end trial when it is time
function to end trial when it is time
function end_trial() {
      jsPsych.pluginAPI.clearAllTimeouts();
      const loaded = Array.from(document.getElementsByTagName('img')).map(x => (x.complete) && (x.naturalWidth != 0));
      const all_loaded = loaded.every(x => x);
      var trial_data = {
        item: trial.item,
        shape_set: trial.shape_set,
        distractor: trial.distractor,
        choice_order: item_order,
        correct: trial.correct,
        choice: response.choice,
        accuracy: response.accuracy,
        rt: response.rt,
        screen_resolution: screen_resolution,
        minimum_resolution: minimum_resolution,
        all_loaded: all_loaded
      };
      display_element.innerHTML = '';
      jsPsych.finishTrial(trial_data);
    }
function end_trial ( ) { jsPsych . pluginAPI . clearAllTimeouts ( ) ; const loaded = Array . from ( document . getElementsByTagName ( 'img' ) ) . map ( x => ( x . complete ) && ( x . naturalWidth != 0 ) ) ; const all_loaded = loaded . every ( x => x ) ; var trial_data = { item : trial . item , shape_set : trial . shape_set , distractor : trial . distractor , choice_order : item_order , correct : trial . correct , choice : response . choice , accuracy : response . accuracy , rt : response . rt , screen_resolution : screen_resolution , minimum_resolution : minimum_resolution , all_loaded : all_loaded } ; display_element . innerHTML = '' ; jsPsych . finishTrial ( trial_data ) ; }
function to end trial when it is time
function to end trial when it is time
// kill any remaining setTimeout handlers
 // confirm image loading
 // gather the data to store for the trial
 // clear the display
 // move on to the next trial
