12 var minutes = Math.floor( (ts/1000) / 60 ) % 60; |
12 var minutes = Math.floor( (ts/1000) / 60 ) % 60; |
13 var seconds = Math.floor( (ts/1000) % 60); |
13 var seconds = Math.floor( (ts/1000) % 60); |
14 return ((hours < 10 ? '0' + hours : hours) + ':' + (minutes < 10 ? '0' + minutes : minutes) + ':' + (seconds < 10 ? '0' + seconds : seconds)); |
14 return ((hours < 10 ? '0' + hours : hours) + ':' + (minutes < 10 ? '0' + minutes : minutes) + ':' + (seconds < 10 ? '0' + seconds : seconds)); |
15 } |
15 } |
16 |
16 |
|
17 function getAnnotCategories(urlCategories, annotCategories) { |
|
18 |
|
19 var jsonLoader = new PIXI.JsonLoader(urlCategories, true); |
|
20 |
|
21 jsonLoader.on('loaded', function(res) { |
|
22 var data = res.target.json; |
|
23 |
|
24 while(annotCategories.length > 0) { |
|
25 annotCategories.pop(); |
|
26 } |
|
27 |
|
28 data.sessions.forEach(function(session) { |
|
29 var annotCat = { |
|
30 ts: session.start_ts === null ? new Date(0) : Date.parse(session.start_ts), |
|
31 colors: {} |
|
32 } |
|
33 var categoriesJson = session.categories_json; |
|
34 annotCat.order = categoriesJson.order; |
|
35 categoriesJson.categories.forEach(function(cat) { |
|
36 annotCat.colors[cat.code] = colorToHex(cat.color); |
|
37 }); |
|
38 annotCat.defaultColor = categoriesJson.defaultColor || "#536991"; |
|
39 annotCategories.push(annotCat); |
|
40 }); |
|
41 console.log(annotCategories); |
|
42 annotCategories[0].order.push("default"); |
|
43 }); |
|
44 |
|
45 jsonLoader.load(); |
|
46 |
|
47 } |
17 |
48 |
18 module.exports = { |
49 module.exports = { |
19 formatTime: formatTime |
50 formatTime: formatTime, |
|
51 getAnnotCategories: getAnnotCategories |
20 }; |
52 }; |