/* 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.STRING], default: undefined, array: true, no_function: false, description: '' }, key_forward: { type: [jsPsych.plugins.parameterType.KEYCODE], default: 'rightarrow', no_function: false, description: '' }, key_backward: { type: [jsPsych.plugins.parameterType.KEYCODE], default: 'leftarrow', no_function: false, description: '' }, allow_backward: { type: [jsPsych.plugins.parameterType.BOOL], default: true, no_function: false, description: '' }, allow_keys: { type: [jsPsych.plugins.parameterType.BOOL], default: true, no_function: false, description: '' }, show_clickable_nav: { type: [jsPsych.plugins.parameterType.BOOL], default: false, no_function: false, description: '' }, button_label_previous: { type: [jsPsych.plugins.parameterType.STRING], default: 'Previous', no_function: false, description: '' }, button_label_next: { type: [jsPsych.plugins.parameterType.STRING], default: 'Next', no_function: false, description: '' } } } 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; // if any trial variables are functions // this evaluates the function and replaces // it with the output of the function trial = jsPsych.pluginAPI.evaluateFunctionParameters(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 = "