This repository was archived by the owner on Apr 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathssl.html
More file actions
executable file
·386 lines (328 loc) · 12.9 KB
/
ssl.html
File metadata and controls
executable file
·386 lines (328 loc) · 12.9 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
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
374
375
376
377
378
379
380
381
382
383
384
385
386
<!doctype html>
<html>
<head>
<meta charset='utf-8'>
<title>My experiment</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="jspsych-5.0.3/jspsych.js"></script>
<script src="jspsych-5.0.3/plugins/jspsych-text.js"></script>
<script src="jspsych-5.0.3/plugins/jspsych-survey-text.js"></script>
<script src="jspsych-5.0.3/plugins/jspsych-single-audio.js"></script>
<script src="jspsych-5.0.3/plugins/jspsych-single-stim.js"></script>
<link href="jspsych-5.0.3/css/jspsych.css" rel="stylesheet" type="text/css"></link>
</head>
<body>
</body>
<script>
var par_id = {
type: 'survey-text',
questions: ['Enter your participant ID'],
timing_post_trial: 1000
};
String.prototype.format = function () {
var i = 0, args = arguments;
return this.replace(/{}/g, function () {
return typeof args[i] != 'undefined' ? args[i++] : '';
});
};
var cond_assign = jsPsych.randomization.sample(['lang1','lang2'],1)[0];
var datetime = jsPsych.startTime();
var rand_targ = ['bi','pu','du','da'];
var rand_targ2 = ['ku','tu','pi','do'];
var pick_targ = function(targType) {
return targType[Math.floor(Math.random()*targType.length)];}
if (cond_assign === 'lang1') {
var target = pick_targ(rand_targ);
} else if (cond_assign === 'lang2') {
var target = pick_targ(rand_targ2);}
/* define instructions block */
var instr1 = {
type: 'single-audio',
stimulus: 'sound/ssl_instr1.wav',
prompt: "<p><center>Press the spacebar to begin.</center></p>",
choices: ['space'],
timing_response: -1,
response_ends_trial: true
};
var instr2 = {
type: 'single-audio',
stimulus: 'sound/ssl_instr2.wav',
prompt: "<p><center>Hi! We're going to listen to an alien language today.</center></p>",
choices: ['space'],
timing_response: -1,
response_ends_trial: true
};
var instr3 = {
type: 'single-audio',
stimulus: 'sound/ssl_instr3.wav',
prompt: "<p><center>This is Meeple</center></p> <img src='image/Alien11.png' style='position:fixed;top:20%;left:42%;'>",
choices: ['space'],
timing_response: -1,
response_ends_trial: true
};
var instr4 = {
type: 'single-audio',
stimulus: 'sound/ssl_instr4.wav',
prompt: "<p>Meeple is from Planet B. We're going to listen to Meeple speak her alien language.</p><img src='image/Alien11.png' style='position:fixed;top:20%;left:42%;'>",
choices: ['space'],
timing_response: -1,
response_ends_trial: true
};
var instr5 = {
type: 'single-audio',
stimulus: 'sound/ssl_instr5.wav',
prompt: "<p>Meeple is going to say her favorite word for you now. Listen carefully!<p><img src='image/Alien11.png' style='position:fixed;top:20%;left:42%;'>",
choices: ['space'],
timing_response: -1,
response_ends_trial: true
};
var instr6_targ = {
type: 'single-audio',
stimulus: 'sound/{}.wav'.format(target),
choices: ['space'],
timing_response: -1,
response_ends_trial: true
};
var instr6 = {
type: 'single-audio',
stimulus: 'sound/ssl_instr6.wav',
prompt: "<p>When you hear Meeple say her favorite word, press the space bar as soon as you can. Let's practice!</p><img src='image/Alien11.png' style='position:fixed;top:20%;left:42%;'>",
choices: ['space'],
timing_response: -1,
response_ends_trial: true
};
var instr7 = {
type: 'single-audio',
stimulus: 'sound/ssl_instr7.wav',
prompt: "<p>Good job! Meeple is going to say many words in her alien language. Remember to press the spacebar whenever you hear Meeple's favorite word!</p><img src='image/Alien11.png' style='position:fixed;top:29%;left:42%;'>",
choices: ['space'],
timing_response: -1,
response_ends_trial: true
};
//reading the sound file
function textFileToArray(filename)
{
var reader = (window.XMLHttpRequest != null )
? new XMLHttpRequest()
: new ActiveXObject("Microsoft.XMLHTTP");
reader.open("GET", filename, false );
reader.send( );
return reader.responseText.split('\n');
}
//check condition
if (cond_assign === 'lang1') {
var sound = textFileToArray('S_fam_seq_1.txt');}
else if (cond_assign === 'lang2') {
var sound = textFileToArray('S_fam_seq_2.txt');}
//putting the sound file into the experimental block
var trials = [];
for (var i = 0; i < ((sound.length)-1); i++) {
trials.push({stimulus: sound[i]});
}
var block = {
type: 'single-audio',
choices: 'space',
timeline: trials,
timing_response: 460,
timing_post_trial: 20
}
var instr8 = {
type: 'single-audio',
stimulus: 'sound/ssl_instr8.wav',
prompt: "<p><center>Great, you did it!</center></p>",
choices: ['space'],
timing_response: -1,
response_ends_trial: true
}
var instr9 = {
type: 'single-audio',
stimulus: 'sound/ssl_instr9.wav',
prompt: "<p><center>Now look at these two aliens</center></p><img src='../tone_images/two_aliens.png' style='position:fixed;top:20%;left:35%;'>",
choices: ['space'],
timing_response: -1,
response_ends_trial: true
}
var instr10 = {
type: 'single-audio',
stimulus: 'sound/ssl_instr10.wav',
prompt: "<p><center>Each of these aliens will say a short phrase. Please try your best to identify which phrase sounds more like Meeple's language. If you don't know the answer, just give your best guess!\n\nPress the left arrow if the first alien's phrase sounds more like Meeple's language, and press the right arrow if the second alien's phrase sounds more like Meeple's language.</center></p>",
choices: ['space'],
timing_response: -1,
response_ends_trial: true
}
//load all the sound files for task 2
var sounds = [];
sounds['1'] = 'sound/di.wav';
sounds['2'] = 'sound/ba.wav';
sounds['3'] = 'sound/pu.wav';
sounds['4'] = 'sound/pa.wav';
sounds['5'] = 'sound/bi.wav';
sounds['6'] = 'sound/do.wav';
sounds['7'] = 'sound/bu.wav';
sounds['8'] = 'sound/tu.wav';
sounds['9'] = 'sound/du.wav';
sounds['10'] = 'sound/pi.wav';
sounds['11'] = 'sound/ti.wav';
sounds['12'] = 'sound/ta.wav';
sounds['13'] = 'sound/da.wav';
sounds['14'] = 'sound/go.wav';
sounds['15'] = 'sound/ku.wav';
sounds['16'] = 'sound/ro.wav';
sounds['17'] = 'sound/silence.wav';
sounds['18'] = 'sound/la.wav';
//asign order of run depending on condition. [0] signifies a short pause
if (cond_assign === 'lang1') {
var forced_test = [17,1,2,[3,0],1,4,5,17,1,2,[3,0],7,8,9,17,7,8,[9,0],1,2,3,17,7,4,[13,0],12,2,13,17,1,2,[3,0],12,2,13,17,
1,2,[3,0],10,11,3,17,10,11,[3,0],10,8,5,17,1,4,[5,0],10,8,5,17,7,4,[13,0],10,11,3,17,10,8,[5,0],7,8,9,17,12,11,[9,0],
10,11,3,17,12,2,[13,0],12,11,9,17,7,8,[9,0],12,11,9,17,10,8,[5,0],12,2,13,17,1,4,[5,0],1,2,3,17,10,8,[5,0],10,11,3,17,
10,11,[3,0],7,4,13,17,10,11,[3,0],1,2,3,17,12,11,[9,0],7,8,9,17,12,2,[13,0],10,8,5,17,12,11,[9,0],1,4,5,17,10,8,[5,0],1,4,5,17,
10,11,[3,0],12,11,9,17,1,4,[5,0],7,4,13,17,12,2,[13,0],1,2,3,17,7,8,[9,0],10,8,5,17,12,11,[9,0],12,2,13,17,7,4,[13,0],1,4,5,
17,1,4,[5,0],12,11,9,17,7,4,[13,0],7,8,9,17,12,2,[13,0],7,4,13,17,7,8,[9,0],7,4,13,17]}
else if (cond_assign === 'lang2') {
var forced_test = [17,11,7,[6,0],13,5,8,17,4,5,[15,0],14,7,15,17,11,18,[10,0],11,7,6,17,13,16,[10,0],4,16,6,17,14,18,[8,0],
13,5,8,17,13,16,[10,0],4,16,6,17,14,7,[15,0],11,7,6,17,11,18,[10,0],4,5,15,17,13,5,[8,0],14,18,8,17,4,16,[6,0],13,16,10,17,
4,5,[15,0],14,7,15,17,11,7,[6,0],11,18,10,17,4,5,[15,0],14,7,15,17,4,16,[6,0],13,16,10,17,13,5,[8,0],11,7,6,17,14,18,[8,0],11,18,10,17,
4,16,[6,0],4,5,15,17,14,7,[15,0],13,16,10,17,14,18,[8,0],13,5,8,17,11,7,[6,0],14,7,15,17,4,16,[6,0],14,18,8,17,11,7,[6,0],11,18,10,17,13,
5,[8,0],13,16,10,17,4,5,[15,0],11,18,10,17,13,5,[8,0],14,18,8,17,11,7,[6,0],14,7,15,17,4,16,[6,0],13,16,10,17,4,5,[15,0],14,7,15,17,13,
16,[10,0],11,18,10,17,13,5,[8,0],14,18,8,17,11,18,[10,0],11,7,6,17,4,16,[6,0],4,5,15,17]}
var tone_block_2 = [];
for (ii=0; ii<forced_test.length; ii++) {
if (ii !== 0 && forced_test[ii] === 17) {
tone_block_2.push({'stimulus': 'sound/silence.wav',
'prompt': "<p><center>Which phrase is like Meeple\'s?\nPress left for first and right for second.</center></p>, <img src='../tone_images/two_aliens.png' style='position:fixed;top:20%;left:35%;'>",
'choices': [37,39],
'timing_response': 1600000000,
'timing_post_trial': 200,
'response_ends_trial': true});
} else if (ii === 0) {
tone_block_2.push({'stimulus': 'sound/silence.wav',
'prompt': '',
'choices': [37,39],
'timing_response': 200,
'timing_post_trial': 200,
'response_ends_trial': false});
} else if (forced_test[ii][1] === 0){
tone_block_2.push({'stimulus': sounds[forced_test[ii][0]],
'response_ends_trial': false,
'timing_response': 460,
'timing_post_trial': 1000});
} else {
tone_block_2.push({'stimulus': sounds[forced_test[ii]],
'response_ends_trial': false,
'timing_response': 460,
'timing_post_trial': 20});
}
}
var send_time = {
type: 'call-function',
func: function () {var datetime = jsPsych.startTime(); return datetime;}
};
var forced_choice_block = {
type: 'single-audio',
timeline: tone_block_2,
timing_response: 360,
timing_post_trial: 20,
response_ends_trial: false
}
var end = {
type: 'text',
text: "Great, you're done with this task. Please wait while we redirect you to the next page!",
cont_key: ['space'],
}
/* create experiment timeline array */
var timeline = [];
timeline.push(par_id);
timeline.push(instr1);
timeline.push(instr2);
timeline.push(instr3);
timeline.push(instr4);
timeline.push(instr5);
timeline.push(instr6_targ);
timeline.push(instr6);
timeline.push(instr6_targ);
timeline.push(instr7);
// timeline.push(block);
timeline.push(instr8);
timeline.push(instr9);
timeline.push(instr10);
// timeline.push(forced_choice_block);
timeline.push(end);
var datajson = jsPsych.data.dataAsCSV();
jsPsych.data.addProperties({
cond: cond_assign,
targ: '{}'.format(target),
ts: datetime
});
function saveData(filename, filedata){
$.ajax({
type:'post',
cache: false,
url: '../expf/deep/local_data_save.php', // this is the path to the above PHP script
data: {filename: filename, filedata: filedata}
});
}
/* start the experiment */
jsPsych.init({
timeline: timeline,
on_finish: function save_data(datajson){
saveData("{}_ssl.csv".format(jsPsych.data.getTrialsOfType('survey-text')[0].responses.match(/[a-zA-Z0-9]/g).join('').split(/Q0/)[1]), jsPsych.data.dataAsCSV());
var data_table = "ssl_table";
$.ajax({
type:'post',
cache: false,
url: '../savedata.php',
data: {
table: data_table,
json: JSON.stringify(datajson)
},
success: function(output) { console.log(output); }
});
setTimeout(function() {
arraylist = JSON.parse(window.sessionStorage.getItem("list_data_key"));
console.log(arraylist);
if (arraylist.length == 0) {return window.location.replace('../../LSL_Exp/end_page.html');}
var pick_exp = function(expType) {
return expType[Math.floor(Math.random()*expType.length)];
};
var exp = pick_exp(arraylist);
if (exp === 'v'){
arraylist = JSON.parse(window.sessionStorage.getItem("list_data_key"));
var i = arraylist.indexOf("v");
if(i != -1) {
arraylist.splice(i, 1);
}
window.sessionStorage.setItem("list_data_key", JSON.stringify(arraylist));
return window.location.replace('../expf/deep/vsl.html');
}
if (exp === 't'){
arraylist = JSON.parse(window.sessionStorage.getItem("list_data_key"));
var i = arraylist.indexOf("t");
if(i != -1) {
arraylist.splice(i, 1);
}
window.sessionStorage.setItem("list_data_key", JSON.stringify(arraylist));
return window.location.replace('../expf/deep/tsl.html');
}
if (exp === 'l'){
arraylist = JSON.parse(window.sessionStorage.getItem("list_data_key"));
var i = arraylist.indexOf("l");
if(i != -1) {
arraylist.splice(i, 1);
}
window.sessionStorage.setItem("list_data_key", JSON.stringify(arraylist));
return window.location.replace('../LSL_Exp/lsl.html');
}
if (exp === 's'){
arraylist = JSON.parse(window.sessionStorage.getItem("list_data_key"));
var i = arraylist.indexOf("s");
if(i != -1) {
arraylist.splice(i, 1);
}
window.sessionStorage.setItem("list_data_key", JSON.stringify(arraylist));
return window.location.replace('ssl.html');
}
}, 3000);
}
});
</script>
</html>