-
Notifications
You must be signed in to change notification settings - Fork 67
/
index.html
79 lines (65 loc) · 2.85 KB
/
index.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!doctype html>
<html>
<head>
<title>My experiment</title>
<!-- Load jQuery -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<!-- Load the jspsych library and plugins -->
<script src="scripts/jspsych.js"></script>
<script src="scripts/plugins/jspsych-text.js"></script>
<script src="scripts/plugins/jspsych-single-stim.js"></script>
<!-- Load the stylesheet -->
<link href="css/jspsych.css" type="text/css" rel="stylesheet"></link>
</head>
<body>
<div id="jspsych_target"></div>
</body>
<script type="text/javascript">
// Experiment parameters
var n_trials_per_stimulus = 5;
// Experiment Instructions
var welcome_message = '<div id="instructions"><p>Welcome to the experiment. Press enter to begin.</p></div>';
var instructions = '<div id="instructions"><p>You will see a series of images that look similar to this:</p>\
<p><img src="img/incongruent_right.gif"></p><p>Press the arrow key that corresponds to the direction that\
the middle arrow is pointing. For example, in this case you would press the right arrow key.</p>\
<p>Press enter to start.</p>';
var debrief = '<div id="instructions"><p>Thank you for participating! Press enter to see the data.</p></div>';
// Generating Random Order for Stimuli
var stimuli = [
{image: "img/congruent_left.gif", data: { stimulus_type: "congruent" }},
{image: "img/congruent_right.gif", data: { stimulus_type: "congruent" }},
{image: "img/incongruent_left.gif", data: { stimulus_type: "incongruent" }},
{image: "img/incongruent_right.gif", data: { stimulus_type: "incongruent" }},
];
var trial_info = jsPsych.randomization.repeat(stimuli, n_trials_per_stimulus, true);
// Define experiment blocks
var instruction_block = {
type: "text",
text: [welcome_message, instructions],
timing_post_trial: 1500
};
var test_block = {
type: "single-stim",
stimuli: trial_info.image,
choices: [37, 39],
data: trial_info.data,
timing_post_trial: function() {
return Math.floor(Math.random()*1000)+1000;
}
};
var debrief_block = {
type: "text",
text: [debrief]
};
jsPsych.preloadImages(trial_info.image, function() { start_experiment(); });
function start_experiment() {
jsPsych.init({
display_element: $('#jspsych_target'),
experiment_structure: [instruction_block, test_block, debrief_block],
on_finish: function(data) {
jsPsych.dataAPI.displayData();
}
});
}
</script>
</html>