-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtemp.html
606 lines (501 loc) · 18.9 KB
/
temp.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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
<!DOCTYPE html>
<!--[if lt IE 8]>
<html class="ie-warning">
<![endif]-->
<!--[if IE 8]>
<html class="ie8">
<![endif]-->
<!--[if IE 9]>
<html class="ie9">
<![endif]-->
<!--[if !IE]> -->
<html class="normal">
<!-- <![endif]-->
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="/tickets2/jsPsych/jspsych.js"></script>
<script src="/tickets2/jsPsych/plugins/jspsych-text.js"></script>
<script src="/tickets2/jsPsych/plugins/jspsych-html.js"></script>
<script src="/tickets2/jsPsych/plugins/jspsych-animation.js"></script>
<script src="/tickets2/jsPsych/plugins/jspsych-number-animation.js"></script>
<script src="/tickets2/jsPsych/plugins/jspsych-html-animation.js"></script>
<script src="/tickets2/jsPsych/plugins/jspsych-bar-choose.js"></script>
<script src="/tickets2/jsPsych/plugins/jspsych-ticket-choose.js"></script>
<script src="/tickets2/jsPsych/plugins/jspsych-final.js"></script>
<script src="/tickets2/jsPsych/plugins/jspsych-age.js"></script>
<script src="/tickets2/jsPsych/plugins/jspsych-instructions_check.js"></script>
<script src="/tickets2/jsPsych/plugins/jspsych-training_avg.js"></script>
<script src="/tickets2/jsPsych/plugins/jspsych-call-function.js"></script>
<script src="/tickets2/jsPsych/plugins/jspsych-workerid.js"></script>
<script src="/tickets2/jsPsych/plugins/jspsych-special_sequence.js"></script>
<script src="/tickets2/jsPsych/plugins/jspsych-points-update.js"></script>
<script src="/tickets2/utils/general.js"></script>
<script src="/tickets2/utils/bar-choose-plugin.js"></script>
<script src="/tickets2/utils/jquery.transform2d.js"></script>
<script src="/tickets2/utils/json2.js"></script>
<script src="/tickets2/utils/browserdetect.js"></script>
<script src="/tickets2/utils/select2.full.min.js"></script>
<link href="/tickets2/utils/select2.min.css" rel="stylesheet" type="text/css"></link>
<link href="/tickets2/jsPsych/css/jspsych.css" rel="stylesheet" type="text/css"></link>
<link href="/tickets2/utils/general.css" rel="stylesheet" type="text/css"></link>
<link href="/tickets2/utils/bar-choose-plugin.css" rel="stylesheet" type="text/css"></link>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<link href="/tickets2/utils/age.css" rel="stylesheet" type="text/css"></link>
<link href="/tickets2/utils/consent.css" rel="stylesheet" type="text/css"></link>
<link href="/tickets2/utils/start.css" rel="stylesheet" type="text/css"></link>
<link href="/tickets2/utils/points.css" rel="stylesheet" type="text/css"></link>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=0.5, user-scalable=no">
<title>Ticket prices</title>
<script type="text/javascript">
var consent_trial = {
type: "html",
url: "/tickets2/utils/consent.html",
cont_btn: "agree2"
}
var age_trial = {
type: "age"
}
var workerid_trial = {
type: "workerid"
}
var special_sequence_trial = {
type: "special_sequence"
}
var instructions_trial = {
type: "instructions_check",
url: "/tickets2/utils/instructions.html",
instructions: "id-int",
check: "id-check",
right: "c-right",
wrong: "c-wrong",
cont_btn: "continue1",
}
var start_trial = {
type: "html",
url: "/tickets2/utils/start.html",
cont_btn: "start1"
}
var animation_trial = {
type: "number-animation",
//prices: animdata,
phase: 0,
continue_message: "Next step"
}
var training_trial = {
type: "bar-choose",
instructions: "Imagine you would see MAXVAL more tickets for your trip to Canada.",
subtitle: "Please drag the bar or type in the input field to determine the amount of tickets <br> that are in the equivalent price range for this trip. <br><br>Press continue when you are sure of your answers.",
// categories: ["$135 - $150", "$151 - $165", "$166 - 180", "$181 - $195", "$196 - $210", "$211 - $225", "$226 - $240"],
min_val: 0,
max_val: 20,
phase: 0,
number: 0
//answers: animanswers
}
var testing_instructions_trial = {
type: "html",
url: "/tickets2/utils/testing.html",
cont_btn: "testingstart"
}
// Second testing instructions (after example sequence)
var testing_instructions2_trial = {
type: "html",
url: "/tickets2/utils/testing_after.html",
cont_btn: "testingstart"
}
// Second bar graph to see learning
var training_trial2 = {
type: "bar-choose",
instructions: "Imagine you would see yet another MAXVAL tickets to Canada.",
subtitle: "Please drag the bar or type in the input field to determine the amount of tickets <br> that are in the equivalent price range for this trip. Press continue when you are sure of your answers.",
// categories: ["$135 - $150", "$151 - $165", "$166 - 180", "$181 - $195", "$196 - $210", "$211 - $225", "$226 - $240"],
min_val: 0,
max_val: 20,
phase: 0,
number: 1
//answers: animanswers
}
var mid_test_trial = {
type: "html",
url: "/tickets2/utils/mid_test.html",
cont_btn: "continue"
}
var training_trial3 = {
type: "bar-choose",
instructions: "Imagine you would see yet another MAXVAL tickets to Canada.",
subtitle: "Please drag the bar or type in the input field to determine the amount of tickets <br> that are in the equivalent price range for this trip. Press continue when you are sure of your answers.",
// categories: ["$135 - $150", "$151 - $165", "$166 - 180", "$181 - $195", "$196 - $210", "$211 - $225", "$226 - $240"],
min_val: 0,
max_val: 20,
phase: 0,
number: 2
//answers: animanswers
}
// Second training phase instructions
var p2_start_trial = {
type: "html",
url: "/tickets2/utils/start2.html",
cont_btn: "start2"
}
// Second training phase
var p2_animation_trial = {
type: "number-animation",
//prices: animdata2,
phase: 1,
continue_message: "Next step"
}
var p2_training_trial = {
type: "bar-choose",
instructions: "Imagine you would see MAXVAL more tickets for your trip to Mexico City.",
subtitle: "Please drag the bar or type in the input field to determine the amount of tickets <br> that are in the equivalent price range for this trip. Press continue when you are sure of your answers.",
// categories: ["$105 - $130", "$131 - $155", "$156 - $180", "$181 - $205", "$206 - $230", "$231 - $255", "$256 - $280"],
min_val: 0,
max_val: 20,
phase: 1,
number: 0
//answers: animanswers2
}
var p2_testing_instructions_trial = {
type: "html",
url: "/tickets2/utils/testing2.html",
cont_btn: "testingstart"
}
// Second bar graph to see learning
var p2_training_trial2 = {
type: "bar-choose",
instructions: "Imagine you would see yet another MAXVAL tickets to Mexico City.",
subtitle: "Please drag the bar or type in the input field to determine the amount of tickets <br> that are in the equivalent price range for this trip. Press continue when you are sure of your answers.",
// categories: ["$105 - $130", "$131 - $155", "$156 - $180", "$181 - $205", "$206 - $230", "$231 - $255", "$256 - $280"],
min_val: 0,
max_val: 20,
phase: 1,
number: 1
//answers: animanswers2
}
var p2_mid_test_trial = {
type: "html",
url: "/tickets2/utils/mid_test.html",
cont_btn: "continue"
}
var p2_training_trial3 = {
type: "bar-choose",
instructions: "Imagine you would see yet another MAXVAL tickets to Mexico City.",
subtitle: "Please drag the bar or type in the input field to determine the amount of tickets <br> that are in the equivalent price range for this trip. Press continue when you are sure of your answers.",
// categories: ["$105 - $130", "$131 - $155", "$156 - $180", "$181 - $205", "$206 - $230", "$231 - $255", "$256 - $280"],
min_val: 0,
max_val: 20,
phase: 1,
number: 2
//answers: animanswers2
}
var points_update_trial = {
type: "points-update"
}
var p2_points_update_trial = {
type: "points-update"
}
var final_trial = {
type: "final"
}
function preload()
{
for(var i = 0; i < NUM_TICKETS; i++)
{
TICKET_IMAGES[0][i] = new Image();
TICKET_IMAGES[0][i].src = "/tickets2/utils/tickets/" + window.ticketprefix + "/ticket" + (i+1) + ".jpg";
TICKET_IMAGES[0][i].classList += " ticket-img";
TICKET_IMAGES[1][i] = new Image();
TICKET_IMAGES[1][i].src = "/tickets2/utils/tickets/" + window.ticketprefix + "/2ticket" + (i+1) + ".jpg";
TICKET_IMAGES[1][i].classList += " ticket-img";
}
}
function init_exp()
{
// if(Function('/*@cc_on return document.documentMode===10@*/')()){ $("body").addClass("ie10"); }
if(document.getElementsByTagName("html")[0].classList == "ie-warning" || (BrowserDetect.browser == "Explorer" && BrowserDetect.version <= 7))
{
document.getElementsByTagName("body")[0].innerHTML = "<p class='ie-nope'>It's time to upgrade your browser. Seriously, stop using this clunky thing.";
return;
}
BrowserDetect.init();
if(BrowserDetect.browser == "Explorer" && BrowserDetect.version == 10)
$("html").addClass("ie10");
if(BrowserDetect.browser == "Explorer" && BrowserDetect.version == 8)
window.ticketprefix = "ie8";
else if(BrowserDetect.browser == "Explorer" && BrowserDetect.version < 11)
window.ticketprefix = "ie9";
else
window.ticketprefix = "normal";
preload();
//window.viewportUnitsBuggyfill.init({refreshDebounceWait: 250});
var timeline = [];
$.post("/tickets2/get.php", { f7g12d: "y" }, function(d) {
var animdata = [];
var animanswers = [];
var animdata2 = [];
var animanswers2 = [];
var testing_data = [];
var p2_testing_data = [];
var training_ranges = [];
var da = JSON.parse(d);
testing_data = da["testing"][0];
p2_testing_data = da["testing"][1];
animdata = da["training"][0];
animdata2 = da["training"][1];
animanswers = da["answers"][0];
animanswers2 = da["answers"][1];
training_ranges = da["training_ranges"];
var training_sort = parseInt(da["training_sort"]);
var threshold = parseFloat(da["training_threshold"]);
console.log(animanswers);
//animation_trial.prices = animdata;
//p2_animation_trial.prices = animdata2;
training_trial.answers = animanswers;
training_trial2.answers = animanswers;
training_trial3.answers = animanswers;
p2_training_trial.answers = animanswers2;
p2_training_trial2.answers = animanswers2;
p2_training_trial3.answers = animanswers2;
training_trial.categories = da["categories"][0];
training_trial2.categories = da["categories"][0];
training_trial3.categories = da["categories"][0];
p2_training_trial.categories = da["categories"][1];
p2_training_trial2.categories = da["categories"][1];
p2_training_trial3.categories = da["categories"][1];
training_trial.max_val = training_sort;
training_trial2.max_val = training_sort;
training_trial3.max_val = training_sort;
p2_training_trial.max_val = training_sort;
p2_training_trial2.max_val = training_sort;
p2_training_trial3.max_val = training_sort;
training_trial.pass_threshold = threshold;
p2_training_trial.pass_threshold = threshold;
var assignment_id = "921994";
//timeline.push(special_sequence_trial);
timeline.push(consent_trial);
timeline.push(age_trial);
workerid_trial.on_finish = function(data) {
$.post("/tickets2/setworkerid.php", { id : data.worker_id });//, function(d) { console.log(d); });
};
timeline.push(workerid_trial);
timeline.push(instructions_trial);
timeline.push(start_trial);
var passed = false;
for(var i = 0; i < animdata.length; i++)
{
for(var j = 0; j < animdata[i].length; j++)
{
timeline.push({
type: "number-animation",
prices: animdata[i][j],
phase: 0,
continue_message: "Next",
repeat_num: i,
sequence_num: j,
passed: function() { return passed; }
});
timeline.push({
type: "training_avg",
phase: 0,
sequence_num: j,
repeat_num: i,
passed: function() { return passed; }
sequence: animdata[i][j],
min_val: training_ranges[0][0],
max_val: training_ranges[0][1]
});
}
timeline.push(Object.assign({ repeat_num: i,
passed: function() { return passed; },
on_finish: function(data) {
if(data.passed)
passed = true;
}
}, training_trial));
}
timeline.push(testing_instructions_trial);
// example testing sequence
timeline.push({ type: "ticket-choose",
phase: 0,
row: -1,
showpoints: false,
prices: [184, 180, 224, 165, 181, 199, 185, 193, 218, 126],
continue_mesage: "Finish",
sequence: ""
});
timeline.push(testing_instructions2_trial);
// testing_data.length = 4;
for(var i = 0; i < testing_data.length; i++)
{
timeline.push({ type: "ticket-choose",
prices: testing_data[i],
row: i,
phase: 0,
continue_message: "Next sequence",
sequence: "In sequence <span>" + (i + 1) + "</span> out of <span>" + testing_data.length + "</span>",
// points: function() { return points_counter.p[0]; },
showpoints: true,
on_finish: function(data) {
$.post("/tickets2/check.php", { phase: 0, sequence: data.sequence, answer: data.result });
}
});
if(i == Math.floor((testing_data.length - 1) / 2)) {
timeline.push(points_update_trial);
timeline.push(training_trial2);
timeline.push(mid_test_trial);
}
}
timeline[timeline.length-1].continue_message = "Finish";
timeline[timeline.length-1].on_finish = function(data) {
$.post("/tickets2/check.php", { phase: 0, sequence: data.sequence, answer: data.result });
};
timeline.push(training_trial3);
/*
timeline.push(p2_start_trial);
var passed2 = false;
for(var i = 0; i < animdata2.length; i++)
{
for(var j = 0; j < animdata2[i].length; j++)
{
timeline.push({
type: "number-animation",
prices: animdata2[i][j],
phase: 1,
continue_message: "Next",
repeat_num: i,
sequence_num: j,
passed: function() { return passed2; }
});
timeline.push({
type: "training_avg",
phase: 1,
sequence_num: j,
repeat_num: i,
passed: function() { return passed2; }
sequence: animdata2[i][j],
min_val: training_ranges[1][0],
max_val: training_ranges[1][1]
});
}
timeline.push(Object.assign({ repeat_num: i,
passed: function() { return passed2; },
on_finish: function(data) {
if(data.passed)
passed2 = true;
}
}, p2_training_trial));
}
timeline.push(p2_testing_instructions_trial);
//p2_testing_data.length = 4;
//for(var i = 0; i < 2; i++)
for(var i = 0; i < p2_testing_data.length; i++)
{
timeline.push({ type: "ticket-choose",
prices: p2_testing_data[i],
row: i,
phase: 1,
continue_message: "Next sequence",
sequence: "In sequence <span>" + (i + 1) + "</span> out of <span>" + p2_testing_data.length + "</span>",
// points: function() { return points_counter.p[1]; },
showpoints: true,
on_finish: function(data) {
$.post("/tickets2/check.php", { phase: 1, sequence: data.sequence, answer: data.result });
} });
if(i == Math.floor((p2_testing_data.length - 1) / 2)) {
timeline.push(p2_points_update_trial);
timeline.push(p2_training_trial2);
timeline.push(p2_mid_test_trial);
}
}
timeline[timeline.length-1].continue_message = "Finish";
timeline[timeline.length-1].on_finish = function(data) {
$.post("/tickets2/check.php", { phase: 1, sequence: data.sequence, answer: data.result });
};
timeline.push(p2_training_trial3);
*/
timeline.push(special_sequence_trial);
timeline.push(final_trial);
/* var completion_code = {
type: 'html',
url: 'confirmation_code.html'
};
timeline.push(completion_code);
*/
//save data
// function to save data
/* function saveData(filename, filedata){
$.ajax({
type:'post',
cache: false,
url: '/tickets2/save_data.php', // this is the path to the above PHP script
data: {filename: filename, filedata: filedata},
// complete: function() {
// window.location.href = "confirmation_code.html";
// }
});
}
var save_data = {
type: 'call-function',
func: function()
{
saveData(subject_id + '_output.csv', jsPsych.data.getDataAsCSV())
}
,timing_post_trial: 0
};
timeline.push(save_data);*/
// save data end
//var worker_id = "NOT_SET";
//var assignment_id = "921994";
$("#wheel").css("display", "none");
jsPsych.init({
timeline: timeline,
display_element: $("#jspsych-main"),
on_finish: function(data) {
$("#jspsych-main").empty().load("/tickets2/confirmation_code.html");
//console.log(worker_id);
$.post("/tickets2/submit.php", { data: JSON.stringify(data), assignment_id: assignment_id }, function(r) {
console.log(r);
});
}
});
});
}
function init_preview(tri)
{
$("#wheel").css("display", "none");
jsPsych.init({
timeline: [consent_trial, tri],
display_element: $("#jspsych-main")
});
}
var accept_trial = {
type: "html",
url: "/tickets2/utils/accept.html"
};
var outside_trial = {
type: "html",
url: "/tickets2/utils/outside.html"
};
function init()
{
/*var tinfo = jsPsych.turk.turkInfo();
if(tinfo.outsideTurk)
init_preview(outside_trial);
else if(tinfo.previewMode)
init_preview(accept_trial);
else
init_exp(tinfo.workerId, tinfo.assignmentId);*/
var prev = false;
if(prev)
init_preview(accept_trial);
else
init_exp();
}
</script>
</head>
<body onload="init()">
<div class="wheel-loader-wrap" id="wheel"><div class="wheel-loader"></div></div>
<div id="jspsych-main"></div>
</body>
</html>