equal
deleted
inserted
replaced
36 ], |
36 ], |
37 "defaultColor": "#536991" |
37 "defaultColor": "#536991" |
38 } |
38 } |
39 ]; |
39 ]; |
40 |
40 |
41 function colorToHex(c) { |
|
42 var m = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/.exec(c); |
|
43 return m ? '#' + (1 << 24 | m[1] << 16 | m[2] << 8 | m[3]).toString(16).substr(1) : c; |
|
44 } |
|
45 |
|
46 function getAnnotCategories(ecode, serverUrl) { |
41 function getAnnotCategories(ecode, serverUrl) { |
47 |
42 |
48 var url = serverUrl+"/p/api/v1/event/" + ecode; |
43 var url = serverUrl+"/p/api/v1/event/" + ecode; |
49 |
44 |
50 var jsonLoader = new PIXI.JsonLoader(url, true); |
45 var jsonLoader = new PIXI.JsonLoader(url, true); |
61 colors: {} |
56 colors: {} |
62 } |
57 } |
63 var categoriesJson = session.categories_json; |
58 var categoriesJson = session.categories_json; |
64 annotCat.order = categoriesJson.order; |
59 annotCat.order = categoriesJson.order; |
65 categoriesJson.categories.forEach(function(cat) { |
60 categoriesJson.categories.forEach(function(cat) { |
66 annotCat.colors[cat.code] = colorToHex(cat.color); |
61 annotCat.colors[cat.code] = annotviz.colorToHex(cat.color); |
67 }); |
62 }); |
68 annotCat.defaultColor = categoriesJson.defaultColor || "#536991"; |
63 annotCat.defaultColor = categoriesJson.defaultColor || "#536991"; |
69 annotCategories.push(annotCat); |
64 annotCategories.push(annotCat); |
70 }); |
65 }); |
71 console.log(JSON.stringify(annotCategories, null, ' ')); |
66 console.log(JSON.stringify(annotCategories, null, ' ')); |