-
Notifications
You must be signed in to change notification settings - Fork 6
/
index.html
74 lines (62 loc) · 2.63 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
<!DOCTYPE html><html class=''>
<head>
<meta charset='UTF-8'>
<meta name="robots" content="noindex">
<title>The Experiment Factory: Adaptive N-Back</title>
<link rel='stylesheet' type='text/css' href='jspsych.css'>
<link rel='stylesheet' type='text/css' href='default_style.css'>
<link rel='stylesheet' type='text/css' href='style.css'>
</head>
<body>
<script src='js/jquery.min.js'></script>
<script src='js/math.min.js'></script>
<script src='js/jspsych/jspsych.js'></script>
<script src='js/jspsych/plugins/jspsych-text.js'></script>
<script src='js/jspsych/poldrack_plugins/jspsych-poldrack-text.js'></script>
<script src='js/jspsych/poldrack_plugins/jspsych-poldrack-instructions.js'></script>
<script src='js/jspsych/poldrack_plugins/jspsych-attention-check.js'></script>
<script src='js/jspsych/poldrack_plugins/jspsych-poldrack-single-stim.js'></script>
<script src='js/jspsych/poldrack_plugins/jspsych-poldrack-categorize.js'></script>
<script src='js/jspsych/plugins/jspsych-survey-text.js'></script>
<script src='js/jspsych/plugins/jspsych-call-function.js'></script>
<script src='js/jspsych/poldrack_plugins/poldrack_utils.js'></script>
<script src='experiment.js'></script>
<script>
$( document ).ready(function() {
jsPsych.init({
timeline: adaptive_n_back_experiment,
display_element: "getDisplayElement",
fullscreen: true,
on_trial_finish: function(data){
addID('adaptive-n-back')
},
on_finish: function(data){
// Serialize the data
var promise = new Promise(function(resolve, reject) {
var data = jsPsych.data.dataAsJSON();
resolve(data);
})
promise.then(function(data) {
$.ajax({
type: "POST",
url: '/save',
data: { "data": data },
success: function(){ document.location = "/next" },
dataType: "application/json",
// Endpoint not running, local save
error: function(err) {
if (err.status == 200){
document.location = "/next";
} else {
// If error, assue local save
jsPsych.data.localSave('adaptive-n-back_results.csv', 'csv');
}
}
});
})
}
});
});
</script>
</body>
</html>