-
Notifications
You must be signed in to change notification settings - Fork 2
/
logger.js
35 lines (31 loc) · 954 Bytes
/
logger.js
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
function Logger(task, parent) {
this.parent = parent;
var d = new Date();
this.session_id = d.getTime();
uid = firebase.auth().currentUser.uid;
this.path = 'taskData/' + uid + '/' + task + '/' + this.session_id;
this.data = {};
this.inputData = function(field, value) {
this.data[field] = value;
};
this.log = function(path, data) {
var updates = {};
updates[this.path + '/' + path] = data;
firebase.database().ref().update(updates);
}
this.sendData = function(trial) {
this.data["trial"] = trial;
console.log(this.data);
console.log(this.parent.state);
firebase.database().ref(this.path + '/' + this.parent.state + '/'
+ trial).set(this.data);
console.log(this.data);
this.data = {};
};
this.downloadData = function() {
exportData = 'data:text/json;charset=utf-8,';
exportData += escape(JSON.stringify(this.rows));
encodedUri = encodeURI(exportData);
newWindow = window.open(encodedUri);
};
}