diff --git a/README.md b/README.md index c262ce69..23eaa371 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,175 @@ jsPsych is a JavaScript library for creating behavioral experiments that run in a web browser. jsPsych creates a framework for defining experiments and provides a set of flexible plugins that create different kinds of tasks a subject could complete during an experiment. By assembling different plugins together and customizing the parameters of each, it is possible to create many different types of experiments. + +Code Demos +---------- + +Demo 1 with the instructions plugin: +
+ + +
+ + +```javascript + + + + + + + + + + + + + + var trial = { + type: 'instructions', + pages: [ + 'Welcome to the experiment. Click next to begin.', + '
In this experiment, you will view a ' + + 'series of images and answer questions.
' + + 'Answer with the keys "y" or "n".', + 'Here is an example:

' + + '

' + + 'Is this person OLD or YOUNG?' + ], + show_clickable_nav: true + } + + jsPsych.init({ + timeline: [trial], + }); + + + + + + + + + + + +``` + + +
+
+ + +Demo 2 with the image-keyboard-response plugin: +
+ + +
+ + +```javascript + + + + + + + + var trial_1 = { + type: "image-keyboard-response", + stimulus: 'img/happy_face_1.jpg', + choices: [89, 78], + prompt: '

Is this face happy? Y or N.

' + } + + var trial_2 = { + type: 'image-keyboard-response', + stimulus: 'img/sad_face_2.jpg', + choices: [89, 78], // Y or N + prompt: '

Is this face happy? Y or N.

' + } + + var trial_3 = { + type: 'image-keyboard-response', + stimulus: 'img/happy_face_2.jpg', + choices: [89, 78], // Y or N + prompt: '

Is this face happy? Y or N.

', + } + + + jsPsych.init({ + timeline: [trial_1, trial_2, trial_3], + default_iti: 250 + }); + + + + + + + +``` +
+
+
+ + +And for a slightly longer experiment example, demo 3 with the html-keyboard-response plugin. Also shows data after experiment ends: +
+ + +
+ + +```javascript +var test_stimuli = [ + { stimulus: "<<<<<", data: { stim_type: 'congruent'} }, + { stimulus: ">>>>>", data: { stim_type: 'congruent'} }, + { stimulus: "<<><<", data: { stim_type: 'incongruent'} }, + { stimulus: ">><>>", data: { stim_type: 'incongruent'} } ]; + +var test = { + timeline: [{ + type: 'html-keyboard-response', + choices: [37, 39], + stimulus: jsPsych.timelineVariable('stimulus'), + data: jsPsych.timelineVariable('data'), + post_trial_gap: 1500, + response_ends_trial: true }], + timeline_variables: test_stimuli, + sample: {type: 'fixed-repetitions', size: 2} +}; + +var debrief = { + type: "html-keyboard-response", + stimulus: function() { + var congruent_rt = Math.round(jsPsych.data.get() + .filter({stim_type: 'congruent'}).select('rt').mean()); + var incongruent_rt = Math.round(jsPsych.data.get() + .filter({stim_type: 'incongruent'}).select('rt').mean()); + return "

Your average response time for congruent trials"+ + "was "+congruent_rt+"ms.

"+ + "

Your average response time for incongruent trials was"+ + ""incongruent_rt + "ms.

"; + } +}; + +var timeline = []; +timeline.push(test); +timeline.push(debrief); +jsPsych.init({ + timeline: timeline, + on_finish: function() { + jsPsych.data.displayData(); + } +}); +``` + +
+
+
+ Documentation ------------- diff --git a/examples/demos/demo_1.html b/examples/demos/demo_1.html new file mode 100644 index 00000000..504feeb6 --- /dev/null +++ b/examples/demos/demo_1.html @@ -0,0 +1,29 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/examples/demos/demo_2.html b/examples/demos/demo_2.html new file mode 100644 index 00000000..0613ee3e --- /dev/null +++ b/examples/demos/demo_2.html @@ -0,0 +1,43 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/demos/demo_3.html b/examples/demos/demo_3.html new file mode 100644 index 00000000..b0b84301 --- /dev/null +++ b/examples/demos/demo_3.html @@ -0,0 +1,58 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/plugins/jspsych-animation.js b/plugins/jspsych-animation.js index 0a916cb2..ef81f074 100644 --- a/plugins/jspsych-animation.js +++ b/plugins/jspsych-animation.js @@ -58,12 +58,6 @@ jsPsych.plugins.animation = (function() { plugin.trial = function(display_element, trial) { - trial.frame_time = trial.frame_time || 250; - trial.frame_isi = trial.frame_isi || 0; - trial.sequence_reps = trial.sequence_reps || 1; - trial.choices = trial.choices || jsPsych.ALL_KEYS; - trial.prompt = (typeof trial.prompt === 'undefined') ? "" : trial.prompt; - var interval_time = trial.frame_time + trial.frame_isi; var animate_frame = -1; var reps = 0; diff --git a/plugins/jspsych-audio-button-response.js b/plugins/jspsych-audio-button-response.js index 40e0411b..f51eaad4 100644 --- a/plugins/jspsych-audio-button-response.js +++ b/plugins/jspsych-audio-button-response.js @@ -30,39 +30,51 @@ jsPsych.plugins["audio-button-response"] = (function() { no_function: false, description: '' }, - button_html: { - type: jsPsych.plugins.parameterType.HTML_STRING, - default: '', - no_function: false, - array: true, - description: '' - }, - prompt: { - type: jsPsych.plugins.parameterType.STRING, - default: '', - no_function: false, - description: '' - }, - trial_duration: { - type: jsPsych.plugins.parameterType.INT, - default: -1, - no_function: false, - description: '' - }, - response_ends_trial: { - type: jsPsych.plugins.parameterType.BOOL, - default: true, - no_function: false, - description: '' - }, - trial_ends_after_audio: { - type: jsPsych.plugins.parameterType.BOOL, - default: false, - no_function: false, - description: '' - }, - } - } + button_html: { + type: jsPsych.plugins.parameterType.HTML_STRING, + default: '', + no_function: false, + array: true, + description: '' + }, + prompt: { + type: jsPsych.plugins.parameterType.STRING, + default: '', + no_function: false, + description: '' + }, + trial_duration: { + type: jsPsych.plugins.parameterType.INT, + default: -1, + no_function: false, + description: '' + }, + margin_vertical: { + type: jsPsych.parameterType.STRING, + default: '0px', + no_function: false, + description: '' + }, + margin_horizontal: { + type: jsPsych.parameterType.STRING, + default: '8px', + no_function: false, + description: '' + }, + response_ends_trial: { + type: jsPsych.plugins.parameterType.BOOL, + default: true, + no_function: false, + description: '' + }, + trial_ends_after_audio: { + type: jsPsych.plugins.parameterType.BOOL, + default: false, + no_function: false, + description: '' + }, + } + } plugin.trial = function(display_element, trial) { diff --git a/plugins/jspsych-audio-keyboard-response.js b/plugins/jspsych-audio-keyboard-response.js index cc5f2c64..e44f53df 100644 --- a/plugins/jspsych-audio-keyboard-response.js +++ b/plugins/jspsych-audio-keyboard-response.js @@ -60,13 +60,6 @@ jsPsych.plugins["audio-keyboard-response"] = (function() { plugin.trial = function(display_element, trial) { - // default parameters - trial.choices = trial.choices || jsPsych.ALL_KEYS; - trial.response_ends_trial = (typeof trial.response_ends_trial === 'undefined') ? true : trial.response_ends_trial; - trial.trial_ends_after_audio = (typeof trial.trial_ends_after_audio === 'undefined') ? false : trial.trial_ends_after_audio; - trial.trial_duration = trial.trial_duration || -1; // if -1, then wait for response forever - trial.prompt = (typeof trial.prompt === 'undefined') ? "" : trial.prompt; - // setup stimulus var context = jsPsych.pluginAPI.audioContext(); if(context !== null){ diff --git a/plugins/jspsych-audio-slider-response.js b/plugins/jspsych-audio-slider-response.js index 33a0e266..2fe91f54 100644 --- a/plugins/jspsych-audio-slider-response.js +++ b/plugins/jspsych-audio-slider-response.js @@ -19,6 +19,30 @@ jsPsych.plugins['audio-slider-response'] = (function() { no_function: false, description: '' }, + min: { + type: jsPsych.plugins.parameterType.INT, + default: 0, + no_function: false, + description: '' + }, + max: { + type: jsPsych.plugins.parameterType.INT, + default: 100, + no_function: false, + description: '' + }, + step: { + type: jsPsych.plugins.parameterType.INT, + default: 1, + no_function: false, + description: '' + }, + button_label: { + type: jsPsych.plugins.parameterType.STRING, + default: 'Next', + no_function: false, + description: '' + }, trial_duration: { type: jsPsych.plugins.parameterType.INT, default: -1, @@ -37,21 +61,17 @@ jsPsych.plugins['audio-slider-response'] = (function() { no_function: false, description: '' }, + prompt: { + type: jsPsych.plugins.parameterType.STRING, + default: '', + no_function: false, + description: '' + } } } plugin.trial = function(display_element, trial) { - trial.min = trial.min || 0; - trial.max = trial.max || 100; - trial.step = trial.step || 1; - trial.button_label = typeof trial.button_label === 'undefined' ? 'Next' : trial.button_label; - trial.response_ends_trial = (typeof trial.response_ends_trial == 'undefined') ? true : trial.response_ends_trial; - trial.trial_ends_after_audio = (typeof trial.trial_ends_after_audio === 'undefined') ? false : trial.trial_ends_after_audio; - trial.stimulus_duration = trial.stimulus_duration || -1; - trial.trial_duration = trial.trial_duration || -1; - trial.prompt = trial.prompt || ""; - // setup stimulus var context = jsPsych.pluginAPI.audioContext(); if(context !== null){ diff --git a/plugins/jspsych-call-function.js b/plugins/jspsych-call-function.js index 214976dc..ae329dae 100644 --- a/plugins/jspsych-call-function.js +++ b/plugins/jspsych-call-function.js @@ -20,17 +20,12 @@ jsPsych.plugins['call-function'] = (function() { default: undefined, no_function: false, description: '' - } + }, } } plugin.trial = function(display_element, trial) { - - // a rare case where we override the default experiment level - // value of this parameter, since this plugin should be invisible - // to the subject of the experiment - trial.post_trial_gap = typeof trial.post_trial_gap == 'undefined' ? 0 : trial.post_trial_gap - + trial.post_trial_gap = 0; var return_val = trial.func(); var trial_data = { diff --git a/plugins/jspsych-categorize-animation.js b/plugins/jspsych-categorize-animation.js index ea9a4e43..670bf47d 100644 --- a/plugins/jspsych-categorize-animation.js +++ b/plugins/jspsych-categorize-animation.js @@ -55,7 +55,7 @@ jsPsych.plugins["categorize-animation"] = (function() { }, frame_time: { type: jsPsych.plugins.parameterType.INT, - default: 250, + default: 500, no_function: false, description: '' }, @@ -88,18 +88,6 @@ jsPsych.plugins["categorize-animation"] = (function() { plugin.trial = function(display_element, trial) { - // set default values - trial.choices = trial.choices || jsPsych.ALL_KEYS; - trial.sequence_reps = trial.sequence_reps || 1; - trial.key_answer = trial.key_answer; - trial.text_answer = (typeof trial.text_answer === 'undefined') ? "" : trial.text_answer; - trial.correct_text = trial.correct_text || "Correct."; - trial.incorrect_text = trial.incorrect_text || "Wrong."; - trial.allow_response_before_complete = trial.allow_response_before_complete || false; - trial.frame_time = trial.frame_time || 500; - trial.feedback_duration = trial.feedback_duration || 2000; - trial.prompt = (typeof trial.prompt === 'undefined') ? '' : trial.prompt; - var animate_frame = -1; var reps = 0; diff --git a/plugins/jspsych-categorize-html.js b/plugins/jspsych-categorize-html.js index 6643fb00..6557d545 100644 --- a/plugins/jspsych-categorize-html.js +++ b/plugins/jspsych-categorize-html.js @@ -41,13 +41,13 @@ jsPsych.plugins['categorize-html'] = (function() { }, correct_text: { type: jsPsych.plugins.parameterType.STRING, - default: 'Correct.', + default: "

Correct

", no_function: false, description: '' }, incorrect_text: { type: jsPsych.plugins.parameterType.STRING, - default: 'Wrong.', + default: "

Incorrect

", no_function: false, description: '' }, @@ -77,7 +77,7 @@ jsPsych.plugins['categorize-html'] = (function() { }, timeout_message: { type: jsPsych.plugins.parameterType.STRING, - default: 'Please respond faster.', + default: "

Please respond faster.

", no_function: false, description: '' }, @@ -104,21 +104,6 @@ jsPsych.plugins['categorize-html'] = (function() { plugin.trial = function(display_element, trial) { - // default parameters - trial.choices = trial.choices || jsPsych.ALL_KEYS; - trial.text_answer = (typeof trial.text_answer === 'undefined') ? "" : trial.text_answer; - trial.correct_text = (typeof trial.correct_text === 'undefined') ? "

Correct

" : trial.correct_text; - trial.incorrect_text = (typeof trial.incorrect_text === 'undefined') ? "

Incorrect

" : trial.incorrect_text; - trial.show_stim_with_feedback = (typeof trial.show_stim_with_feedback === 'undefined') ? true : trial.show_stim_with_feedback; - trial.force_correct_button_press = (typeof trial.force_correct_button_press === 'undefined') ? false : trial.force_correct_button_press; - trial.prompt = (typeof trial.prompt === 'undefined') ? '' : trial.prompt; - trial.show_feedback_on_timeout = (typeof trial.show_feedback_on_timeout === 'undefined') ? false : trial.show_feedback_on_timeout; - trial.timeout_message = trial.timeout_message || "

Please respond faster.

"; - // timing params - trial.stimulus_duration = trial.stimulus_duration || -1; // default is to show image until response - trial.trial_duration = trial.trial_duration || -1; // default is no max response time - trial.feedback_duration = trial.feedback_duration || 2000; - display_element.innerHTML = '
'+trial.stimulus+'
'; // hide image after time if the timing parameter is set diff --git a/plugins/jspsych-categorize-image.js b/plugins/jspsych-categorize-image.js index 217960b2..5f59f68d 100644 --- a/plugins/jspsych-categorize-image.js +++ b/plugins/jspsych-categorize-image.js @@ -43,13 +43,13 @@ jsPsych.plugins['categorize-image'] = (function() { }, correct_text: { type: jsPsych.plugins.parameterType.STRING, - default: 'Correct.', + default: "

Correct

", no_function: false, description: '' }, incorrect_text: { type: jsPsych.plugins.parameterType.STRING, - default: 'Wrong.', + default: "

Incorrect

", no_function: false, description: '' }, @@ -79,7 +79,7 @@ jsPsych.plugins['categorize-image'] = (function() { }, timeout_message: { type: jsPsych.plugins.parameterType.STRING, - default: 'Please respond faster.', + default: "

Please respond faster.

", no_function: false, description: '' }, @@ -106,21 +106,6 @@ jsPsych.plugins['categorize-image'] = (function() { plugin.trial = function(display_element, trial) { - // default parameters - trial.choices = trial.choices || jsPsych.ALL_KEYS; - trial.text_answer = (typeof trial.text_answer === 'undefined') ? "" : trial.text_answer; - trial.correct_text = (typeof trial.correct_text === 'undefined') ? "

Correct

" : trial.correct_text; - trial.incorrect_text = (typeof trial.incorrect_text === 'undefined') ? "

Incorrect

" : trial.incorrect_text; - trial.show_stim_with_feedback = (typeof trial.show_stim_with_feedback === 'undefined') ? true : trial.show_stim_with_feedback; - trial.force_correct_button_press = (typeof trial.force_correct_button_press === 'undefined') ? false : trial.force_correct_button_press; - trial.prompt = (typeof trial.prompt === 'undefined') ? '' : trial.prompt; - trial.show_feedback_on_timeout = (typeof trial.show_feedback_on_timeout === 'undefined') ? false : trial.show_feedback_on_timeout; - trial.timeout_message = trial.timeout_message || "

Please respond faster.

"; - // timing params - trial.stimulus_duration = trial.stimulus_duration || -1; // default is to show image until response - trial.trial_duration = trial.trial_duration || -1; // default is no max response time - trial.feedback_duration = trial.feedback_duration || 2000; - display_element.innerHTML = ''; // hide image after time if the timing parameter is set diff --git a/plugins/jspsych-external-html.js b/plugins/jspsych-external-html.js index 28c1c63f..4683480b 100644 --- a/plugins/jspsych-external-html.js +++ b/plugins/jspsych-external-html.js @@ -34,7 +34,7 @@ jsPsych.plugins['external-html'] = (function() { }, check_fn: { type: jsPsych.plugins.parameterType.FUNCTION, - default: 'function() { return true; }', + default: function() { return true; }, no_function: false, description: '' }, @@ -49,11 +49,6 @@ jsPsych.plugins['external-html'] = (function() { plugin.trial = function(display_element, trial) { - // default parameters - trial.check_fn = trial.check_fn || function() { return true; } - trial.force_refresh = (typeof trial.force_refresh === 'undefined') ? false : trial.force_refresh - - var url = trial.url; if (trial.force_refresh) { url = trial.url + "?time=" + (new Date().getTime()); diff --git a/plugins/jspsych-free-sort.js b/plugins/jspsych-free-sort.js index fa63c60c..1c18e0e6 100644 --- a/plugins/jspsych-free-sort.js +++ b/plugins/jspsych-free-sort.js @@ -72,15 +72,6 @@ jsPsych.plugins['free-sort'] = (function() { plugin.trial = function(display_element, trial) { - // default values - trial.stim_height = trial.stim_height || 100; - trial.stim_width = trial.stim_width || 100; - trial.prompt = (typeof trial.prompt === 'undefined') ? '' : trial.prompt; - trial.prompt_location = trial.prompt_location || "above"; - trial.sort_area_width = trial.sort_area_width || 800; - trial.sort_area_height = trial.sort_area_height || 800; - trial.button_label = typeof trial.button_label === 'undefined' ? 'Done' : trial.button_label; - var start_time = (new Date()).getTime(); var html = ""; diff --git a/plugins/jspsych-fullscreen.js b/plugins/jspsych-fullscreen.js index 28684f17..9665a9c3 100644 --- a/plugins/jspsych-fullscreen.js +++ b/plugins/jspsych-fullscreen.js @@ -46,11 +46,6 @@ jsPsych.plugins.fullscreen = (function() { plugin.trial = function(display_element, trial) { - trial.fullscreen_mode = typeof trial.fullscreen_mode === 'undefined' ? true : trial.fullscreen_mode; - trial.message = trial.message || '

The experiment will switch to full screen mode when you press the button below

'; - trial.button_label = trial.button_label || 'Go'; - trial.delay_after = trial.delay_after || 1000; - // check if keys are allowed in fullscreen mode var keyboardNotAllowed = typeof Element !== 'undefined' && 'ALLOW_KEYBOARD_INPUT' in Element; if (keyboardNotAllowed) { diff --git a/plugins/jspsych-html-button-response.js b/plugins/jspsych-html-button-response.js index 881cbef8..7ba272ab 100644 --- a/plugins/jspsych-html-button-response.js +++ b/plugins/jspsych-html-button-response.js @@ -42,6 +42,18 @@ jsPsych.plugins["html-button-response"] = (function() { no_function: false, description: '' }, + margin_vertical: { + type: jsPsych.plugins.parameterType.STRING, + default: '0px', + no_function: false, + description: '' + }, + margin_horizontal: { + type: jsPsych.plugins.parameterType.STRING, + default: '8px', + no_function: false, + description: '' + }, stimulus_duration: { type: jsPsych.plugins.parameterType.INT, default: -1, @@ -65,15 +77,6 @@ jsPsych.plugins["html-button-response"] = (function() { plugin.trial = function(display_element, trial) { - // default trial parameters - trial.button_html = trial.button_html || ''; - trial.response_ends_trial = (typeof trial.response_ends_trial === 'undefined') ? true : trial.response_ends_trial; - trial.stimulus_duration = trial.stimulus_duration || -1; // if -1, then show indefinitely - trial.trial_duration = trial.trial_duration || -1; // if -1, then wait for response forever - trial.prompt = (typeof trial.prompt === 'undefined') ? "" : trial.prompt; - trial.margin_vertical = trial.margin_vertical || "0px"; - trial.margin_horizontal = trial.margin_horizontal || "8px"; - // display stimulus display_element.innerHTML = '
'+trial.stimulus+'
'; diff --git a/plugins/jspsych-html-keyboard-response.js b/plugins/jspsych-html-keyboard-response.js index a0a5dcc1..5d987689 100644 --- a/plugins/jspsych-html-keyboard-response.js +++ b/plugins/jspsych-html-keyboard-response.js @@ -60,13 +60,6 @@ jsPsych.plugins["html-keyboard-response"] = (function() { plugin.trial = function(display_element, trial) { - // set default values for the parameters - trial.choices = trial.choices || jsPsych.ALL_KEYS; - trial.response_ends_trial = (typeof trial.response_ends_trial == 'undefined') ? true : trial.response_ends_trial; - trial.stimulus_duration = trial.stimulus_duration || -1; - trial.trial_duration = trial.trial_duration || -1; - trial.prompt = trial.prompt || ""; - var new_html = '
'+trial.stimulus+'
'; // add prompt diff --git a/plugins/jspsych-html-slider-response.js b/plugins/jspsych-html-slider-response.js index 45ee5236..65b543a9 100644 --- a/plugins/jspsych-html-slider-response.js +++ b/plugins/jspsych-html-slider-response.js @@ -43,7 +43,7 @@ jsPsych.plugins['html-slider-response'] = (function() { }, labels: { type: jsPsych.plugins.parameterType.KEYCODE, - default: [], + default: undefined, array: true, no_function: false, description: '' @@ -84,17 +84,6 @@ jsPsych.plugins['html-slider-response'] = (function() { plugin.trial = function(display_element, trial) { - trial.min = trial.min || 0; - trial.max = trial.max || 100; - trial.step = trial.step || 1; - trial.labels = trial.labels || []; - trial.button_label = typeof trial.button_label === 'undefined' ? 'Next' : trial.button_label; - trial.response_ends_trial = (typeof trial.response_ends_trial == 'undefined') ? true : trial.response_ends_trial; - trial.stimulus_duration = trial.stimulus_duration || -1; - trial.trial_duration = trial.trial_duration || -1; - trial.prompt = trial.prompt || ""; - - var html = '
'; html += '
' + trial.stimulus + '
'; html += '
'; diff --git a/plugins/jspsych-iat-html.js b/plugins/jspsych-iat-html.js index 1d6ea570..2ab79be6 100644 --- a/plugins/jspsych-iat-html.js +++ b/plugins/jspsych-iat-html.js @@ -104,21 +104,6 @@ plugin.trial = function(display_element, trial) { - // set default values for the parameters - trial.left_category_key = trial.left_category_key || 'E'; - trial.right_category_key = trial.right_category_key || 'I'; - trial.left_category_label = trial.left_category_label || ['left']; - trial.right_category_label = trial.right_category_label || ['right']; - trial.key_to_move_forward = trial.key_to_move_forward || jsPsych.ALL_KEYS; - trial.display_feedback = typeof trial.display_feedback == 'undefined' ? false : trial.display_feedback; - trial.html_when_wrong = trial.html_when_wrong || 'X'; - trial.bottom_instructions = trial.bottom_instructions || "

If you press the wrong key, a red X will appear. Press any key to continue.

"; - trial.force_correct_key_press = trial.force_correct_key_press || false; //If true, key_to_move_forward is no longer needed - trial.stim_key_association = trial.stim_key_association || 'undefined'; - trial.response_ends_trial = (typeof trial.response_ends_trial == 'undefined') ? true : trial.response_ends_trial; - trial.trial_duration = trial.trial_duration || -1; - trial.key_to_move_forward = trial.key_to_move_forward || jsPsych.ALL_KEYS; - var html_str = ""; html_str += "

" + trial.stimulus + "

"; diff --git a/plugins/jspsych-iat-image.js b/plugins/jspsych-iat-image.js index 66991a25..446d912e 100644 --- a/plugins/jspsych-iat-image.js +++ b/plugins/jspsych-iat-image.js @@ -106,21 +106,6 @@ plugin.trial = function(display_element, trial) { - // set default values for the parameters - trial.left_category_key = trial.left_category_key || 'E'; - trial.right_category_key = trial.right_category_key || 'I'; - trial.left_category_label = trial.left_category_label || ['left']; - trial.right_category_label = trial.right_category_label || ['right']; - trial.key_to_move_forward = trial.key_to_move_forward || jsPsych.ALL_KEYS; - trial.display_feedback = typeof trial.display_feedback == 'undefined' ? false : trial.display_feedback; - trial.html_when_wrong = trial.html_when_wrong || 'X'; - trial.bottom_instructions = trial.bottom_instructions || "

If you press the wrong key, a red X will appear. Press any key to continue.

"; - trial.force_correct_key_press = trial.force_correct_key_press || false; //If true, key_to_move_forward is no longer needed - trial.stim_key_association = trial.stim_key_association || 'undefined'; - trial.response_ends_trial = (typeof trial.response_ends_trial == 'undefined') ? true : trial.response_ends_trial; - trial.trial_duration = trial.trial_duration || -1; - trial.key_to_move_forward = trial.key_to_move_forward || jsPsych.ALL_KEYS; - var html_str = ""; html_str += "
"; diff --git a/plugins/jspsych-image-button-response.js b/plugins/jspsych-image-button-response.js index 1c4bd508..27b5db53 100644 --- a/plugins/jspsych-image-button-response.js +++ b/plugins/jspsych-image-button-response.js @@ -56,6 +56,18 @@ jsPsych.plugins["image-button-response"] = (function() { no_function: false, description: '' }, + margin_vertical: { + type: jsPsych.plugins.parameterType.STRING, + default: '0px', + no_function: false, + description: '' + }, + margin_horizontal: { + type: jsPsych.plugins.parameterType.STRING, + default: '8px', + no_function: false, + description: '' + }, response_ends_trial: { type: jsPsych.plugins.parameterType.BOOL, default: true, @@ -74,15 +86,6 @@ jsPsych.plugins["image-button-response"] = (function() { console.error('Required parameter "stimulus" missing in image-button-response'); } - // default trial parameters - trial.button_html = trial.button_html || ''; - trial.response_ends_trial = (typeof trial.response_ends_trial === 'undefined') ? true : trial.response_ends_trial; - trial.stimulus_duration = trial.stimulus_duration || -1; // if -1, then show indefinitely - trial.trial_duration = trial.trial_duration || -1; // if -1, then wait for response forever - trial.prompt = (typeof trial.prompt === 'undefined') ? "" : trial.prompt; - trial.margin_vertical = trial.margin_vertical || "0px"; - trial.margin_horizontal = trial.margin_horizontal || "8px"; - // display stimulus var html = ''; diff --git a/plugins/jspsych-image-slider-response.js b/plugins/jspsych-image-slider-response.js index 18bb1eb0..2182b4f2 100644 --- a/plugins/jspsych-image-slider-response.js +++ b/plugins/jspsych-image-slider-response.js @@ -86,17 +86,6 @@ jsPsych.plugins['image-slider-response'] = (function() { plugin.trial = function(display_element, trial) { - - trial.min = trial.min || 0; - trial.max = trial.max || 100; - trial.step = trial.step || 1; - trial.labels = trial.labels || []; - trial.button_label = typeof trial.button_label === 'undefined' ? 'Next' : trial.button_label; - trial.response_ends_trial = (typeof trial.response_ends_trial == 'undefined') ? true : trial.response_ends_trial; - trial.stimulus_duration = trial.stimulus_duration || -1; - trial.trial_duration = trial.trial_duration || -1; - trial.prompt = trial.prompt || ""; - var html = '
'; html += '
'; html += '
'; diff --git a/plugins/jspsych-instructions.js b/plugins/jspsych-instructions.js index 48b9e938..02044fd8 100644 --- a/plugins/jspsych-instructions.js +++ b/plugins/jspsych-instructions.js @@ -71,14 +71,6 @@ jsPsych.plugins.instructions = (function() { plugin.trial = function(display_element, trial) { - trial.key_forward = trial.key_forward || 'rightarrow'; - trial.key_backward = trial.key_backward || 'leftarrow'; - trial.allow_backward = (typeof trial.allow_backward === 'undefined') ? true : trial.allow_backward; - trial.allow_keys = (typeof trial.allow_keys === 'undefined') ? true : trial.allow_keys; - trial.show_clickable_nav = (typeof trial.show_clickable_nav === 'undefined') ? false : trial.show_clickable_nav; - trial.button_label_previous = (typeof trial.button_label_previous === 'undefined') ? 'Previous' : trial.button_label_previous; - trial.button_label_next = (typeof trial.button_label_next === 'undefined') ? 'Next' : trial.button_label_next; - var current_page = 0; var view_history = []; diff --git a/plugins/jspsych-reconstruction.js b/plugins/jspsych-reconstruction.js index f4403a70..91c23476 100644 --- a/plugins/jspsych-reconstruction.js +++ b/plugins/jspsych-reconstruction.js @@ -59,13 +59,6 @@ jsPsych.plugins['reconstruction'] = (function() { plugin.trial = function(display_element, trial) { - // default parameter values - trial.starting_value = (typeof trial.starting_value == 'undefined') ? 0.5 : trial.starting_value; - trial.step_size = trial.step_size || 0.05; - trial.key_increase = trial.key_increase || 'h'; - trial.key_decrease = trial.key_decrease || 'g'; - trial.button_label = typeof trial.button_label === 'undefined' ? 'Next' : trial.button_label; - // if any trial variables are functions // this evaluates the function and replaces // it with the output of the function diff --git a/plugins/jspsych-resize.js b/plugins/jspsych-resize.js index bda3d25b..bb88171c 100644 --- a/plugins/jspsych-resize.js +++ b/plugins/jspsych-resize.js @@ -57,14 +57,6 @@ jsPsych.plugins["resize"] = (function() { plugin.trial = function(display_element, trial) { - // default trial paramters - trial.item_height = trial.item_height || 1; - trial.item_width = trial.item_width || 1; - trial.prompt = trial.prompt || ' '; - trial.pixels_per_unit = trial.pixels_per_unit || 100; - trial.starting_size = trial.starting_size || 100; - trial.button_label = trial.button_label || "Done"; - var aspect_ratio = trial.item_width / trial.item_height; // variables to determine div size diff --git a/plugins/jspsych-same-different-html.js b/plugins/jspsych-same-different-html.js index b1cbaf14..7055fd17 100644 --- a/plugins/jspsych-same-different-html.js +++ b/plugins/jspsych-same-different-html.js @@ -71,15 +71,6 @@ jsPsych.plugins['same-different-image'] = (function() { plugin.trial = function(display_element, trial) { - // default parameters - trial.same_key = trial.same_key || 81; // default is 'q' - trial.different_key = trial.different_key || 80; // default is 'p' - trial.advance_key = trial.advance_key || jsPsych.ALL_KEYS - trial.first_stim_duration = trial.first_stim_duration || 1000; // if -1, the first stim is shown until any key is pressed - trial.second_stim_duration = trial.second_stim_duration || 1000; // if -1, then second stim is shown until response. - trial.gap_duration = trial.gap_duration || 500; - trial.prompt = (typeof trial.prompt === 'undefined') ? "" : trial.prompt; - display_element.innerHTML = '
'+trial.stimuli[0]+'
'; var first_stim_info; diff --git a/plugins/jspsych-same-different-image.js b/plugins/jspsych-same-different-image.js index f9567f32..09e10001 100644 --- a/plugins/jspsych-same-different-image.js +++ b/plugins/jspsych-same-different-image.js @@ -62,6 +62,13 @@ jsPsych.plugins['same-different-image'] = (function() { no_function: false, description: '' }, + advance_key: { + type: jsPsych.plugins.parameterType.KEYCODE, + array: true, + default: jsPsych.ALL_KEYS, + no_function: false, + description: '' + }, prompt: { type: jsPsych.plugins.parameterType.STRING, default: '', @@ -73,15 +80,6 @@ jsPsych.plugins['same-different-image'] = (function() { plugin.trial = function(display_element, trial) { - // default parameters - trial.same_key = trial.same_key || 81; // default is 'q' - trial.different_key = trial.different_key || 80; // default is 'p' - trial.advance_key = trial.advance_key || jsPsych.ALL_KEYS - trial.first_stim_duration = trial.first_stim_duration || 1000; // if -1, the first stim is shown until any key is pressed - trial.second_stim_duration = trial.second_stim_duration || 1000; // if -1, then second stim is shown until response. - trial.gap_duration = trial.gap_duration || 500; - trial.prompt = (typeof trial.prompt === 'undefined') ? "" : trial.prompt; - display_element.innerHTML = ''; var first_stim_info; diff --git a/plugins/jspsych-serial-reaction-time-mouse.js b/plugins/jspsych-serial-reaction-time-mouse.js index 858522b2..63d58f45 100644 --- a/plugins/jspsych-serial-reaction-time-mouse.js +++ b/plugins/jspsych-serial-reaction-time-mouse.js @@ -16,13 +16,6 @@ jsPsych.plugins["serial-reaction-time-mouse"] = (function() { name: 'serial-reaction-time-mouse', description: '', parameters: { - grid: { - type: jsPsych.plugins.parameterType.BOOL, - array: true, - default: [[1,1,1,1]], - no_function: false, - description: '' - }, target: { type: jsPsych.plugins.parameterType.INT, array: true, @@ -30,6 +23,13 @@ jsPsych.plugins["serial-reaction-time-mouse"] = (function() { no_function: false, description: '' }, + grid: { + type: jsPsych.plugins.parameterType.BOOL, + array: true, + default: [[1,1,1,1]], + no_function: false, + description: '' + }, grid_square_size: { type: jsPsych.plugins.parameterType.INT, default: 100, @@ -48,7 +48,7 @@ jsPsych.plugins["serial-reaction-time-mouse"] = (function() { no_function: false, description: '' }, - timing_pre_target: { + pre_target_duration: { type: jsPsych.plugins.parameterType.INT, default: 0, no_function: false, @@ -83,16 +83,6 @@ jsPsych.plugins["serial-reaction-time-mouse"] = (function() { plugin.trial = function(display_element, trial) { - trial.grid = trial.grid || [[1,1,1,1]]; - trial.grid_square_size = trial.grid_square_size || 100; - trial.target_color = trial.target_color || "#999"; - trial.response_ends_trial = (typeof trial.response_ends_trial === 'undefined') ? true : trial.response_ends_trial; - trial.pre_target_duration = (typeof trial.pre_target_duration === 'undefined') ? 0 : trial.pre_target_duration; - trial.trial_duration = trial.trial_duration || -1; // if -1, then wait for response forever - trial.fade_duration = (typeof trial.fade_duration === 'undefined') ? -1 : trial.fade_duration; - trial.allow_nontarget_responses = (typeof trial.allow_nontarget_responses === 'undefined') ? false : trial.allow_nontarget_responses; - trial.prompt = (typeof trial.prompt === 'undefined') ? "" : trial.prompt; - var startTime = -1; var response = { rt: -1, diff --git a/plugins/jspsych-serial-reaction-time.js b/plugins/jspsych-serial-reaction-time.js index b0332967..b831076a 100644 --- a/plugins/jspsych-serial-reaction-time.js +++ b/plugins/jspsych-serial-reaction-time.js @@ -55,7 +55,7 @@ jsPsych.plugins["serial-reaction-time"] = (function() { no_function: false, description: '' }, - timing_pre_target: { + pre_target_duration: { type: jsPsych.plugins.parameterType.INT, default: 0, no_function: false, @@ -96,18 +96,6 @@ jsPsych.plugins["serial-reaction-time"] = (function() { plugin.trial = function(display_element, trial) { - trial.grid = trial.grid || [[1,1,1,1]]; - trial.choices = trial.choices || [['3','5','7','9']]; - trial.grid_square_size = trial.grid_square_size || 100; - trial.target_color = trial.target_color || "#999"; - trial.response_ends_trial = (typeof trial.response_ends_trial === 'undefined') ? true : trial.response_ends_trial; - trial.pre_target_duration = (typeof trial.pre_target_duration === 'undefined') ? 0 : trial.pre_target_duration; - trial.trial_duration = trial.trial_duration || -1; // if -1, then wait for response forever - trial.show_response_feedback = (typeof trial.show_response_feedback === 'undefined') ? false : trial.show_response_feedback; - trial.feedback_duration = (typeof trial.feedback_duration === 'undefined') ? 200 : trial.feedback_duration; - trial.fade_duration = (typeof trial.fade_duration === 'undefined') ? -1 : trial.fade_duration; - trial.prompt = (typeof trial.prompt === 'undefined') ? "" : trial.prompt; - // create a flattened version of the choices array var flat_choices = jsPsych.utils.flatten(trial.choices); while(flat_choices.indexOf('') > -1){ diff --git a/plugins/jspsych-survey-likert.js b/plugins/jspsych-survey-likert.js index 5daa5223..36e206a1 100644 --- a/plugins/jspsych-survey-likert.js +++ b/plugins/jspsych-survey-likert.js @@ -30,6 +30,12 @@ jsPsych.plugins['survey-likert'] = (function() { no_function: false, description: '' }, + preamble: { + type: jsPsych.plugins.parameterType.STRING, + default: '', + no_function: false, + description: '' + }, required: { type: jsPsych.plugins.parameterType.BOOL, array: true, @@ -48,11 +54,6 @@ jsPsych.plugins['survey-likert'] = (function() { plugin.trial = function(display_element, trial) { - // default parameters for the trial - trial.preamble = typeof trial.preamble === 'undefined' ? "" : trial.preamble; - trial.required = typeof trial.required === 'undefined' ? false : trial.required; - trial.button_label = typeof trial.button_label === 'undefined' ? 'Next' : trial.button_label; - var html = ""; // inject CSS for trial diff --git a/plugins/jspsych-survey-multi-choice.js b/plugins/jspsych-survey-multi-choice.js index 871b7565..5e0a3e83 100644 --- a/plugins/jspsych-survey-multi-choice.js +++ b/plugins/jspsych-survey-multi-choice.js @@ -65,13 +65,6 @@ jsPsych.plugins['survey-multi-choice'] = (function() { return arr.join(separator = '-'); } - // trial defaults - trial.preamble = typeof trial.preamble == 'undefined' ? "" : trial.preamble; - trial.required = typeof trial.required == 'undefined' ? null : trial.required; - trial.horizontal = typeof trial.required == 'undefined' ? false : trial.horizontal; - //If button_label is empty, the browser's language will be used to determine the button label. - trial.button_label = typeof trial.button_label === 'undefined' ? '' : trial.button_label; - // inject CSS for trial display_element.innerHTML = ''; var cssstr = ".jspsych-survey-multi-choice-question { margin-top: 2em; margin-bottom: 2em; text-align: left; }"+ diff --git a/plugins/jspsych-survey-multi-select.js b/plugins/jspsych-survey-multi-select.js index b4c78564..9dc591a8 100644 --- a/plugins/jspsych-survey-multi-select.js +++ b/plugins/jspsych-survey-multi-select.js @@ -63,14 +63,6 @@ jsPsych.plugins['survey-multi-select'] = (function() { return arr.join(separator = '-'); } - // trial defaults - trial.preamble = typeof trial.preamble == 'undefined' ? "" : trial.preamble; - trial.required = typeof trial.required == 'undefined' ? false : trial.required; - trial.required_msg = trial.required_msg || '*please select at least one option!'; - trial.horizontal = typeof trial.horizontal == 'undefined' ? false : trial.horizontal; - //If button_label is empty, the browser's language will be used to determine the button label. - trial.button_label = typeof trial.button_label === 'undefined' ? '' : trial.button_label; - // inject CSS for trial display_element.innerHTML = ''; diff --git a/plugins/jspsych-survey-text.js b/plugins/jspsych-survey-text.js index a1b3be7b..ed378f83 100644 --- a/plugins/jspsych-survey-text.js +++ b/plugins/jspsych-survey-text.js @@ -62,8 +62,6 @@ jsPsych.plugins['survey-text'] = (function() { plugin.trial = function(display_element, trial) { - trial.preamble = typeof trial.preamble == 'undefined' ? "" : trial.preamble; - trial.button_label = typeof trial.button_label === 'undefined' ? 'Next' : trial.button_label; if (typeof trial.rows == 'undefined') { trial.rows = []; diff --git a/plugins/jspsych-video.js b/plugins/jspsych-video.js index 9386224f..b2bac420 100644 --- a/plugins/jspsych-video.js +++ b/plugins/jspsych-video.js @@ -70,11 +70,6 @@ jsPsych.plugins.video = (function() { plugin.trial = function(display_element, trial) { - // set default values for the parameters - trial.prompt = trial.prompt || ""; - trial.autoplay = typeof trial.autoplay == 'undefined' ? true : trial.autoplay; - trial.controls = typeof trial.controls == 'undefined' ? false : trial.controls; - // display stimulus var video_html = '