mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-12 08:38:11 +00:00
Merge pull request #441 from kristiyip/master
Updated README with demos and code
This commit is contained in:
commit
a0c8d0386e
169
README.md
169
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:
|
||||
<div display="flex">
|
||||
<img src="https://user-images.githubusercontent.com/14092539/28126774-801ea42e-66f8-11e7-9b6a-c8bad0026bec.gif" align="right" width=50% />
|
||||
|
||||
<div markdown="1" style="width: 50%;">
|
||||
<sub>
|
||||
|
||||
```javascript
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var trial = {
|
||||
type: 'instructions',
|
||||
pages: [
|
||||
'Welcome to the experiment. Click next to begin.',
|
||||
'<div>In this experiment, you will view a ' +
|
||||
'series of images and answer questions.<br>' +
|
||||
'Answer with the keys "y" or "n".',
|
||||
'Here is an example:<br><br> ' +
|
||||
'<img src="img/age/of2.jpg"></img><br><br>' +
|
||||
'Is this person OLD or YOUNG?'
|
||||
],
|
||||
show_clickable_nav: true
|
||||
}
|
||||
|
||||
jsPsych.init({
|
||||
timeline: [trial],
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
```
|
||||
|
||||
</sub>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Demo 2 with the image-keyboard-response plugin:
|
||||
<div display="flex">
|
||||
<img src="https://user-images.githubusercontent.com/14092539/28125911-0504cca2-66f6-11e7-8f5b-c9686f63aaa8.gif" align="right" width=50% />
|
||||
|
||||
<div markdown"2" style="width: 50%;">
|
||||
<sub>
|
||||
|
||||
```javascript
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var trial_1 = {
|
||||
type: "image-keyboard-response",
|
||||
stimulus: 'img/happy_face_1.jpg',
|
||||
choices: [89, 78],
|
||||
prompt: '<p>Is this face happy? Y or N.</p>'
|
||||
}
|
||||
|
||||
var trial_2 = {
|
||||
type: 'image-keyboard-response',
|
||||
stimulus: 'img/sad_face_2.jpg',
|
||||
choices: [89, 78], // Y or N
|
||||
prompt: '<p>Is this face happy? Y or N.</p>'
|
||||
}
|
||||
|
||||
var trial_3 = {
|
||||
type: 'image-keyboard-response',
|
||||
stimulus: 'img/happy_face_2.jpg',
|
||||
choices: [89, 78], // Y or N
|
||||
prompt: '<p>Is this face happy? Y or N.</p>',
|
||||
}
|
||||
|
||||
|
||||
jsPsych.init({
|
||||
timeline: [trial_1, trial_2, trial_3],
|
||||
default_iti: 250
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
```
|
||||
</sub>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
And for a slightly longer experiment example, demo 3 with the html-keyboard-response plugin. Also shows data after experiment ends:
|
||||
<div display="flex">
|
||||
<img src="https://user-images.githubusercontent.com/14092539/28126802-97b50d08-66f8-11e7-9a45-46561ab51a5f.gif" align="right" width=50% />
|
||||
|
||||
<div markdown="3" style="width: 50%;">
|
||||
<sub>
|
||||
|
||||
```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 "<p>Your average response time for congruent trials"+
|
||||
"was <strong>"+congruent_rt+"ms</strong>.</p>"+
|
||||
"<p>Your average response time for incongruent trials was"+
|
||||
"<strong>"incongruent_rt + "ms</strong>.</p>";
|
||||
}
|
||||
};
|
||||
|
||||
var timeline = [];
|
||||
timeline.push(test);
|
||||
timeline.push(debrief);
|
||||
jsPsych.init({
|
||||
timeline: timeline,
|
||||
on_finish: function() {
|
||||
jsPsych.data.displayData();
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
</sub>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
|
||||
|
29
examples/demos/demo_1.html
Normal file
29
examples/demos/demo_1.html
Normal file
@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="../jspsych.js"></script>
|
||||
<script src="../plugins/jspsych-instructions.js"></script>
|
||||
<link rel="stylesheet" href="../css/jspsych.css">
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
<script>
|
||||
var trial = {
|
||||
type: 'instructions',
|
||||
pages: [
|
||||
'Welcome to the experiment. Click next to begin.',
|
||||
'<div>In this experiment, you will view a ' +
|
||||
'series of images and answer questions.<br>' +
|
||||
'Answer with the keys "y" or "n".',
|
||||
'Here is an example:<br><br> ' +
|
||||
'<img src="img/age/of2.jpg"></img><br><br>' +
|
||||
'Is this person OLD or YOUNG?'
|
||||
],
|
||||
show_clickable_nav: true
|
||||
}
|
||||
|
||||
jsPsych.init({
|
||||
timeline: [trial],
|
||||
});
|
||||
</script>
|
||||
</html>
|
43
examples/demos/demo_2.html
Normal file
43
examples/demos/demo_2.html
Normal file
@ -0,0 +1,43 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="../jspsych.js"></script>
|
||||
<script src="../plugins/jspsych-image-keyboard-response.js"></script>
|
||||
<link rel="stylesheet" href="../css/jspsych.css"></link>
|
||||
<style>
|
||||
img {
|
||||
width: 300px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
<script>
|
||||
var trial_1 = {
|
||||
type: "image-keyboard-response",
|
||||
stimulus: 'img/happy_face_1.jpg',
|
||||
choices: [89, 78],
|
||||
prompt: '<p class="center-content">Is this face happy? Y or N.</p>'
|
||||
}
|
||||
|
||||
var trial_2 = {
|
||||
type: 'image-keyboard-response',
|
||||
stimulus: 'img/sad_face_2.jpg',
|
||||
choices: [89, 78], // Y or N
|
||||
prompt: '<p class="center-content">Is this face happy? Y or N.</p>'
|
||||
}
|
||||
|
||||
var trial_3 = {
|
||||
type: 'image-keyboard-response',
|
||||
stimulus: 'img/happy_face_2.jpg',
|
||||
choices: [89, 78], // Y or N
|
||||
prompt: '<p class="center-content">Is this face happy? Y or N.</p>',
|
||||
}
|
||||
|
||||
|
||||
jsPsych.init({
|
||||
timeline: [trial_1, trial_2, trial_3],
|
||||
default_iti: 250
|
||||
});
|
||||
</script>
|
||||
</html>
|
58
examples/demos/demo_3.html
Normal file
58
examples/demos/demo_3.html
Normal file
@ -0,0 +1,58 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="../jspsych.js"></script>
|
||||
<script src="../plugins/jspsych-html-keyboard-response.js"></script>
|
||||
<link rel="stylesheet" href="../css/jspsych.css">
|
||||
<style>
|
||||
#jspsych-html-keyboard-response-stimulus {
|
||||
font-size: 500%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
<script>
|
||||
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 "<p style='font-size:25px'>Your average response time for congruent trials was <strong>" + congruent_rt + "ms</strong>.</p>"+
|
||||
"<p style='font-size:25px'>Your average response time for incongruent trials was <strong>" + incongruent_rt + "ms</strong>.</p>";
|
||||
}
|
||||
};
|
||||
|
||||
var timeline = [];
|
||||
timeline.push(test);
|
||||
timeline.push(debrief);
|
||||
|
||||
jsPsych.init({
|
||||
timeline: timeline,
|
||||
on_finish: function() {
|
||||
jsPsych.data.displayData();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</html>
|
@ -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;
|
||||
|
@ -30,39 +30,51 @@ jsPsych.plugins["audio-button-response"] = (function() {
|
||||
no_function: false,
|
||||
description: ''
|
||||
},
|
||||
button_html: {
|
||||
type: jsPsych.plugins.parameterType.HTML_STRING,
|
||||
default: '<button class="jspsych-btn">%choice%</button>',
|
||||
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: '<button class="jspsych-btn">%choice%</button>',
|
||||
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) {
|
||||
|
||||
|
@ -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){
|
||||
|
@ -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){
|
||||
|
@ -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 = {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -41,13 +41,13 @@ jsPsych.plugins['categorize-html'] = (function() {
|
||||
},
|
||||
correct_text: {
|
||||
type: jsPsych.plugins.parameterType.STRING,
|
||||
default: 'Correct.',
|
||||
default: "<p class='feedback'>Correct</p>",
|
||||
no_function: false,
|
||||
description: ''
|
||||
},
|
||||
incorrect_text: {
|
||||
type: jsPsych.plugins.parameterType.STRING,
|
||||
default: 'Wrong.',
|
||||
default: "<p class='feedback'>Incorrect</p>",
|
||||
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: "<p>Please respond faster.</p>",
|
||||
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') ? "<p class='feedback'>Correct</p>" : trial.correct_text;
|
||||
trial.incorrect_text = (typeof trial.incorrect_text === 'undefined') ? "<p class='feedback'>Incorrect</p>" : 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 || "<p>Please respond faster.</p>";
|
||||
// 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 = '<div id="jspsych-categorize-html-stimulus" class="jspsych-categorize-html-stimulus">'+trial.stimulus+'</div>';
|
||||
|
||||
// hide image after time if the timing parameter is set
|
||||
|
@ -43,13 +43,13 @@ jsPsych.plugins['categorize-image'] = (function() {
|
||||
},
|
||||
correct_text: {
|
||||
type: jsPsych.plugins.parameterType.STRING,
|
||||
default: 'Correct.',
|
||||
default: "<p class='feedback'>Correct</p>",
|
||||
no_function: false,
|
||||
description: ''
|
||||
},
|
||||
incorrect_text: {
|
||||
type: jsPsych.plugins.parameterType.STRING,
|
||||
default: 'Wrong.',
|
||||
default: "<p class='feedback'>Incorrect</p>",
|
||||
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: "<p>Please respond faster.</p>",
|
||||
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') ? "<p class='feedback'>Correct</p>" : trial.correct_text;
|
||||
trial.incorrect_text = (typeof trial.incorrect_text === 'undefined') ? "<p class='feedback'>Incorrect</p>" : 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 || "<p>Please respond faster.</p>";
|
||||
// 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 = '<img id="jspsych-categorize-image-stimulus" class="jspsych-categorize-image-stimulus" src="'+trial.stimulus+'"></img>';
|
||||
|
||||
// hide image after time if the timing parameter is set
|
||||
|
@ -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());
|
||||
|
@ -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 = "";
|
||||
|
@ -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 || '<p>The experiment will switch to full screen mode when you press the button below</p>';
|
||||
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) {
|
||||
|
@ -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 || '<button class="jspsych-btn">%choice%</button>';
|
||||
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 = '<div id="jspsych-html-button-response-stimulus">'+trial.stimulus+'</div>';
|
||||
|
||||
|
@ -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 = '<div id="jspsych-html-keyboard-response-stimulus">'+trial.stimulus+'</div>';
|
||||
|
||||
// add prompt
|
||||
|
@ -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 = '<div id="jspsych-html-slider-response-wrapper" style="margin: 100px 0px;">';
|
||||
html += '<div id="jspsych-html-slider-response-stimulus">' + trial.stimulus + '</div>';
|
||||
html += '<div class="jspsych-html-slider-response-container" style="position:relative;">';
|
||||
|
@ -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 || '<span style="color: red; font-size: 80px">X</span>';
|
||||
trial.bottom_instructions = trial.bottom_instructions || "<p>If you press the wrong key, a red X will appear. Press any key to continue.</p>";
|
||||
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 += "<div style='position: absolute; height: 20%; width: 100%; margin-left: auto; margin-right: auto; top: 42%; left: 0; right: 0'><p id='jspsych-iat-stim'>" + trial.stimulus + "</p></div>";
|
||||
|
@ -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 || '<span style="color: red; font-size: 80px">X</span>';
|
||||
trial.bottom_instructions = trial.bottom_instructions || "<p>If you press the wrong key, a red X will appear. Press any key to continue.</p>";
|
||||
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 += "<div style='position: absolute; height: 20%; width: 100%; margin-left: auto; margin-right: auto; top: 42%; left: 0; right: 0'><img src='"+trial.stimulus+"' id='jspsych-iat-stim'></img></div>";
|
||||
|
@ -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 || '<button class="jspsych-btn">%choice%</button>';
|
||||
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 = '<img src="'+trial.stimulus+'" id="jspsych-image-button-response-stimulus"></img>';
|
||||
|
||||
|
@ -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 = '<div id="jspsych-image-slider-response-wrapper" style="margin: 100px 0px;">';
|
||||
html += '<div id="jspsych-image-slider-response-stimulus"><img src="' + trial.stimulus + '"></div>';
|
||||
html += '<div class="jspsych-image-slider-response-container" style="position:relative;">';
|
||||
|
@ -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 = [];
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 = '<div class="jspsych-same-different-stimulus">'+trial.stimuli[0]+'</div>';
|
||||
|
||||
var first_stim_info;
|
||||
|
@ -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 = '<img class="jspsych-same-different-stimulus" src="'+trial.stimuli[0]+'"></img>';
|
||||
|
||||
var first_stim_info;
|
||||
|
@ -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,
|
||||
|
@ -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){
|
||||
|
@ -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
|
||||
|
@ -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 = '<style id="jspsych-survey-multi-choice-css"></style>';
|
||||
var cssstr = ".jspsych-survey-multi-choice-question { margin-top: 2em; margin-bottom: 2em; text-align: left; }"+
|
||||
|
@ -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 = '<style id="jspsych-survey-multi-select-css"></style>';
|
||||
|
@ -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 = [];
|
||||
|
@ -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 = '<video id="jspsych-video-player" width="'+trial.width+'" height="'+trial.height+'" '
|
||||
if(trial.autoplay){
|
||||
|
@ -57,14 +57,14 @@ jsPsych.plugins["visual-search-circle"] = (function() {
|
||||
target_size: {
|
||||
type: jsPsych.plugins.parameterType.INT,
|
||||
array: true,
|
||||
default: 50,
|
||||
default: [50, 50],
|
||||
no_function: false,
|
||||
description: ''
|
||||
},
|
||||
fixation_size: {
|
||||
type: jsPsych.plugins.parameterType.INT,
|
||||
array: true,
|
||||
default: 16,
|
||||
default: [16, 16],
|
||||
no_function: false,
|
||||
description: ''
|
||||
},
|
||||
@ -103,15 +103,6 @@ jsPsych.plugins["visual-search-circle"] = (function() {
|
||||
|
||||
plugin.trial = function(display_element, trial) {
|
||||
|
||||
// default values
|
||||
trial.target_size = trial.target_size || [50, 50];
|
||||
trial.fixation_size = trial.fixation_size || [16, 16];
|
||||
trial.circle_diameter = trial.circle_diameter || 250;
|
||||
trial.target_present_key = trial.target_present_key || 74;
|
||||
trial.target_absent_key = trial.target_absent_key || 70;
|
||||
trial.trial_duration = (typeof trial.trial_duration === 'undefined') ? -1 : trial.trial_duration;
|
||||
trial.fixation_duration = (typeof trial.fixation_duration === 'undefined') ? 1000 : trial.fixation_duration;
|
||||
|
||||
// circle params
|
||||
var diam = trial.circle_diameter; // pixels
|
||||
var radi = diam / 2;
|
||||
|
@ -78,16 +78,7 @@ jsPsych.plugins['vsl-animate-occlusion'] = (function() {
|
||||
}
|
||||
|
||||
plugin.trial = function(display_element, trial) {
|
||||
|
||||
// default trial parameters
|
||||
trial.cycle_duration = trial.cycle_duration || 1000;
|
||||
trial.canvas_size = trial.canvas_size || [400, 400];
|
||||
trial.image_size = trial.image_size || [100, 100];
|
||||
trial.initial_direction = trial.initial_direction || "left";
|
||||
trial.occlude_center = (typeof trial.occlude_center === 'undefined') ? true : trial.occlude_center;
|
||||
trial.choices = trial.choices || jsPsych.ALL_KEYS;
|
||||
trial.pre_movement_duration = (typeof trial.pre_movement_duration === 'undefined') ? 500 : trial.pre_movement_duration;
|
||||
|
||||
|
||||
// variable to keep track of timing info and responses
|
||||
var start_time = 0;
|
||||
var responses = [];
|
||||
|
@ -46,11 +46,6 @@ jsPsych.plugins['vsl-grid-scene'] = (function() {
|
||||
|
||||
plugin.trial = function(display_element, trial) {
|
||||
|
||||
// default parameter values
|
||||
trial.image_size = trial.image_size || [100, 100];
|
||||
trial.trial_duration = typeof trial.trial_duration === 'undefined' ? 2000 : trial.trial_duration;
|
||||
|
||||
|
||||
display_element.innerHTML = plugin.generate_stimulus(trial.stimuli, trial.image_size);
|
||||
|
||||
jsPsych.pluginAPI.setTimeout(function() {
|
||||
|
@ -69,16 +69,7 @@ jsPsych.plugins['xab-html'] = (function() {
|
||||
}
|
||||
|
||||
plugin.trial = function(display_element, trial) {
|
||||
|
||||
// default trial values
|
||||
trial.left_key = trial.left_key || 81; // defaults to 'q'
|
||||
trial.right_key = trial.right_key || 80; // defaults to 'p'
|
||||
trial.x_duration = trial.x_duration || 1000; // defaults to 1000msec.
|
||||
trial.x_durationab_gap = trial.x_durationab_gap || 1000; // defaults to 1000msec.
|
||||
trial.ab_duration = trial.ab_duration || -1; // defaults to -1, meaning infinite time on AB. If a positive number is used, then AB will only be displayed for that length.
|
||||
trial.trial_duration = trial.trial_duration || -1; //
|
||||
trial.prompt = (typeof trial.prompt === 'undefined') ? "" : trial.prompt;
|
||||
|
||||
|
||||
// unpack the stimuli array
|
||||
trial.x_path = trial.stimuli[0];
|
||||
|
||||
|
@ -72,15 +72,6 @@ jsPsych.plugins['xab-image'] = (function() {
|
||||
|
||||
plugin.trial = function(display_element, trial) {
|
||||
|
||||
// default trial values
|
||||
trial.left_key = trial.left_key || 81; // defaults to 'q'
|
||||
trial.right_key = trial.right_key || 80; // defaults to 'p'
|
||||
trial.x_duration = trial.x_duration || 1000; // defaults to 1000msec.
|
||||
trial.x_durationab_gap = trial.x_durationab_gap || 1000; // defaults to 1000msec.
|
||||
trial.ab_duration = trial.ab_duration || -1; // defaults to -1, meaning infinite time on AB. If a positive number is used, then AB will only be displayed for that length.
|
||||
trial.trial_duration = trial.trial_duration || -1; //
|
||||
trial.prompt = (typeof trial.prompt === 'undefined') ? "" : trial.prompt;
|
||||
|
||||
// unpack the stimuli array
|
||||
trial.x_path = trial.stimuli[0];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user