forked from jspsych/jsPsych
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathend-active-node.html
52 lines (45 loc) · 1.17 KB
/
end-active-node.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html>
<html>
<head>
<script src="../jspsych.js"></script>
<script src="../plugins/jspsych-html-keyboard-response.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 = ["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: [89, 78], // Y or N
prompt: '<p>Press Y to Continue. Press N to end this node of the experiment.</p>',
on_finish: function(data) {
if (data.key_press == 78) {
jsPsych.endCurrentTimeline();
}
},
timeline: trials
}
var after_block = {
type: 'html-keyboard-response',
stimulus: '<p>The next node</p>',
}
jsPsych.init({
timeline: [block, after_block],
on_finish: function() {
jsPsych.data.displayData();
}
});
</script>
</html>