jsPsych/examples/manual-preloading.html
2019-06-18 16:57:11 -04:00

47 lines
996 B
HTML

<!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 images_to_preload = [
'img/happy_face_1.jpg',
'img/happy_face_2.jpg',
'img/happy_face_3.jpg',
'img/happy_face_4.jpg',
'img/sad_face_1.jpg',
'img/sad_face_2.jpg',
'img/sad_face_3.jpg',
'img/sad_face_4.jpg'
]
var trial = {
type: 'image-keyboard-response',
stimulus: function(){
return jsPsych.randomization.sampleWithoutReplacement(images_to_preload, 1)[0];
},
choices: ['y','n'],
prompt: '<p>Have you seen this face before? Y or N.</p>'
}
jsPsych.init({
timeline: [trial],
on_finish: function() {
jsPsych.data.displayData();
},
preload_images: images_to_preload,
default_iti: 250
});
</script>
</html>