/* 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
*
*
*/
(function($) {
jsPsych.instructions = (function() {
var plugin = {};
plugin.create = function(params) {
params = jsPsych.pluginAPI.enforceArray(params, ['pages']);
var trials = new Array(1);
trials[0] = {};
trials[0].pages = params.pages;
trials[0].key_forward = params.key_forward || 'rightarrow';
trials[0].key_backward = params.key_backward || 'leftarrow';
trials[0].allow_backward = (typeof params.allow_backward === 'undefined') ? true : params.allow_backward;
trials[0].allow_keys = (typeof params.allow_keys === 'undefined') ? true : params.allow_keys;
trials[0].show_clickable_nav = (typeof params.show_clickable_nav === 'undefined') ? false : params.show_clickable_nav;
return trials;
};
plugin.trial = function(display_element, trial) {
// if any trial variables are functions
// this evaluates the function and replaces
// it with the output of the function
trial = jsPsych.pluginAPI.normalizeTrialVariables(trial);
var current_page = 0;
var view_history = [];
var start_time = (new Date()).getTime();
var last_page_update_time = start_time;
function show_current_page(){
display_element.html(trial.pages[current_page]);
if(trial.show_clickable_nav){
var nav_html = "