jsPsych/examples/jspsych-image-slider-response.html

77 lines
2.4 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<script src="../jspsych.js"></script>
<script src="../plugins/jspsych-image-slider-response.js"></script>
<link rel="stylesheet" href="../css/jspsych.css">
</head>
<body></body>
<script>
// 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: [trial_proc, trial_1, trial_2, trial_3],
preload_images: ['img/happy_face_1.jpg','img/happy_face_2.jpg','img/happy_face_3.jpg','img/happy_face_4.jpg'],
on_finish: function() {
jsPsych.data.displayData();
},
default_iti: 250
});
</script>
</html>