mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
47 lines
989 B
HTML
47 lines
989 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">
|
|
<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>
|