Merge pull request #1073 from chrisbrickhouse/Iss-1064

survey-*: default to autocomplete=off and add param to enable
This commit is contained in:
Becky Gilbert 2020-10-02 11:00:23 -07:00 committed by GitHub
commit b96a875d30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 6 deletions

View File

@ -39,6 +39,12 @@ jsPsych.plugins['survey-html-form'] = (function() {
pretty_name: 'Data As Array',
default: false,
description: 'Retrieve the data as an array e.g. [{name: "INPUT_NAME", value: "INPUT_VALUE"}, ...] instead of an object e.g. {INPUT_NAME: INPUT_VALUE, ...}.'
},
autocomplete: {
type: jsPsych.plugins.parameterType.BOOL,
pretty_name: 'Allow autocomplete',
default: false,
description: "Setting this to true will enable browser auto-complete or auto-fill for the form."
}
}
}
@ -51,7 +57,11 @@ jsPsych.plugins['survey-html-form'] = (function() {
html += '<div id="jspsych-survey-html-form-preamble" class="jspsych-survey-html-form-preamble">'+trial.preamble+'</div>';
}
// start form
html += '<form id="jspsych-survey-html-form">'
if ( trial.autocomplete ) {
html += '<form id="jspsych-survey-html-form">'
} else {
html += '<form id="jspsych-survey-html-form" autocomplete="off">'
}
// add form HTML / input elements
html += trial.html;

View File

@ -71,6 +71,12 @@ jsPsych.plugins['survey-likert'] = (function() {
pretty_name: 'Button label',
default: 'Continue',
description: 'Label of the button.'
},
autocomplete: {
type: jsPsych.plugins.parameterType.BOOL,
pretty_name: 'Allow autocomplete',
default: false,
description: "Setting this to true will enable browser auto-complete or auto-fill for the form."
}
}
}
@ -99,7 +105,12 @@ jsPsych.plugins['survey-likert'] = (function() {
if(trial.preamble !== null){
html += '<div id="jspsych-survey-likert-preamble" class="jspsych-survey-likert-preamble">'+trial.preamble+'</div>';
}
html += '<form id="jspsych-survey-likert-form">';
if ( trial.autocomplete ) {
html += '<form id="jspsych-survey-likert-form">';
} else {
html += '<form id="jspsych-survey-likert-form" autocomplete="off">';
}
// add likert scale questions ///
// generate question order. this is randomized here as opposed to randomizing the order of trial.questions

View File

@ -71,6 +71,12 @@ jsPsych.plugins['survey-multi-choice'] = (function() {
pretty_name: 'Button label',
default: 'Continue',
description: 'Label of the button.'
},
autocomplete: {
type: jsPsych.plugins.parameterType.BOOL,
pretty_name: 'Allow autocomplete',
default: false,
description: "Setting this to true will enable browser auto-complete or auto-fill for the form."
}
}
}
@ -95,8 +101,11 @@ jsPsych.plugins['survey-multi-choice'] = (function() {
}
// form element
html += '<form id="jspsych-survey-multi-choice-form">';
if ( trial.autocomplete ) {
html += '<form id="jspsych-survey-multi-choice-form">';
} else {
html += '<form id="jspsych-survey-multi-choice-form" autofocus="off">';
}
// generate question order. this is randomized here as opposed to randomizing the order of trial.questions
// so that the data are always associated with the same question regardless of order
var question_order = [];

View File

@ -75,6 +75,12 @@ jsPsych.plugins['survey-multi-select'] = (function() {
pretty_name: 'Required message',
default: 'You must choose at least one response for this question',
description: 'Message that will be displayed if required question is not answered.'
},
autocomplete: {
type: jsPsych.plugins.parameterType.BOOL,
pretty_name: 'Allow autocomplete',
default: false,
description: "Setting this to true will enable browser auto-complete or auto-fill for the form."
}
}
}
@ -99,6 +105,9 @@ jsPsych.plugins['survey-multi-select'] = (function() {
var trial_form_id = _join(plugin_id_name, "form");
display_element.innerHTML += '<form id="'+trial_form_id+'"></form>';
var trial_form = display_element.querySelector("#" + trial_form_id);
if ( !trial.autocomplete ) {
trial_form.setAttribute('autocomplete',"off");
}
// show preamble text
var preamble_id_name = _join(plugin_id_name, 'preamble');
if(trial.preamble !== null){

View File

@ -72,6 +72,12 @@ jsPsych.plugins['survey-text'] = (function() {
pretty_name: 'Button label',
default: 'Continue',
description: 'The text that appears on the button to finish the trial.'
},
autocomplete: {
type: jsPsych.plugins.parameterType.BOOL,
pretty_name: 'Allow autocomplete',
default: false,
description: "Setting this to true will enable browser auto-complete or auto-fill for the form."
}
}
}
@ -100,8 +106,11 @@ jsPsych.plugins['survey-text'] = (function() {
html += '<div id="jspsych-survey-text-preamble" class="jspsych-survey-text-preamble">'+trial.preamble+'</div>';
}
// start form
html += '<form id="jspsych-survey-text-form">'
if (trial.autocomplete) {
html += '<form id="jspsych-survey-text-form">';
} else {
html += '<form id="jspsych-survey-text-form" autocomplete="off">';
}
// generate question order
var question_order = [];
for(var i=0; i<trial.questions.length; i++){