equal
deleted
inserted
replaced
23 <script> |
23 <script> |
24 |
24 |
25 var PIXI = require('pixi'); |
25 var PIXI = require('pixi'); |
26 var annotCategories = []; |
26 var annotCategories = []; |
27 |
27 |
28 function colorToHex(input) { |
|
29 if (input.substring(0, 1) === '#') { |
|
30 return input; |
|
31 } |
|
32 else { |
|
33 var m = input.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i); |
|
34 var r = m[1], g=[2], b=[3]; |
|
35 return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); |
|
36 } |
|
37 } |
|
38 |
|
39 function getAnnotCategories(ecode, serverUrl) { |
28 function getAnnotCategories(ecode, serverUrl) { |
40 |
29 |
41 var url = serverUrl+"/p/api/v1/event/" + ecode; |
30 var url = serverUrl+"/p/api/v1/event/" + ecode; |
42 |
31 |
43 var jsonLoader = new PIXI.JsonLoader(url, true); |
32 var jsonLoader = new PIXI.JsonLoader(url, true); |
54 colors: {} |
43 colors: {} |
55 } |
44 } |
56 var categoriesJson = session.categories_json; |
45 var categoriesJson = session.categories_json; |
57 annotCat.order = categoriesJson.order; |
46 annotCat.order = categoriesJson.order; |
58 categoriesJson.categories.forEach(function(cat) { |
47 categoriesJson.categories.forEach(function(cat) { |
59 annotCat.colors[cat.code] = colorToHex(cat.color); |
48 annotCat.colors[cat.code] = annotviz.colorToHex(cat.color); |
60 }); |
49 }); |
61 annotCat.defaultColor = categoriesJson.defaultColor || "#536991"; |
50 annotCat.defaultColor = categoriesJson.defaultColor || "#536991"; |
62 annotCategories.push(annotCat); |
51 annotCategories.push(annotCat); |
63 }); |
52 }); |
64 console.log(annotCategories); |
53 console.log(annotCategories); |