front-end/experiments/jsPsych-unused/plugins/jspsych-audio-countdown-keyboard-response.js
// 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();
      if(context !== null){
        source.stop();
        source.onended = function() { }
      } else {
        audio.pause();
        audio.removeEventListener('ended', end_trial);
      }
      jsPsych.pluginAPI.cancelAllKeyboardResponses();
      if(context !== null && response.rt !== null){
        response.rt = Math.round(response.rt * 1000);
      }
      var trial_data = {
        "rt": response.rt,
        "stimulus": trial.stimulus,
        "key_press": response.key
      };
      display_element.innerHTML = '';
      jsPsych.finishTrial(trial_data);
    }
function end_trial ( ) { jsPsych . pluginAPI . clearAllTimeouts ( ) ; if ( context !== null ) { source . stop ( ) ; source . onended = function ( ) { } } else { audio . pause ( ) ; audio . removeEventListener ( 'ended' , end_trial ) ; } jsPsych . pluginAPI . cancelAllKeyboardResponses ( ) ; if ( context !== null && response . rt !== null ) { response . rt = Math . round ( response . rt * 1000 ) ; } var trial_data = { "rt" : response . rt , "stimulus" : trial . stimulus , "key_press" : response . key } ; 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 // stop the audio file if it is playing // remove end event listeners if they exist // kill keyboard listeners // gather the data to store for the trial // clear the display // move on to the next trial