-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstruct.html
More file actions
executable file
·166 lines (147 loc) · 5.25 KB
/
Instruct.html
File metadata and controls
executable file
·166 lines (147 loc) · 5.25 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<!DOCTYPE html>
<html>
<head>
<title>Task instructions</title>
<meta charset="UTF-8">
<!-- Set the favicon logo -->
<link rel="icon" href="./Assets/Logo.png" type="image/x-icon" />
<!-- Import the stylesheet -->
<link rel="stylesheet" href="./Assets/w3.css">
<!-- Some more styling -->
<style>
body {
padding: 30px 0;
}
.alert {
padding: 20px;
background-color: #f44336;
color: white;
}
.closebtn {
margin-left: 15px;
color: white;
font-weight: bold;
float: right;
font-size: 22px;
line-height: 20px;
cursor: pointer;
transition: 0.3s;
}
.closebtn:hover {
color: black;
}
</style>
<!-- Get participant IDs passed in from URL -->
<script src="./Assets/GetPpantIds.js"></script>
<!-- Get task IDs passed in from URL -->
<script src="./Assets/GetTaskId.js"></script>
<!-- Get DateTime_Start and ClientTimeZone (and add to TaskIO) -->
<script src="./Assets/SetDateTime.js"></script>
<!-- Exclusion check -->
<script src="./Assets/ExclusionCheck.js"></script>
<!-- Import the instruction text -->
<script src="./Instructions/Text.js"></script>
<!-- Show the warning if needed -->
<script src="./ShowWarning.js"></script>
<script>
async function OnBodyLoad() {
ShowWarningIfNeeded();
if (!TaskId) {
document.getElementById('TextArea').innerHTML =
'<p>This page is for testing purposes only.</p>' +
'<p>If you are reading this and you are not Sophie or Sam, ' +
'something is horribly wrong. 😄</p>';
} else if (TaskId === 'TItrain') {
document.getElementById('TextArea').innerHTML = TItrain;
document.getElementById('Audio').src =
'./Instructions/TItrain.mp3';
} else if (TaskId === 'TIprobe') {
document.getElementById('TextArea').innerHTML = TIprobe;
document.getElementById('Audio').src =
'./Instructions/TIprobe.mp3';
} else {
var ErrorCode = 'XXX';
var URL = "./Error.html?SubjectId=" +
encodeURIComponent(String(SubjectId)) +
'&ErrorCode=' +
encodeURIComponent(String(ErrorCode)) +
"#";
window.location.replace(URL);
}
document.getElementById('Canvas').style.visibility = 'visible';
}
async function LogInstruct() {
var Data2Send = {
SubjectId: SubjectId,
DateTime_Start: DateTime_Start,
ClientTimeZone: ClientTimeZone,
TaskId: TaskId
};
var P1 = await fetch('./InstructActions.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(Data2Send)
});
var Result = await P1.json();
if (Result.Error) {
var ErrorCode = 'XXX';
var URL = "./Error.html?SubjectId=" +
encodeURIComponent(String(SubjectId)) +
'&ErrorCode=' +
encodeURIComponent(String(ErrorCode)) +
"#";
window.location.replace(URL);
}
return Result;
}
function OnStartAudio() {
SetDateTime();
}
function OnFinishAudio() {
document.getElementById('ButtonArea').innerHTML =
'<button onclick="Continue()">Continue</button>';
}
function Continue() {
LogInstruct().then(function (P1) {
TargetUrl = P1.TargetUrl;
if (window.location.href != TargetUrl) {
window.location.replace(TargetUrl);
} else {
location.reload();
}
}).catch(function (Err) {
var ErrorCode = 'XXX';
var URL = "./Error.html?SubjectId=" +
encodeURIComponent(String(SubjectId)) +
'&ErrorCode=' +
encodeURIComponent(String(ErrorCode)) +
"#";
window.location.replace(URL);
});
}
</script>
</head>
<body onload="OnBodyLoad()">
<div id='Canvas' style='visibility:hidden;'>
<center>
<div id='AudioDiv'>
<p><i>Please press play to hear the instructions read out through your speakers...</i></p>
<audio
controls
onplay="OnStartAudio()"
onended="OnFinishAudio()"
id="Audio"
src="./Instructions/Test.mp3"
type="audio/wav">
</audio>
</div>
</center>
<div id="TextArea" style="max-width:800px; margin:0 auto"></div>
<center>
<div id="ButtonArea"></div>
</center>
</div>
</body>
</html>