-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
373 lines (349 loc) · 13 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
<html lang="en_US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=5, width=device-width, height=device-height">
<title>RR User Input</title>
<style>
div#content2, div#content1 {
display: flex;
flex-wrap: wrap;
}
div.module {
margin: 5px;
border: 1px solid #a0a0a0;
border-radius: 5px;
padding: 5px;
}
div.module button {
display: block;
margin: 10px 0;
width: 100%;
}
h3 {
margin-top: 0;
margin-bottom: 0;
}
div#banner {
position: fixed;
top: 0;
left: 0;
width: 100%;
background-color: #aaeeaa;
padding: 5px;
padding-left: 15px;
}
body:not([running]) div#banner {
visibility: hidden;
}
body:not([running]) div#content2 {
display: none;
}
body:not([running]) div#bar-wrapper {
display: none;
}
body[running] div#content1 {
display: none;
}
div#form {
background-color: orange;
}
input, select {
width: 100%;
}
div#bar-wrapper {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
z-index: 100;
background-color: #eeeeee;
padding-top: 10px;
padding-bottom: 10px;
}
div#bar-wrapper[ready] {
background-color: #aaeeaa;
}
div#bar {
padding-left: 5px;
padding-right: 5px;
max-width: 400px;
display: flex;
justify-content: space-between;
align-items: center;
}
button#send {
margin-left: auto;
margin-right: 0;
display: inline-block;
}
</style>
</head>
<body>
<div id="banner">
<span id="experimenter"></span>
is running
<span id="participant"></span>
in session
<span id="session"></span>
</div>
<br>
<div id="content1">
<div id="form" class="module">
<table>
<tr>
<td>Experimenter</td>
<td>
<select id="experimenter_in">
<option value="jackie">jackie</option>
<option value="alicia">alicia</option>
<option value="olga">olga</option>
<option value="jete">jete</option>
</select>
</td>
</tr>
<tr>
<td>Participant</td>
<td>
<select id="participant_in">
<option value="p001">p001</option>
<option value="p002">p002</option>
<option value="p003">p003</option>
<option value="p004">p004</option>
<option value="p005">p005</option>
<option value="p006">p006</option>
<option value="p007">p007</option>
<option value="p008">p008</option>
<option value="p009">p009</option>
<option value="p010">p010</option>
<option value="p011">p011</option>
<option value="p012">p012</option>
<option value="p013">p013</option>
<option value="p014">p014</option>
<option value="p015">p015</option>
<option value="p016">p016</option>
<option value="p017">p017</option>
<option value="p018">p018</option>
<option value="p019">p019</option>
<option value="p020">p020</option>
<option value="p021">p021</option>
<option value="p022">p022</option>
<option value="p023">p023</option>
<option value="p024">p024</option>
<option value="p025">p025</option>
<option value="p026">p026</option>
<option value="p027">p027</option>
<option value="p028">p028</option>
<option value="p029">p029</option>
<option value="p030">p030</option>
<option value="p031">p031</option>
<option value="p032">p032</option>
<option value="p101">p101</option>
<option value="p102">p102</option>
<option value="p103">p103</option>
<option value="p104">p104</option>
<option value="p105">p105</option>
<option value="p201">p201</option>
<option value="p202">p202</option>
<option value="p203">p203</option>
<option value="p204">p204</option>
<option value="p205">p205</option>
<option value="p206">p206</option>
<option value="p301">p301</option>
<option value="p302">p302</option>
<option value="p303">p303</option>
<option value="p304">p304</option>
<option value="p305">p305</option>
<option value="p306">p306</option>
<option value="p307">p307</option>
<option value="p999">p999</option>
<option value="p998">p998</option>
<option value="p997">p997</option>
</select>
</td>
</tr>
<tr>
<td>Session</td>
<td>
<select id="session_in">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
</select>
</td>
</tr>
<tr>
<td>Starting Point</td>
<td>
<select id="restart_in">
<option value="beginning">beginning</option>
<option value="intro">intro</option>
<option value="apt">apt</option>
<option value="sdt">sdt</option>
<option value="pc">pc</option>
<option value="rs1">rs1</option>
<option value="cs1">cs1</option>
<option value="rs2">rs2</option>
<option value="photo">photo</option>
<option value="close">close</option>
</select>
</td>
</tr>
</table>
<button id="launch">Launch</button>
</div>
<div class="module">
<h3>Tega Controls</h3>
Click to send a command to Tega:
<button data-type="TEGA" data-cmd="POSE_SLEEPING">Sleep</button>
<button data-type="TEGA" data-cmd="PERKUP">Wake Up</button>
</div>
</div>
<div id="content2">
<div class="module">
<h3>Interaction</h3>
<button data-type="INTERACTION" data-cmd="PAUSE">Pause</button>
<button data-type="INTERACTION" data-cmd="RESUME">Resume</button>
<button data-type="INTERACTION" data-cmd="STOP">Stop</button>
</div>
<div class="module">
<h3>Yes/No Input</h3>
Select senario outcome:
<button data-type="YESNO" data-cmd="TIMEOUT">Timeout / No Response</button>
<button data-type="YESNO" data-cmd="YES">Yes: Child Will Do It</button>
<button data-type="YESNO" data-cmd="NO">No: Child Won't Do It</button>
</div>
<div class="module">
<h3>Negotiation</h3>
Select negotiation outcome:
<button data-type="NEGOTIATION" data-cmd="TIMEOUT">Timeout / No Response</button>
<button data-type="NEGOTIATION" data-cmd="REFUSAL">Refusal: Child Wants Their Choice</button>
<button data-type="NEGOTIATION" data-cmd="ACQUIESCENCE">Acquiescense: Child Allows Robot's Choice</button>
<button data-type="NEGOTIATION" data-cmd="COMPROMISE GENERAL">Compromise: Do Both (Not Specific)</button>
<button data-type="NEGOTIATION" data-cmd="COMPROMISE CHILD">Compromise: Do Child's First</button>
<button data-type="NEGOTIATION" data-cmd="COMPROMISE ROBOT">Compromise: Do Robot's First</button>
</div>
<div class="module">
<h3>Tega Controls</h3>
Click to send a command to Tega:
<button data-type="TEGA" data-cmd="POSE_SLEEPING">Sleep</button>
<button data-type="TEGA" data-cmd="PERKUP">Wake Up</button>
</div>
<div class="module">
<h3>Story Controls</h3>
Click to signal the end of the story:
<button data-type="THEEND" data-cmd="THEEND">THE END</button>
</div>
</div>
<br>
<br>
<div id="bar-wrapper">
<div id="bar">
<span id="confirm_text">Select a command to send</span>
<button id="send" disabled>CONFIRM AND SEND</button>
</div>
</div>
</body>
</html>
<script>
(function(){
function setMessage(str) {
const m = str ? " Send '"+str+"'?" : " ";
document.getElementById("confirm_text").innerHTML = m;
}
var cmd;
let setCmd = e => {
cmd = {
type: e.target.attributes["data-type"].value,
cmd: e.target.attributes["data-cmd"].value,
};
setMessage(cmd.cmd);
if (!document.body.attributes["running"]) {
sendCmd();
}
else {
document.getElementById("send").removeAttribute("disabled");
document.getElementById("bar-wrapper").setAttribute("ready", "");
}
};
let clearCmd = () => {
msg = undefined;
setMessage();
document.getElementById("send").setAttribute("disabled", "");
document.getElementById("bar-wrapper").removeAttribute("ready");
};
// Attach the command setter to all command buttons.
for (let b of document.getElementsByTagName("button")) {
if (b.attributes["data-type"]) {
b.onclick = setCmd;
}
}
function sendCmd() {
if (!cmd) return;
let content = cmd;
clearCmd();
fetch("/command", {
method: "POST",
body: JSON.stringify(content),
headers: {
"Content-Type": "text/plain",
"Content-Length": content.length,
},
}).catch(err => {
console.error(err);
});
};
document.getElementById("send").onclick = sendCmd;
document.getElementById("launch").onclick = function() {
let content = {
experimenter: document.getElementById("experimenter_in").value,
participant: document.getElementById("participant_in").value,
session: document.getElementById("session_in").value,
restart: document.getElementById("restart_in").value,
};
fetch("/launch", {
method: "POST",
body: JSON.stringify(content),
headers: {
"Content-Type": "text/plain",
"Content-Length": content.length,
},
}).then(r => {
if (!r.ok)
alert("Invalid value. Did you fill out all the boxes?");
}).catch(err => {
console.error(err);
alert("Invalid value. Did you fill out all the boxes?");
});
};
// Get status.
var updating;
setInterval(() => {
if (updating) return;
updating = true;
fetch("/status")
.then(r => r.json())
.then(j => {
if (j.msg) {
document.getElementById("experimenter").innerHTML = j.msg.experimenter;
document.getElementById("participant").innerHTML = j.msg.participant;
document.getElementById("session").innerHTML = j.msg.session;
}
if (j.running) {
document.body.setAttribute("running", "")
} else {
document.body.removeAttribute("running", "")
}
updating = false;
})
.catch(err => {
console.error(err);
updating = false;
});
}, 1000);
})();
</script>