jsPsych/examples/end-experiment.html
2021-02-17 16:24:27 -08:00

45 lines
994 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 = ["img/1.gif", "img/2.gif", "img/3.gif", "img/4.gif", "img/5.gif", "img/6.gif", "img/7.gif", "img/8.gif", "img/9.gif", "img/10.gif"];
var trials = [];
for (var i = 0; i < images.length; i++) {
trials.push({
stimulus: images[i]
});
}
var block = {
type: 'image-keyboard-response',
choices: ['y','n'],
prompt: '<p>Press "y" to continue. Press "n" to end the experiment.</p>',
render_on_canvas: false,
on_finish: function(data) {
if (data.response == 'n') {
jsPsych.endExperiment('The experiment was ended. This is the end message.');
}
},
timeline: trials
}
jsPsych.init({
timeline: [block]
});
</script>
</html>