client/annotviz/app/annotsvizview.html
changeset 119 e6605fecb175
parent 117 c0034b35c44e
child 122 3b11017a76a4
--- a/client/annotviz/app/annotsvizview.html	Thu Jan 22 11:18:58 2015 +0100
+++ b/client/annotviz/app/annotsvizview.html	Thu Jan 22 12:12:33 2015 +0100
@@ -25,17 +25,6 @@
         var PIXI = require('pixi');
         var annotCategories = [];
 
-        function colorToHex(input) {
-            if (input.substring(0, 1) === '#') {
-                return input;
-            }
-            else {
-                var m = input.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i);
-                var r = m[1], g=[2], b=[3];
-                return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
-            }
-        }
-
         function getAnnotCategories(ecode, serverUrl) {
 
             var url = serverUrl+"/p/api/v1/event/" + ecode;
@@ -56,7 +45,7 @@
                     var categoriesJson = session.categories_json;
                     annotCat.order = categoriesJson.order;
                     categoriesJson.categories.forEach(function(cat) {
-                        annotCat.colors[cat.code] = colorToHex(cat.color);
+                        annotCat.colors[cat.code] = annotviz.colorToHex(cat.color);
                     });
                     annotCat.defaultColor = categoriesJson.defaultColor || "#536991";
                     annotCategories.push(annotCat);