diff -r 89544c28a364 -r df6b39f962bc client/annotviz/app/js/utils.js --- a/client/annotviz/app/js/utils.js Thu Jan 22 15:02:54 2015 +0100 +++ b/client/annotviz/app/js/utils.js Thu Jan 22 15:03:58 2015 +0100 @@ -14,7 +14,39 @@ return ((hours < 10 ? '0' + hours : hours) + ':' + (minutes < 10 ? '0' + minutes : minutes) + ':' + (seconds < 10 ? '0' + seconds : seconds)); } +function getAnnotCategories(urlCategories, annotCategories) { + + var jsonLoader = new PIXI.JsonLoader(urlCategories, true); + + jsonLoader.on('loaded', function(res) { + var data = res.target.json; + + while(annotCategories.length > 0) { + annotCategories.pop(); + } + + data.sessions.forEach(function(session) { + var annotCat = { + ts: session.start_ts === null ? new Date(0) : Date.parse(session.start_ts), + colors: {} + } + var categoriesJson = session.categories_json; + annotCat.order = categoriesJson.order; + categoriesJson.categories.forEach(function(cat) { + annotCat.colors[cat.code] = colorToHex(cat.color); + }); + annotCat.defaultColor = categoriesJson.defaultColor || "#536991"; + annotCategories.push(annotCat); + }); + console.log(annotCategories); + annotCategories[0].order.push("default"); + }); + + jsonLoader.load(); + +} module.exports = { - formatTime: formatTime + formatTime: formatTime, + getAnnotCategories: getAnnotCategories };