mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
86 lines
2.8 KiB
HTML
86 lines
2.8 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<script src="../jspsych.js"></script>
|
|
<script src="../plugins/jspsych-image-slider-response.js"></script>
|
|
<script src="../plugins/jspsych-preload.js"></script>
|
|
<link rel="stylesheet" href="../css/jspsych.css">
|
|
</head>
|
|
<body></body>
|
|
<script>
|
|
|
|
// three images are used in a standard way in image-* plugins and can therefore be automatically preloaded.
|
|
// there's one additional image ('img/happy_face_4.jpg') that is only used in timeline variables
|
|
// and will not be automatically preloaded, so this file must be preloaded manually.
|
|
var preload = {
|
|
type: 'preload',
|
|
auto_preload: true,
|
|
images: ['img/happy_face_4.jpg']
|
|
}
|
|
|
|
// If render_on_canvas is false, the images will be shown via an <img> rather than <canvas> element.
|
|
// In some browsers, the first time the images are shown, the <img> method (render_on_canvas: false) will produce a brief
|
|
// blank screen (white flash) between images that are presented consecutively with no post_trial_gap between them.
|
|
var trial = {
|
|
type: 'image-slider-response',
|
|
stimulus: jsPsych.timelineVariable('stim'),
|
|
trial_duration: 1000,
|
|
labels: ['1 (least happy)', '100 (most happy)'],
|
|
prompt: '<p>How happy is this person on a scale of 1-100?</p><p>(Consecutive images with no post_trial_gap)</p>',
|
|
response_ends_trial: false,
|
|
slider_width: 500,
|
|
stimulus_width: 400,
|
|
maintain_aspect_ratio: true,
|
|
post_trial_gap: 0,
|
|
//render_on_canvas: false
|
|
}
|
|
|
|
var trial_proc = {
|
|
timeline: [trial],
|
|
timeline_variables: [
|
|
{stim: 'img/happy_face_1.jpg'},
|
|
{stim: 'img/happy_face_2.jpg'},
|
|
{stim: 'img/happy_face_3.jpg'},
|
|
{stim: 'img/happy_face_4.jpg'}
|
|
]
|
|
}
|
|
|
|
var trial_1 = {
|
|
type: 'image-slider-response',
|
|
stimulus: 'img/happy_face_1.jpg',
|
|
labels: ['1 (least happy)', '100 (most happy)'],
|
|
slider_width: 500,
|
|
require_movement: true,
|
|
prompt: '<p>How happy is this person on a scale of 1-100? (Interaction with slider is required)</p>'
|
|
}
|
|
|
|
var trial_2 = {
|
|
type: 'image-slider-response',
|
|
stimulus: 'img/happy_face_2.jpg',
|
|
labels: ['1 (least happy)', '100 (most happy)'],
|
|
slider_start: 80,
|
|
slider_width: 500,
|
|
prompt: '<p>How happy is this person on a scale of 1-100? (5s time limit; set start value)</p>',
|
|
trial_duration: 5000
|
|
}
|
|
|
|
var trial_3 = {
|
|
type: 'image-slider-response',
|
|
stimulus: 'img/happy_face_3.jpg',
|
|
labels: ['1 (least happy)', '100 (most happy)'],
|
|
slider_width: 500,
|
|
prompt: '<p>How happy is this person on a scale of 1-100? (1s stimulus duration)</p>',
|
|
stimulus_duration: 1000
|
|
}
|
|
|
|
jsPsych.init({
|
|
timeline: [preload, trial_proc, trial_1, trial_2, trial_3],
|
|
on_finish: function() {
|
|
jsPsych.data.displayData();
|
|
},
|
|
default_iti: 250
|
|
});
|
|
</script>
|
|
|
|
</html>
|