-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
144 lines (124 loc) · 4.47 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<!DOCTYPE html>
<html>
<head>
<script src="js/jspsych/jspsych.js"></script>
<script src="js/jspsych-psychophysics-3.6.0/jspsych-psychophysics.js"></script>
<script src="js/jspsych/plugin-preload.js"></script>
<script src="js/jspsych/plugin-html-button-response.js"></script>
<script src="js/jspsych/plugin-instructions.js"></script>
<script src="js/jspsych/plugin-call-function.js"></script>
<script src="js/jspsych/plugin-survey-text.js"></script>
<script src="js/jspsych/plugin-survey.js"></script>
<script type="text/javascript" src="lib/jspsych-7-pavlovia-2022.1.1.js"></script>
<script src="js/functions/shared_func.js"></script>
<script src="js/functions/image_func.js"></script>
<script src="js/functions/position_func.js"></script>
<script src="config/prolific_config.js"></script>
<script src="config/survey_config.js"></script>
<script src="config/expt1_config.js"></script>
<script src="config/expt2_config.js"></script>
<script src="config/expt3_config.js"></script>
<script src="config/expt4_config.js"></script>
<script src="config/instructions.js"></script>
<link href="js/jspsych/jspsych.css" rel="stylesheet" type="text/css" />
<link href="css/custom-style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<canvas id="canvas" width="800" height="600"></canvas>
<script>
const jsPsych = initJsPsych({
on_finish: function(){
let completeCode = prolific_config["completeCode"]
if (completeCode !== undefined | completeCode !== "") {
window.location = `https://app.prolific.co/submissions/complete?cc=${completeCode}`
}
}
});
var jspRand = jsPsych.randomization
var pavloviaInfo;
const canvas = document.getElementById("canvas");
const imgSize = [96, 96];
const mainTimeline = [];
// capture info from Prolific
var prolific_id = jsPsych.data.getURLVariable('PROLIFIC_PID');
var study_id = jsPsych.data.getURLVariable('STUDY_ID');
var session_id = jsPsych.data.getURLVariable('SESSION_ID');
jsPsych.data.addProperties({
prolific_id: prolific_id,
study_id: study_id,
session_id: session_id
});
var pavlovia_init = {
type: jsPsychPavlovia,
command: "init",
// Store info received by Pavlovia init into the global variable `pavloviaInfo`
setPavloviaInfo: function(info) {
console.log(info);
pavloviaInfo = info;
}
};
const enter_ID = {
type: jsPsychSurveyText,
questions: [
{
prompt: "Please enter the participant ID",
required: true,
name: "ID"
}
],
}
const enter_ID_node = {
timeline: [enter_ID],
conditional_function: function() {
return prolific_id === undefined
}
}
mainTimeline.push(pavlovia_init)
mainTimeline.push(enter_ID_node)
</script>
<script src="js/preloadImgs.js"></script>
<script src="js/survey.js"></script>
<script src="js/Experiment1.js"></script>
<script src="js/Experiment2.js"></script>
<script src="js/Experiment3.js"></script>
<script src="js/Experiment4.js"></script>
<script>
var pavlovia_finish = {
type: jsPsychPavlovia,
command: "finish",
participantId: function() {
if (prolific_id !== undefined) {
return prolific_id
} else {
return jsPsych.data.get().
filter({trial_type: 'survey-text'}).
select("response").
values[0].ID;
}
},
};
mainTimeline.push(pavlovia_finish);
var expt_complete = {
type: jsPsychHtmlButtonResponse,
stimulus: '<p>All Done</p>',
choices: "",
trial_duration: 1500,
}
mainTimeline.push(expt_complete);
var redirect_prolific = {
type: jsPsychHtmlButtonResponse,
stimulus: prolific_config["redirectMessage"],
choices: ["Continue"],
trial_duration: 5000,
}
const redirect_prolific_node = {
timeline: [redirect_prolific],
conditional_function: function() {
return (completeCode !== undefined | completeCode !== "") & prolific_config["redirectScreen"]
}
}
mainTimeline.push(redirect_prolific_node);
jsPsych.run(mainTimeline)
</script>
</body>
</html>