@jspsych/plugin-audio-button-response 1.1.2 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import { JsPsych, JsPsychPlugin, ParameterType, TrialType } from \"jspsych\";\n\nconst info = <const>{\n name: \"audio-button-response\",\n parameters: {\n /** The audio to be played. */\n stimulus: {\n type: ParameterType.AUDIO,\n pretty_name: \"Stimulus\",\n default: undefined,\n },\n /** Array containing the label(s) for the button(s). */\n choices: {\n type: ParameterType.STRING,\n pretty_name: \"Choices\",\n default: undefined,\n array: true,\n },\n /** The HTML for creating button. Can create own style. Use the \"%choice%\" string to indicate where the label from the choices parameter should be inserted. */\n button_html: {\n type: ParameterType.HTML_STRING,\n pretty_name: \"Button HTML\",\n default: '<button class=\"jspsych-btn\">%choice%</button>',\n array: true,\n },\n /** Any content here will be displayed below the stimulus. */\n prompt: {\n type: ParameterType.HTML_STRING,\n pretty_name: \"Prompt\",\n default: null,\n },\n /** The maximum duration to wait for a response. */\n trial_duration: {\n type: ParameterType.INT,\n pretty_name: \"Trial duration\",\n default: null,\n },\n /** Vertical margin of button. */\n margin_vertical: {\n type: ParameterType.STRING,\n pretty_name: \"Margin vertical\",\n default: \"0px\",\n },\n /** Horizontal margin of button. */\n margin_horizontal: {\n type: ParameterType.STRING,\n pretty_name: \"Margin horizontal\",\n default: \"8px\",\n },\n /** If true, the trial will end when user makes a response. */\n response_ends_trial: {\n type: ParameterType.BOOL,\n pretty_name: \"Response ends trial\",\n default: true,\n },\n /** If true, then the trial will end as soon as the audio file finishes playing. */\n trial_ends_after_audio: {\n type: ParameterType.BOOL,\n pretty_name: \"Trial ends after audio\",\n default: false,\n },\n /**\n * If true, then responses are allowed while the audio is playing.\n * If false, then the audio must finish playing before a response is accepted.\n */\n response_allowed_while_playing: {\n type: ParameterType.BOOL,\n pretty_name: \"Response allowed while playing\",\n default: true,\n },\n },\n};\n\ntype Info = typeof info;\n\n/**\n * **audio-button-response**\n *\n * jsPsych plugin for playing an audio file and getting a button response\n *\n * @author Kristin Diep\n * @see {@link https://www.jspsych.org/plugins/jspsych-audio-button-response/ audio-button-response plugin documentation on jspsych.org}\n */\nclass AudioButtonResponsePlugin implements JsPsychPlugin<Info> {\n static info = info;\n private audio;\n\n constructor(private jsPsych: JsPsych) {}\n\n trial(display_element: HTMLElement, trial: TrialType<Info>, on_load: () => void) {\n // hold the .resolve() function from the Promise that ends the trial\n let trial_complete;\n\n // setup stimulus\n var context = this.jsPsych.pluginAPI.audioContext();\n\n // store response\n var response = {\n rt: null,\n button: null,\n };\n\n // record webaudio context start time\n var startTime;\n\n // load audio file\n this.jsPsych.pluginAPI\n .getAudioBuffer(trial.stimulus)\n .then((buffer) => {\n if (context !== null) {\n this.audio = context.createBufferSource();\n this.audio.buffer = buffer;\n this.audio.connect(context.destination);\n } else {\n this.audio = buffer;\n this.audio.currentTime = 0;\n }\n setupTrial();\n })\n .catch((err) => {\n console.error(\n `Failed to load audio file \"${trial.stimulus}\". Try checking the file path. We recommend using the preload plugin to load audio files.`\n );\n console.error(err);\n });\n\n const setupTrial = () => {\n // set up end event if trial needs it\n if (trial.trial_ends_after_audio) {\n this.audio.addEventListener(\"ended\", end_trial);\n }\n\n // enable buttons after audio ends if necessary\n if (!trial.response_allowed_while_playing && !trial.trial_ends_after_audio) {\n this.audio.addEventListener(\"ended\", enable_buttons);\n }\n\n //display buttons\n var buttons = [];\n if (Array.isArray(trial.button_html)) {\n if (trial.button_html.length == trial.choices.length) {\n buttons = trial.button_html;\n } else {\n console.error(\n \"Error in audio-button-response plugin. The length of the button_html array does not equal the length of the choices array\"\n );\n }\n } else {\n for (var i = 0; i < trial.choices.length; i++) {\n buttons.push(trial.button_html);\n }\n }\n\n var html = '<div id=\"jspsych-audio-button-response-btngroup\">';\n for (var i = 0; i < trial.choices.length; i++) {\n var str = buttons[i].replace(/%choice%/g, trial.choices[i]);\n html +=\n '<div class=\"jspsych-audio-button-response-button\" style=\"cursor: pointer; display: inline-block; margin:' +\n trial.margin_vertical +\n \" \" +\n trial.margin_horizontal +\n '\" id=\"jspsych-audio-button-response-button-' +\n i +\n '\" data-choice=\"' +\n i +\n '\">' +\n str +\n \"</div>\";\n }\n html += \"</div>\";\n\n //show prompt if there is one\n if (trial.prompt !== null) {\n html += trial.prompt;\n }\n\n display_element.innerHTML = html;\n\n if (trial.response_allowed_while_playing) {\n enable_buttons();\n } else {\n disable_buttons();\n }\n\n // start time\n startTime = performance.now();\n\n // start audio\n if (context !== null) {\n startTime = context.currentTime;\n this.audio.start(startTime);\n } else {\n this.audio.play();\n }\n\n // end trial if time limit is set\n if (trial.trial_duration !== null) {\n this.jsPsych.pluginAPI.setTimeout(() => {\n end_trial();\n }, trial.trial_duration);\n }\n\n on_load();\n };\n\n // function to handle responses by the subject\n function after_response(choice) {\n // measure rt\n var endTime = performance.now();\n var rt = Math.round(endTime - startTime);\n if (context !== null) {\n endTime = context.currentTime;\n rt = Math.round((endTime - startTime) * 1000);\n }\n response.button = parseInt(choice);\n response.rt = rt;\n\n // disable all the buttons after a response\n disable_buttons();\n\n if (trial.response_ends_trial) {\n end_trial();\n }\n }\n\n // function to end trial when it is time\n const end_trial = () => {\n // kill any remaining setTimeout handlers\n this.jsPsych.pluginAPI.clearAllTimeouts();\n\n // stop the audio file if it is playing\n // remove end event listeners if they exist\n if (context !== null) {\n this.audio.stop();\n } else {\n this.audio.pause();\n }\n\n this.audio.removeEventListener(\"ended\", end_trial);\n this.audio.removeEventListener(\"ended\", enable_buttons);\n\n // gather the data to store for the trial\n var trial_data = {\n rt: response.rt,\n stimulus: trial.stimulus,\n response: response.button,\n };\n\n // clear the display\n display_element.innerHTML = \"\";\n\n // move on to the next trial\n this.jsPsych.finishTrial(trial_data);\n\n trial_complete();\n };\n\n function button_response(e) {\n var choice = e.currentTarget.getAttribute(\"data-choice\"); // don't use dataset for jsdom compatibility\n after_response(choice);\n }\n\n function disable_buttons() {\n var btns = document.querySelectorAll(\".jspsych-audio-button-response-button\");\n for (var i = 0; i < btns.length; i++) {\n var btn_el = btns[i].querySelector(\"button\");\n if (btn_el) {\n btn_el.disabled = true;\n }\n btns[i].removeEventListener(\"click\", button_response);\n }\n }\n\n function enable_buttons() {\n var btns = document.querySelectorAll(\".jspsych-audio-button-response-button\");\n for (var i = 0; i < btns.length; i++) {\n var btn_el = btns[i].querySelector(\"button\");\n if (btn_el) {\n btn_el.disabled = false;\n }\n btns[i].addEventListener(\"click\", button_response);\n }\n }\n\n return new Promise((resolve) => {\n trial_complete = resolve;\n });\n }\n\n simulate(\n trial: TrialType<Info>,\n simulation_mode,\n simulation_options: any,\n load_callback: () => void\n ) {\n if (simulation_mode == \"data-only\") {\n load_callback();\n this.simulate_data_only(trial, simulation_options);\n }\n if (simulation_mode == \"visual\") {\n this.simulate_visual(trial, simulation_options, load_callback);\n }\n }\n\n private create_simulation_data(trial: TrialType<Info>, simulation_options) {\n const default_data = {\n stimulus: trial.stimulus,\n rt: this.jsPsych.randomization.sampleExGaussian(500, 50, 1 / 150, true),\n response: this.jsPsych.randomization.randomInt(0, trial.choices.length - 1),\n };\n\n const data = this.jsPsych.pluginAPI.mergeSimulationData(default_data, simulation_options);\n\n this.jsPsych.pluginAPI.ensureSimulationDataConsistency(trial, data);\n\n return data;\n }\n\n private simulate_data_only(trial: TrialType<Info>, simulation_options) {\n const data = this.create_simulation_data(trial, simulation_options);\n\n this.jsPsych.finishTrial(data);\n }\n\n private simulate_visual(trial: TrialType<Info>, simulation_options, load_callback: () => void) {\n const data = this.create_simulation_data(trial, simulation_options);\n\n const display_element = this.jsPsych.getDisplayElement();\n\n const respond = () => {\n if (data.rt !== null) {\n this.jsPsych.pluginAPI.clickTarget(\n display_element.querySelector(`div[data-choice=\"${data.response}\"] button`),\n data.rt\n );\n }\n };\n\n this.trial(display_element, trial, () => {\n load_callback();\n if (!trial.response_allowed_while_playing) {\n this.audio.addEventListener(\"ended\", respond);\n } else {\n respond();\n }\n });\n }\n}\n\nexport default AudioButtonResponsePlugin;\n"],"names":["ParameterType"],"mappings":";;;;AAEA,MAAM,IAAI,GAAU;AAClB,IAAA,IAAI,EAAE,uBAAuB;AAC7B,IAAA,UAAU,EAAE;;AAEV,QAAA,QAAQ,EAAE;YACR,IAAI,EAAEA,qBAAa,CAAC,KAAK;AACzB,YAAA,WAAW,EAAE,UAAU;AACvB,YAAA,OAAO,EAAE,SAAS;AACnB,SAAA;;AAED,QAAA,OAAO,EAAE;YACP,IAAI,EAAEA,qBAAa,CAAC,MAAM;AAC1B,YAAA,WAAW,EAAE,SAAS;AACtB,YAAA,OAAO,EAAE,SAAS;AAClB,YAAA,KAAK,EAAE,IAAI;AACZ,SAAA;;AAED,QAAA,WAAW,EAAE;YACX,IAAI,EAAEA,qBAAa,CAAC,WAAW;AAC/B,YAAA,WAAW,EAAE,aAAa;AAC1B,YAAA,OAAO,EAAE,+CAA+C;AACxD,YAAA,KAAK,EAAE,IAAI;AACZ,SAAA;;AAED,QAAA,MAAM,EAAE;YACN,IAAI,EAAEA,qBAAa,CAAC,WAAW;AAC/B,YAAA,WAAW,EAAE,QAAQ;AACrB,YAAA,OAAO,EAAE,IAAI;AACd,SAAA;;AAED,QAAA,cAAc,EAAE;YACd,IAAI,EAAEA,qBAAa,CAAC,GAAG;AACvB,YAAA,WAAW,EAAE,gBAAgB;AAC7B,YAAA,OAAO,EAAE,IAAI;AACd,SAAA;;AAED,QAAA,eAAe,EAAE;YACf,IAAI,EAAEA,qBAAa,CAAC,MAAM;AAC1B,YAAA,WAAW,EAAE,iBAAiB;AAC9B,YAAA,OAAO,EAAE,KAAK;AACf,SAAA;;AAED,QAAA,iBAAiB,EAAE;YACjB,IAAI,EAAEA,qBAAa,CAAC,MAAM;AAC1B,YAAA,WAAW,EAAE,mBAAmB;AAChC,YAAA,OAAO,EAAE,KAAK;AACf,SAAA;;AAED,QAAA,mBAAmB,EAAE;YACnB,I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":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import { JsPsych, JsPsychPlugin, ParameterType, TrialType } from \"jspsych\";\n\nconst info = <const>{\n name: \"audio-button-response\",\n parameters: {\n /** The audio to be played. */\n stimulus: {\n type: ParameterType.AUDIO,\n pretty_name: \"Stimulus\",\n default: undefined,\n },\n /** Array containing the label(s) for the button(s). */\n choices: {\n type: ParameterType.STRING,\n pretty_name: \"Choices\",\n default: undefined,\n array: true,\n },\n /** The HTML for creating button. Can create own style. Use the \"%choice%\" string to indicate where the label from the choices parameter should be inserted. */\n button_html: {\n type: ParameterType.HTML_STRING,\n pretty_name: \"Button HTML\",\n default: '<button class=\"jspsych-btn\">%choice%</button>',\n array: true,\n },\n /** Any content here will be displayed below the stimulus. */\n prompt: {\n type: ParameterType.HTML_STRING,\n pretty_name: \"Prompt\",\n default: null,\n },\n /** The maximum duration to wait for a response. */\n trial_duration: {\n type: ParameterType.INT,\n pretty_name: \"Trial duration\",\n default: null,\n },\n /** Vertical margin of button. */\n margin_vertical: {\n type: ParameterType.STRING,\n pretty_name: \"Margin vertical\",\n default: \"0px\",\n },\n /** Horizontal margin of button. */\n margin_horizontal: {\n type: ParameterType.STRING,\n pretty_name: \"Margin horizontal\",\n default: \"8px\",\n },\n /** If true, the trial will end when user makes a response. */\n response_ends_trial: {\n type: ParameterType.BOOL,\n pretty_name: \"Response ends trial\",\n default: true,\n },\n /** If true, then the trial will end as soon as the audio file finishes playing. */\n trial_ends_after_audio: {\n type: ParameterType.BOOL,\n pretty_name: \"Trial ends after audio\",\n default: false,\n },\n /**\n * If true, then responses are allowed while the audio is playing.\n * If false, then the audio must finish playing before a response is accepted.\n */\n response_allowed_while_playing: {\n type: ParameterType.BOOL,\n pretty_name: \"Response allowed while playing\",\n default: true,\n },\n /** The delay of enabling button */\n enable_button_after: {\n type: ParameterType.INT,\n pretty_name: \"Enable button after\",\n default: 0,\n },\n },\n};\n\ntype Info = typeof info;\n\n/**\n * **audio-button-response**\n *\n * jsPsych plugin for playing an audio file and getting a button response\n *\n * @author Kristin Diep\n * @see {@link https://www.jspsych.org/plugins/jspsych-audio-button-response/ audio-button-response plugin documentation on jspsych.org}\n */\nclass AudioButtonResponsePlugin implements JsPsychPlugin<Info> {\n static info = info;\n private audio;\n\n constructor(private jsPsych: JsPsych) {}\n\n trial(display_element: HTMLElement, trial: TrialType<Info>, on_load: () => void) {\n // hold the .resolve() function from the Promise that ends the trial\n let trial_complete;\n\n // setup stimulus\n var context = this.jsPsych.pluginAPI.audioContext();\n\n // store response\n var response = {\n rt: null,\n button: null,\n };\n\n // record webaudio context start time\n var startTime;\n\n // load audio file\n this.jsPsych.pluginAPI\n .getAudioBuffer(trial.stimulus)\n .then((buffer) => {\n if (context !== null) {\n this.audio = context.createBufferSource();\n this.audio.buffer = buffer;\n this.audio.connect(context.destination);\n } else {\n this.audio = buffer;\n this.audio.currentTime = 0;\n }\n setupTrial();\n })\n .catch((err) => {\n console.error(\n `Failed to load audio file \"${trial.stimulus}\". Try checking the file path. We recommend using the preload plugin to load audio files.`\n );\n console.error(err);\n });\n\n const setupTrial = () => {\n // set up end event if trial needs it\n if (trial.trial_ends_after_audio) {\n this.audio.addEventListener(\"ended\", end_trial);\n }\n\n // enable buttons after audio ends if necessary\n if (!trial.response_allowed_while_playing && !trial.trial_ends_after_audio) {\n this.audio.addEventListener(\"ended\", enable_buttons);\n }\n\n //display buttons\n var buttons = [];\n if (Array.isArray(trial.button_html)) {\n if (trial.button_html.length == trial.choices.length) {\n buttons = trial.button_html;\n } else {\n console.error(\n \"Error in audio-button-response plugin. The length of the button_html array does not equal the length of the choices array\"\n );\n }\n } else {\n for (var i = 0; i < trial.choices.length; i++) {\n buttons.push(trial.button_html);\n }\n }\n\n var html = '<div id=\"jspsych-audio-button-response-btngroup\">';\n for (var i = 0; i < trial.choices.length; i++) {\n var str = buttons[i].replace(/%choice%/g, trial.choices[i]);\n html +=\n '<div class=\"jspsych-audio-button-response-button\" style=\"cursor: pointer; display: inline-block; margin:' +\n trial.margin_vertical +\n \" \" +\n trial.margin_horizontal +\n '\" id=\"jspsych-audio-button-response-button-' +\n i +\n '\" data-choice=\"' +\n i +\n '\">' +\n str +\n \"</div>\";\n }\n html += \"</div>\";\n\n //show prompt if there is one\n if (trial.prompt !== null) {\n html += trial.prompt;\n }\n\n display_element.innerHTML = html;\n\n if (trial.response_allowed_while_playing) {\n disable_buttons();\n enable_buttons();\n } else {\n disable_buttons();\n }\n\n // start time\n startTime = performance.now();\n\n // start audio\n if (context !== null) {\n startTime = context.currentTime;\n this.audio.start(startTime);\n } else {\n this.audio.play();\n }\n\n // end trial if time limit is set\n if (trial.trial_duration !== null) {\n this.jsPsych.pluginAPI.setTimeout(() => {\n end_trial();\n }, trial.trial_duration);\n }\n\n on_load();\n };\n\n // function to handle responses by the subject\n function after_response(choice) {\n // measure rt\n var endTime = performance.now();\n var rt = Math.round(endTime - startTime);\n if (context !== null) {\n endTime = context.currentTime;\n rt = Math.round((endTime - startTime) * 1000);\n }\n response.button = parseInt(choice);\n response.rt = rt;\n\n // disable all the buttons after a response\n disable_buttons();\n\n if (trial.response_ends_trial) {\n end_trial();\n }\n }\n\n // function to end trial when it is time\n const end_trial = () => {\n // kill any remaining setTimeout handlers\n this.jsPsych.pluginAPI.clearAllTimeouts();\n\n // stop the audio file if it is playing\n // remove end event listeners if they exist\n if (context !== null) {\n this.audio.stop();\n } else {\n this.audio.pause();\n }\n\n this.audio.removeEventListener(\"ended\", end_trial);\n this.audio.removeEventListener(\"ended\", enable_buttons);\n\n // gather the data to store for the trial\n var trial_data = {\n rt: response.rt,\n stimulus: trial.stimulus,\n response: response.button,\n };\n\n // clear the display\n display_element.innerHTML = \"\";\n\n // move on to the next trial\n this.jsPsych.finishTrial(trial_data);\n\n trial_complete();\n };\n\n const enable_buttons_with_delay = (delay: number) => {\n this.jsPsych.pluginAPI.setTimeout(enable_buttons_without_delay, delay);\n };\n\n function button_response(e) {\n var choice = e.currentTarget.getAttribute(\"data-choice\"); // don't use dataset for jsdom compatibility\n after_response(choice);\n }\n\n function disable_buttons() {\n var btns = document.querySelectorAll(\".jspsych-audio-button-response-button\");\n for (var i = 0; i < btns.length; i++) {\n var btn_el = btns[i].querySelector(\"button\");\n if (btn_el) {\n btn_el.disabled = true;\n }\n btns[i].removeEventListener(\"click\", button_response);\n }\n }\n\n function enable_buttons_without_delay() {\n var btns = document.querySelectorAll(\".jspsych-audio-button-response-button\");\n for (var i = 0; i < btns.length; i++) {\n var btn_el = btns[i].querySelector(\"button\");\n if (btn_el) {\n btn_el.disabled = false;\n }\n btns[i].addEventListener(\"click\", button_response);\n }\n }\n\n function enable_buttons() {\n if (trial.enable_button_after > 0) {\n enable_buttons_with_delay(trial.enable_button_after);\n } else {\n enable_buttons_without_delay();\n }\n }\n\n return new Promise((resolve) => {\n trial_complete = resolve;\n });\n }\n\n simulate(\n trial: TrialType<Info>,\n simulation_mode,\n simulation_options: any,\n load_callback: () => void\n ) {\n if (simulation_mode == \"data-only\") {\n load_callback();\n this.simulate_data_only(trial, simulation_options);\n }\n if (simulation_mode == \"visual\") {\n this.simulate_visual(trial, simulation_options, load_callback);\n }\n }\n\n private create_simulation_data(trial: TrialType<Info>, simulation_options) {\n const default_data = {\n stimulus: trial.stimulus,\n rt:\n this.jsPsych.randomization.sampleExGaussian(500, 50, 1 / 150, true) +\n trial.enable_button_after,\n response: this.jsPsych.randomization.randomInt(0, trial.choices.length - 1),\n };\n\n const data = this.jsPsych.pluginAPI.mergeSimulationData(default_data, simulation_options);\n\n this.jsPsych.pluginAPI.ensureSimulationDataConsistency(trial, data);\n\n return data;\n }\n\n private simulate_data_only(trial: TrialType<Info>, simulation_options) {\n const data = this.create_simulation_data(trial, simulation_options);\n\n this.jsPsych.finishTrial(data);\n }\n\n private simulate_visual(trial: TrialType<Info>, simulation_options, load_callback: () => void) {\n const data = this.create_simulation_data(trial, simulation_options);\n\n const display_element = this.jsPsych.getDisplayElement();\n\n const respond = () => {\n if (data.rt !== null) {\n this.jsPsych.pluginAPI.clickTarget(\n display_element.querySelector(`div[data-choice=\"${data.response}\"] button`),\n data.rt\n );\n }\n };\n\n this.trial(display_element, trial, () => {\n load_callback();\n if (!trial.response_allowed_while_playing) {\n this.audio.addEventListener(\"ended\", respond);\n } else {\n respond();\n }\n });\n }\n}\n\nexport default AudioButtonResponsePlugin;\n"],"names":["ParameterType"],"mappings":";;;;AAEA,MAAM,IAAI,GAAU;AAClB,IAAA,IAAI,EAAE,uBAAuB;AAC7B,IAAA,UAAU,EAAE;;AAEV,QAAA,QAAQ,EAAE;YACR,IAAI,EAAEA,qBAAa,CAAC,KAAK;AACzB,YAAA,WAAW,EAAE,UAAU;AACvB,YAAA,OAAO,EAAE,SAAS;AACnB,SAAA;;AAED,QAAA,OAAO,EAAE;YACP,IAAI,EAAEA,qBAAa,CAAC,MAAM;AAC1B,YAAA,WAAW,EAAE,SAAS;AACtB,YAAA,OAAO,EAAE,SAAS;AAClB,YAAA,KAAK,EAAE,IAAI;AACZ,SAAA;;AAED,QAAA,WAAW,EAAE;YACX,IAAI,EAAEA,qBAAa,CAAC,WAAW;AAC/B,YAAA,WAAW,EAAE,aAAa;AAC1B,YAAA,OAAO,EAAE,+CAA+C;AACxD,YAAA,KAAK,EAAE,IAAI;AACZ,SAAA;;AAED,QAAA,MAAM,EAAE;YACN,IAAI,EAAEA,qBAAa,CAAC,WAAW;AAC/B,YAAA,WAAW,EAAE,QAAQ;AACrB,YAAA,OAAO,EAAE,IAAI;AACd,SAAA;;AAED,QAAA,cAAc,EAAE;YACd,IAAI,EAAEA,qBAAa,CAAC,GAAG;AACvB,YAAA,WAAW,EAAE,gBAAgB;AAC7B,YAAA,OAAO,EAAE,IAAI;AACd,SAAA;;AAED,QAAA,eAAe,EAAE;YACf,IAAI,EAAEA,qBAAa,CAAC,MAAM;AAC1B,YAAA,WAAW,EAAE,iBAAiB;AAC9B,YAAA,OAAO,EAAE,KAAK;AACf,SAAA;;AAED,QAAA,iBAAiB,EAAE;YAC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,CAAC;QAEpE,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC;QAEzD,MAAM,OAAO,GAAG,MAAK;AACnB,YAAA,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,EAAE;gBACpB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAChC,eAAe,CAAC,aAAa,CAAC,oBAAoB,IAAI,CAAC,QAAQ,CAAW,SAAA,CAAA,CAAC,EAC3E,IAAI,CAAC,EAAE,CACR,CAAC;AACH,aAAA;AACH,SAAC,CAAC;QAEF,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,EAAE,MAAK;AACtC,YAAA,aAAa,EAAE,CAAC;AAChB,YAAA,IAAI,CAAC,KAAK,CAAC,8BAA8B,EAAE;gBACzC,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAC/C,aAAA;AAAM,iBAAA;AACL,gBAAA,OAAO,EAAE,CAAC;AACX,aAAA;AACH,SAAC,CAAC,CAAC;KACJ;;AArRM,yBAAI,CAAA,IAAA,GAAG,IAAI;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,161 +1,173 @@
1
- import { JsPsych, JsPsychPlugin, ParameterType, TrialType } from "jspsych";
2
- declare const info: {
3
- readonly name: "audio-button-response";
4
- readonly parameters: {
5
- /** The audio to be played. */
6
- readonly stimulus: {
7
- readonly type: ParameterType.AUDIO;
8
- readonly pretty_name: "Stimulus";
9
- readonly default: any;
10
- };
11
- /** Array containing the label(s) for the button(s). */
12
- readonly choices: {
13
- readonly type: ParameterType.STRING;
14
- readonly pretty_name: "Choices";
15
- readonly default: any;
16
- readonly array: true;
17
- };
18
- /** The HTML for creating button. Can create own style. Use the "%choice%" string to indicate where the label from the choices parameter should be inserted. */
19
- readonly button_html: {
20
- readonly type: ParameterType.HTML_STRING;
21
- readonly pretty_name: "Button HTML";
22
- readonly default: "<button class=\"jspsych-btn\">%choice%</button>";
23
- readonly array: true;
24
- };
25
- /** Any content here will be displayed below the stimulus. */
26
- readonly prompt: {
27
- readonly type: ParameterType.HTML_STRING;
28
- readonly pretty_name: "Prompt";
29
- readonly default: any;
30
- };
31
- /** The maximum duration to wait for a response. */
32
- readonly trial_duration: {
33
- readonly type: ParameterType.INT;
34
- readonly pretty_name: "Trial duration";
35
- readonly default: any;
36
- };
37
- /** Vertical margin of button. */
38
- readonly margin_vertical: {
39
- readonly type: ParameterType.STRING;
40
- readonly pretty_name: "Margin vertical";
41
- readonly default: "0px";
42
- };
43
- /** Horizontal margin of button. */
44
- readonly margin_horizontal: {
45
- readonly type: ParameterType.STRING;
46
- readonly pretty_name: "Margin horizontal";
47
- readonly default: "8px";
48
- };
49
- /** If true, the trial will end when user makes a response. */
50
- readonly response_ends_trial: {
51
- readonly type: ParameterType.BOOL;
52
- readonly pretty_name: "Response ends trial";
53
- readonly default: true;
54
- };
55
- /** If true, then the trial will end as soon as the audio file finishes playing. */
56
- readonly trial_ends_after_audio: {
57
- readonly type: ParameterType.BOOL;
58
- readonly pretty_name: "Trial ends after audio";
59
- readonly default: false;
60
- };
61
- /**
62
- * If true, then responses are allowed while the audio is playing.
63
- * If false, then the audio must finish playing before a response is accepted.
64
- */
65
- readonly response_allowed_while_playing: {
66
- readonly type: ParameterType.BOOL;
67
- readonly pretty_name: "Response allowed while playing";
68
- readonly default: true;
69
- };
70
- };
71
- };
72
- declare type Info = typeof info;
73
- /**
74
- * **audio-button-response**
75
- *
76
- * jsPsych plugin for playing an audio file and getting a button response
77
- *
78
- * @author Kristin Diep
79
- * @see {@link https://www.jspsych.org/plugins/jspsych-audio-button-response/ audio-button-response plugin documentation on jspsych.org}
80
- */
81
- declare class AudioButtonResponsePlugin implements JsPsychPlugin<Info> {
82
- private jsPsych;
83
- static info: {
84
- readonly name: "audio-button-response";
85
- readonly parameters: {
86
- /** The audio to be played. */
87
- readonly stimulus: {
88
- readonly type: ParameterType.AUDIO;
89
- readonly pretty_name: "Stimulus";
90
- readonly default: any;
91
- };
92
- /** Array containing the label(s) for the button(s). */
93
- readonly choices: {
94
- readonly type: ParameterType.STRING;
95
- readonly pretty_name: "Choices";
96
- readonly default: any;
97
- readonly array: true;
98
- };
99
- /** The HTML for creating button. Can create own style. Use the "%choice%" string to indicate where the label from the choices parameter should be inserted. */
100
- readonly button_html: {
101
- readonly type: ParameterType.HTML_STRING;
102
- readonly pretty_name: "Button HTML";
103
- readonly default: "<button class=\"jspsych-btn\">%choice%</button>";
104
- readonly array: true;
105
- };
106
- /** Any content here will be displayed below the stimulus. */
107
- readonly prompt: {
108
- readonly type: ParameterType.HTML_STRING;
109
- readonly pretty_name: "Prompt";
110
- readonly default: any;
111
- };
112
- /** The maximum duration to wait for a response. */
113
- readonly trial_duration: {
114
- readonly type: ParameterType.INT;
115
- readonly pretty_name: "Trial duration";
116
- readonly default: any;
117
- };
118
- /** Vertical margin of button. */
119
- readonly margin_vertical: {
120
- readonly type: ParameterType.STRING;
121
- readonly pretty_name: "Margin vertical";
122
- readonly default: "0px";
123
- };
124
- /** Horizontal margin of button. */
125
- readonly margin_horizontal: {
126
- readonly type: ParameterType.STRING;
127
- readonly pretty_name: "Margin horizontal";
128
- readonly default: "8px";
129
- };
130
- /** If true, the trial will end when user makes a response. */
131
- readonly response_ends_trial: {
132
- readonly type: ParameterType.BOOL;
133
- readonly pretty_name: "Response ends trial";
134
- readonly default: true;
135
- };
136
- /** If true, then the trial will end as soon as the audio file finishes playing. */
137
- readonly trial_ends_after_audio: {
138
- readonly type: ParameterType.BOOL;
139
- readonly pretty_name: "Trial ends after audio";
140
- readonly default: false;
141
- };
142
- /**
143
- * If true, then responses are allowed while the audio is playing.
144
- * If false, then the audio must finish playing before a response is accepted.
145
- */
146
- readonly response_allowed_while_playing: {
147
- readonly type: ParameterType.BOOL;
148
- readonly pretty_name: "Response allowed while playing";
149
- readonly default: true;
150
- };
151
- };
152
- };
153
- private audio;
154
- constructor(jsPsych: JsPsych);
155
- trial(display_element: HTMLElement, trial: TrialType<Info>, on_load: () => void): Promise<unknown>;
156
- simulate(trial: TrialType<Info>, simulation_mode: any, simulation_options: any, load_callback: () => void): void;
157
- private create_simulation_data;
158
- private simulate_data_only;
159
- private simulate_visual;
160
- }
161
- export default AudioButtonResponsePlugin;
1
+ import { JsPsych, JsPsychPlugin, ParameterType, TrialType } from "jspsych";
2
+ declare const info: {
3
+ readonly name: "audio-button-response";
4
+ readonly parameters: {
5
+ /** The audio to be played. */
6
+ readonly stimulus: {
7
+ readonly type: ParameterType.AUDIO;
8
+ readonly pretty_name: "Stimulus";
9
+ readonly default: any;
10
+ };
11
+ /** Array containing the label(s) for the button(s). */
12
+ readonly choices: {
13
+ readonly type: ParameterType.STRING;
14
+ readonly pretty_name: "Choices";
15
+ readonly default: any;
16
+ readonly array: true;
17
+ };
18
+ /** The HTML for creating button. Can create own style. Use the "%choice%" string to indicate where the label from the choices parameter should be inserted. */
19
+ readonly button_html: {
20
+ readonly type: ParameterType.HTML_STRING;
21
+ readonly pretty_name: "Button HTML";
22
+ readonly default: "<button class=\"jspsych-btn\">%choice%</button>";
23
+ readonly array: true;
24
+ };
25
+ /** Any content here will be displayed below the stimulus. */
26
+ readonly prompt: {
27
+ readonly type: ParameterType.HTML_STRING;
28
+ readonly pretty_name: "Prompt";
29
+ readonly default: any;
30
+ };
31
+ /** The maximum duration to wait for a response. */
32
+ readonly trial_duration: {
33
+ readonly type: ParameterType.INT;
34
+ readonly pretty_name: "Trial duration";
35
+ readonly default: any;
36
+ };
37
+ /** Vertical margin of button. */
38
+ readonly margin_vertical: {
39
+ readonly type: ParameterType.STRING;
40
+ readonly pretty_name: "Margin vertical";
41
+ readonly default: "0px";
42
+ };
43
+ /** Horizontal margin of button. */
44
+ readonly margin_horizontal: {
45
+ readonly type: ParameterType.STRING;
46
+ readonly pretty_name: "Margin horizontal";
47
+ readonly default: "8px";
48
+ };
49
+ /** If true, the trial will end when user makes a response. */
50
+ readonly response_ends_trial: {
51
+ readonly type: ParameterType.BOOL;
52
+ readonly pretty_name: "Response ends trial";
53
+ readonly default: true;
54
+ };
55
+ /** If true, then the trial will end as soon as the audio file finishes playing. */
56
+ readonly trial_ends_after_audio: {
57
+ readonly type: ParameterType.BOOL;
58
+ readonly pretty_name: "Trial ends after audio";
59
+ readonly default: false;
60
+ };
61
+ /**
62
+ * If true, then responses are allowed while the audio is playing.
63
+ * If false, then the audio must finish playing before a response is accepted.
64
+ */
65
+ readonly response_allowed_while_playing: {
66
+ readonly type: ParameterType.BOOL;
67
+ readonly pretty_name: "Response allowed while playing";
68
+ readonly default: true;
69
+ };
70
+ /** The delay of enabling button */
71
+ readonly enable_button_after: {
72
+ readonly type: ParameterType.INT;
73
+ readonly pretty_name: "Enable button after";
74
+ readonly default: 0;
75
+ };
76
+ };
77
+ };
78
+ type Info = typeof info;
79
+ /**
80
+ * **audio-button-response**
81
+ *
82
+ * jsPsych plugin for playing an audio file and getting a button response
83
+ *
84
+ * @author Kristin Diep
85
+ * @see {@link https://www.jspsych.org/plugins/jspsych-audio-button-response/ audio-button-response plugin documentation on jspsych.org}
86
+ */
87
+ declare class AudioButtonResponsePlugin implements JsPsychPlugin<Info> {
88
+ private jsPsych;
89
+ static info: {
90
+ readonly name: "audio-button-response";
91
+ readonly parameters: {
92
+ /** The audio to be played. */
93
+ readonly stimulus: {
94
+ readonly type: ParameterType.AUDIO;
95
+ readonly pretty_name: "Stimulus";
96
+ readonly default: any;
97
+ };
98
+ /** Array containing the label(s) for the button(s). */
99
+ readonly choices: {
100
+ readonly type: ParameterType.STRING;
101
+ readonly pretty_name: "Choices";
102
+ readonly default: any;
103
+ readonly array: true;
104
+ };
105
+ /** The HTML for creating button. Can create own style. Use the "%choice%" string to indicate where the label from the choices parameter should be inserted. */
106
+ readonly button_html: {
107
+ readonly type: ParameterType.HTML_STRING;
108
+ readonly pretty_name: "Button HTML";
109
+ readonly default: "<button class=\"jspsych-btn\">%choice%</button>";
110
+ readonly array: true;
111
+ };
112
+ /** Any content here will be displayed below the stimulus. */
113
+ readonly prompt: {
114
+ readonly type: ParameterType.HTML_STRING;
115
+ readonly pretty_name: "Prompt";
116
+ readonly default: any;
117
+ };
118
+ /** The maximum duration to wait for a response. */
119
+ readonly trial_duration: {
120
+ readonly type: ParameterType.INT;
121
+ readonly pretty_name: "Trial duration";
122
+ readonly default: any;
123
+ };
124
+ /** Vertical margin of button. */
125
+ readonly margin_vertical: {
126
+ readonly type: ParameterType.STRING;
127
+ readonly pretty_name: "Margin vertical";
128
+ readonly default: "0px";
129
+ };
130
+ /** Horizontal margin of button. */
131
+ readonly margin_horizontal: {
132
+ readonly type: ParameterType.STRING;
133
+ readonly pretty_name: "Margin horizontal";
134
+ readonly default: "8px";
135
+ };
136
+ /** If true, the trial will end when user makes a response. */
137
+ readonly response_ends_trial: {
138
+ readonly type: ParameterType.BOOL;
139
+ readonly pretty_name: "Response ends trial";
140
+ readonly default: true;
141
+ };
142
+ /** If true, then the trial will end as soon as the audio file finishes playing. */
143
+ readonly trial_ends_after_audio: {
144
+ readonly type: ParameterType.BOOL;
145
+ readonly pretty_name: "Trial ends after audio";
146
+ readonly default: false;
147
+ };
148
+ /**
149
+ * If true, then responses are allowed while the audio is playing.
150
+ * If false, then the audio must finish playing before a response is accepted.
151
+ */
152
+ readonly response_allowed_while_playing: {
153
+ readonly type: ParameterType.BOOL;
154
+ readonly pretty_name: "Response allowed while playing";
155
+ readonly default: true;
156
+ };
157
+ /** The delay of enabling button */
158
+ readonly enable_button_after: {
159
+ readonly type: ParameterType.INT;
160
+ readonly pretty_name: "Enable button after";
161
+ readonly default: 0;
162
+ };
163
+ };
164
+ };
165
+ private audio;
166
+ constructor(jsPsych: JsPsych);
167
+ trial(display_element: HTMLElement, trial: TrialType<Info>, on_load: () => void): Promise<unknown>;
168
+ simulate(trial: TrialType<Info>, simulation_mode: any, simulation_options: any, load_callback: () => void): void;
169
+ private create_simulation_data;
170
+ private simulate_data_only;
171
+ private simulate_visual;
172
+ }
173
+ export default AudioButtonResponsePlugin;