-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
60 lines (45 loc) · 1.84 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
<!DOCTYPE html><html class=''>
<head>
<meta charset='UTF-8'>
<meta name="robots" content="noindex">
<title>The Experiment Factory simple-reaction-time</title>
<!-- We use jquery but could also use Vanilla Javascript-->
<script src='assets/js/jquery.min.js'></script>
<!-- Note we are using version jspsych-6.0.4-->
<script src="assets/js/jspsych.js"></script>
<script src="assets/js/plugins/jspsych-html-keyboard-response.js"></script>
<script src="assets/js/plugins/jspsych-image-keyboard-response.js"></script>
<!-- This is where our timeline is defined!-->
<script src='experiment.js'></script>
<!-- Here is the experiment styling -->
<link href="assets/css/jspsych.css" rel="stylesheet" type="text/css"></link>
</head>
<body></body>
<script>
$( document ).ready(function() {
jsPsych.init({
timeline: timeline,
fullscreen: true,
on_trial_finish: function(data){
//TODO: need to add back in function to add identifier
console.log('This happens at the end!')
},
on_finish: function(data){
$.ajax({
type: "POST",
url: '/save',
data: { "data": data },
success: function(){ document.location = "/next" },
dataType: "application/json",
//TODO: is this still the best/recommended way to do this?
// Endpoint not running, local save
error: function(err) {
if (err.status == 200){ document.location = "/next"
} else { jsPsych.data.displayData() }
}
});
}
});
});
</script>
</html>