client/annotviz/app/js/main.js
changeset 99 9d968fbcaa2a
parent 92 a323578ea954
child 100 0d7dac03c1a0
--- a/client/annotviz/app/js/main.js	Mon Jan 19 09:52:52 2015 +0100
+++ b/client/annotviz/app/js/main.js	Tue Jan 20 12:00:40 2015 +0100
@@ -9,6 +9,7 @@
 
 
 var PIXI = require('pixi');
+var rgb2hex = require('./utils');
 
 // Config vars
 var horizontalView = false;
@@ -42,6 +43,19 @@
 // Timecode method
 var timePageLoaded = Date.now();
 var offsetMusic = false;
+var categoriesColor = {		
+	"ntm" : rgb2hex(205,200,63),
+    "iam" : rgb2hex(205,200,63),
+    "hip" : rgb2hex(205,200,63),
+    "hop" : rgb2hex(205,200,63),
+    "rock" : rgb2hex(222,139,83),
+    "rap" : rgb2hex(222,139,83),
+    "classic" : rgb2hex(222,139,83),
+    "drums" : rgb2hex(197,163,202),
+    "guitar" : rgb2hex(197,163,202),
+    "bass" : rgb2hex(121,187,146),
+    "default": rgb2hex(128,128,128)
+};
 
 //create an new instance of a pixi stage
 var stage = new PIXI.Stage(sceneBgColor);
@@ -146,17 +160,23 @@
 
 var GeneralView = require('./generalView.js')
 
-var GeneralRoll = new GeneralView(uberContainer, 0, 0, sceneWidth - (prSize2 + prSize3), sceneHeight, Date.now(), Date.now() + 300000, 30);
+var GeneralRoll = new GeneralView(uberContainer, 0, 0, sceneWidth - (prSize2 + prSize3), sceneHeight, Date.now(), Date.now() + 300000, 30, 5, 100, categoriesColor);
 
 
 function addAnnots(data){
     var title = data.content.category.label;
+    var code = data.content.category.code;
     var user = data.content.user;
-    //Test cat and color
-    var colorAnnot = 0x65A954;
+    if (typeof(categoriesColor[code]) != 'undefined'){
+    	var color = categoriesColor[code];
+    }
+    else {
+    	var code = "default";
+    	var color = categoriesColor[code];
+    }
     
-    AnnotationRoll.addAnnot(title, user, colorAnnot);
-    GeneralRoll.addAnnot(title, Date.now());
+    AnnotationRoll.addAnnot(title, user, color);
+    GeneralRoll.addAnnot(code, Date.now());
 }
 
 /* ---------------------------------------------------------------- */
@@ -244,7 +264,7 @@
             if(logger){
                 log('Got message: ' + e.data);
             }
-            console.log(e);
+//            console.log(e);
             addAnnots(JSON.parse(e.data));
         };
     }