-
Notifications
You must be signed in to change notification settings - Fork 0
/
entry.js
46 lines (44 loc) · 1.36 KB
/
entry.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
36
37
38
39
40
41
42
43
44
45
46
;function Entry(){
this.lang = null;
this.set = null;
this.start_date = null;
this.start_time = null;
this.end_time = null; // in ms
this.duration = null; // in second
this.ds = new Object();
this.comment_end = null;
}
// Data collected within one ID (questions)
function Data(){
this.ctype1 = null;
this.low = null;
this.high = null;
this.time = []; // array of intervals in second of user's actions
this.comment_question = null;
}
// encode Entry Object to CSV one line format
function flat(e){
//var r = [e.lang, e.set, e.start_date, e.start_time/1000, e.end_time/1000, e.duration];
var r = [e.lang, e.set, e.start_date, e.start_time+'', e.end_time+'', e.duration];
var ids_sorted = ids.concat([]);
ids_sorted.sort(sortNumberAscending); // for alignment
for(var j=0; j<ids_sorted.length; j++){
var i = ids_sorted[j];
r.push('ID'+i);
//data
//if(e.ds[i].high==0){e.ds[i].high=Infinity;}
r = r.concat([e.ds[i].ctype1, e.ds[i].low, e.ds[i].high],e.ds[i].time);
r = r.concat(new Array(config.depth + 1 - e.ds[i].time.length));
r.push(e.ds[i].comment_question.replace(/,/g,";"));
}
//* make undefined and null empty string '' for later encoding
for(var i=r.length-1;i>=0;i--){
if(r[i]==undefined){r[i]='';}
if(r[i]==null){r[i]='';}
}
//*/
r.push("SEQ");
r = r.concat(ids);
//log("r: "+r);
return r;
}