mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 11:10:54 +00:00
example of manual preloading
This commit is contained in:
parent
a056d40b2f
commit
7e73a2fcbd
46
examples/manual-preloading.html
Normal file
46
examples/manual-preloading.html
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<!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>
|
Loading…
Reference in New Issue
Block a user