This repository has been archived by the owner on Nov 16, 2019. It is now read-only.
forked from madebyafox/learning_at_a_glance
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blockstart.html
181 lines (159 loc) · 4.4 KB
/
blockstart.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
<!DOCTYPE html>
<html>
<head>
<script src = "js/helpers.js"></script>
<link rel="stylesheet" type="text/css" href="css/amystyle.css">
</head>
<body>
<div style="display: flex;
justify-content: center;
align-items: center; height: 500px;
width: 100%;" >
<h3 id ="title"> </h3>
<h3 id ="exercise"></h3>
<h3 id ="input"></h3>
</div>
<p style="text-align: center; font-style: italic;">Press ENTER to continue</p>
</body>
<script>
window.addEventListener("keydown", doKeyDown, true); //add keyboard key listener
var title=""; //placeholder for title text
var exercise = ""; //placeholder for exercise text
var mouseInst = new Audio("img/instructions/mouse.mp3"); //instructions for mouse training block 0
var gazeInst = new Audio("img/instructions/gaze.mp3"); //instructions for gaze training block 0
var condition = parseInt(getQueryVariable("condition")); //get the condition from the querystring
var lastBlock = parseInt(getQueryVariable("block")); //get the last block from the querystring
var input = getQueryVariable("input"); //get the input var from the querystring //used only for logic on determining input for block 0
var nextBlock = getBlock(lastBlock,input); //decide what the next block to be executed is;
var stimulus = getStimulus(nextBlock); //get the next stimulus based on the block
var nextInput = getInput(nextBlock,condition); //get the next input baed on the block and condition
//SET DISPLAY INSTRUCTIONS
document.getElementById("title").innerHTML=title;
document.getElementById("exercise").innerHTML=exercise;
document.getElementById("input").innerHTML=" navigating by "+nextInput;
var next = "stimulus.html?participant="+getQueryVariable("participant")+"&condition="+condition+"&block="+nextBlock+"&stimulus="+stimulus+"&input="+nextInput;
//AWESOME SUPER FUNCTIONS OF AWESOMENESS : note : not actually SUPER functions
function getBlock (block, input)
{
if (block == 0) //handle the training trials
{
if (input==""){
return 0;
}
else if (input =="mouse"){
return 0;
}
else if(input =="gaze"){
return 1;
}
}
else if (block ==4)
{ window.location.href="debrief.html";}//redirect to survey
else { //otherwise increment by 1
return (block + 1);
}
}
function getStimulus(block)
{
switch (block){
case 0:
title = "Let's practice ";
exercise ="";
return "training";
break;
case 1:
title = "";
exercise ="#1: flags - "
return "flags";
break;
case 2:
title = "";
exercise ="#2: fish - "
return "fish";
break;
case 3:
title = "";
exercise ="#3: poinsonous mushrooms - "
return "mushrooms";
break;
case 4:
title = "";
exercise ="#4: viruses - "
return "viruses";
break;
}
}
function getInput(block,condition)
{
if (condition == 1)
{
switch (block)
{
case 0:
if (input == ""){
mouseInst.play();
return "mouse"
}
if (input == "mouse"){
gazeInst.play();
return "gaze";
}
break;
case 1:
return "gaze";
break;
case 2:
return "mouse";
break;
case 3:
return "gaze";
break;
case 4:
return "mouse";
break;
}
}
else if (condition == 2)
{
switch (block)
{
case 0:
if (input == ""){
mouseInst.play();
return "mouse";}
if (input == "mouse"){
gazeInst.play();
return "gaze";}
break;
case 1:
return "mouse";
break;
case 2:
return "gaze";
break;
case 3:
return "mouse";
break;
case 4:
return "gaze";
break;
}
}
}
//----------------------
///CALLED EVERYTIME A KEY IS PRESSED
//----------------------
function doKeyDown(e) {
switch (e.keyCode) {
case 13:
console.log(" ENTER PRESSED");
window.location.href=next;
break;
case 32:
mouseInst.pause();
gazeInst.pause();
break;
}
}
</script>
</html>