diff -r 082b64a5c699 -r 8546e2181a73 annot-server/static/js/app.js --- a/annot-server/static/js/app.js Thu Jan 22 07:04:42 2015 +0100 +++ b/annot-server/static/js/app.js Thu Jan 22 08:07:09 2015 +0100 @@ -35,14 +35,9 @@ ); } - function parseColor(input) { - var m = input.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i); - if( m) return [m[1],m[2],m[3]]; - else throw new Error("Colour "+input+" could not be parsed."); - } - - function rgbToHex(r, g, b) { - return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); + function colorToHex(c) { + var m = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/.exec(c); + return m ? '#' + (1 << 24 | m[1] << 16 | m[2] << 8 | m[3]).toString(16).substr(1) : c; } $scope.data = dataModel.data; @@ -210,8 +205,7 @@ var hexc; if(color.substring(0, 4) === 'rgb(') { - var rgbc = parseColor(color); - hexc = rgbToHex(rgbc[0],rgbc[1], rgbc[2]); + hexc = colorToHex(color); } else { hexc = color; @@ -225,7 +219,7 @@ user : $scope.username }; sock.send(JSON.stringify(new_annot)); - if(context.logging===true){ + if(context.logging===true){ log('Sent: ' + JSON.stringify(new_annot)); } if(typeof c==='undefined'){