diff --git a/examples/jspsych-audio-button-response.html b/examples/jspsych-audio-button-response.html index 0f5a4128..1c51aa5b 100644 --- a/examples/jspsych-audio-button-response.html +++ b/examples/jspsych-audio-button-response.html @@ -29,17 +29,17 @@ timeline.push({ type: 'audio-button-response', stimulus: 'sound/speech_red.mp3', - choices: ['Green', 'Blue', 'Red'], - trial_duration: 2000, - response_ends_trial: false, - prompt: "
What word was said? (trial ends after 2s)
" + choices: ['#00ff00', '#0000ff', '#ff0000'], + response_allowed_while_playing: false, + button_html: '', + prompt: "Which color was said?
" }); timeline.push({ type: 'audio-button-response', stimulus: 'sound/speech_joke.mp3', choices: ['Not funny', 'Funny'], - prompt: 'How funny was the joke?
When the audio stops, click a button to end the trial.
Response buttons are disabled while the audio is playing.
', + prompt: 'Is the joke funny?
When the audio stops, click a button to end the trial.
Response buttons are disabled while the audio is playing.
', response_allowed_while_playing: false }) diff --git a/examples/jspsych-video-button-response.html b/examples/jspsych-video-button-response.html index cecb0ff9..2e8d02b3 100644 --- a/examples/jspsych-video-button-response.html +++ b/examples/jspsych-video-button-response.html @@ -18,8 +18,7 @@ var trial_1 = { type: 'video-button-response', stimulus: ['video/sample_video.mp4'], - choices: ['y','n'], - button_html: '', + choices: ['Y','N'], margin_vertical: '10px', margin_horizontal: '8px', prompt: 'Press Y or N', @@ -37,10 +36,11 @@ var trial_2 = { type: 'video-button-response', stimulus: ['video/sample_video.mp4'], - choices: ['Great','Not great'], + choices: ['😄','😁','🥱','😣','🤯'], + button_html: 'How great was the video?
When the video stops, click a button to end the trial.
Response buttons are disabled while the video is playing.
', + prompt: 'Click the emoji that best represents your reaction to the video
When the video stops, click a button to end the trial.
Response buttons are disabled while the video is playing.
', width: 600, autoplay: true, response_ends_trial: true, diff --git a/plugins/jspsych-audio-button-response.js b/plugins/jspsych-audio-button-response.js index 8ce7a82d..bd4078fe 100644 --- a/plugins/jspsych-audio-button-response.js +++ b/plugins/jspsych-audio-button-response.js @@ -140,16 +140,12 @@ jsPsych.plugins["audio-button-response"] = (function() { html += trial.prompt; } - display_element.innerHTML = html; - - for (var i = 0; i < trial.choices.length; i++) { - display_element.querySelector('#jspsych-audio-button-response-button-' + i).addEventListener('click', function(e){ - var choice = e.currentTarget.getAttribute('data-choice'); // don't use dataset for jsdom compatibility - after_response(choice); - }); - if (!trial.response_allowed_while_playing) { - display_element.querySelector('#jspsych-audio-button-response-button-' + i).querySelector('button').disabled = true; - } + display_element.innerHTML = html; + + if(trial.response_allowed_while_playing){ + enable_buttons(); + } else { + disable_buttons(); } // store response @@ -172,11 +168,7 @@ jsPsych.plugins["audio-button-response"] = (function() { response.rt = rt; // disable all the buttons after a response - var btns = document.querySelectorAll('.jspsych-audio-button-response-button button'); - for(var i=0; i