/* jspsych-text.js * Josh de Leeuw * * This plugin displays text (including HTML formatted strings) during the experiment. * Use it to show instructions, provide performance feedback, etc... * * documentation: docs.jspsych.org * * */ jsPsych.plugins.instructions = (function() { var plugin = {}; plugin.info = { name: 'instructions', description: '', parameters: { pages: { type: jsPsych.plugins.parameterType.HTML_STRING, pretty_name: 'Pages', default: undefined, array: true, description: 'Each element of the array is the content for a single page.' }, key_forward: { type: jsPsych.plugins.parameterType.KEYCODE, pretty_name: 'Key forward', default: 'rightarrow', description: 'The key the subject can press in order to advance to the next page.' }, key_backward: { type: jsPsych.plugins.parameterType.KEYCODE, pretty_name: 'Key backward', default: 'leftarrow', description: 'The key that the subject can press to return to the previous page.' }, allow_backward: { type: jsPsych.plugins.parameterType.BOOL, pretty_name: 'Allow backward', default: true, description: 'If true, the subject can return to the previous page of the instructions.' }, allow_keys: { type: jsPsych.plugins.parameterType.BOOL, pretty_name: 'Allow keys', default: true, description: 'If true, the subject can use keyboard keys to navigate the pages.' }, show_clickable_nav: { type: jsPsych.plugins.parameterType.BOOL, pretty_name: 'Show clickable nav', default: false, description: 'If true, then a "Previous" and "Next" button will be displayed beneath the instructions.' }, button_label_previous: { type: jsPsych.plugins.parameterType.STRING, pretty_name: 'Button label previous', default: 'Previous', description: 'The text that appears on the button to go backwards.' }, button_label_next: { type: jsPsych.plugins.parameterType.STRING, pretty_name: 'Button label next', default: 'Next', description: 'The text that appears on the button to go forwards.' } } } plugin.trial = function(display_element, trial) { var current_page = 0; var view_history = []; var start_time = (new Date()).getTime(); var last_page_update_time = start_time; function btnListener(evt){ evt.target.removeEventListener('click', btnListener); if(this.id === "jspsych-instructions-back"){ back(); } else if(this.id === 'jspsych-instructions-next'){ next(); } } function show_current_page() { display_element.innerHTML = trial.pages[current_page]; if (trial.show_clickable_nav) { var nav_html = "