equal
deleted
inserted
replaced
33 return decodeURI( |
33 return decodeURI( |
34 (new RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1] |
34 (new RegExp(name + '=' + '(.+?)(&|$)').exec(location.search)||[,null])[1] |
35 ); |
35 ); |
36 } |
36 } |
37 |
37 |
38 function parseColor(input) { |
38 function colorToHex(c) { |
39 var m = input.match(/^rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)$/i); |
39 var m = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/.exec(c); |
40 if( m) return [m[1],m[2],m[3]]; |
40 return m ? '#' + (1 << 24 | m[1] << 16 | m[2] << 8 | m[3]).toString(16).substr(1) : c; |
41 else throw new Error("Colour "+input+" could not be parsed."); |
|
42 } |
|
43 |
|
44 function rgbToHex(r, g, b) { |
|
45 return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); |
|
46 } |
41 } |
47 |
42 |
48 $scope.data = dataModel.data; |
43 $scope.data = dataModel.data; |
49 |
44 |
50 var process_categories = function(data) { |
45 var process_categories = function(data) { |
208 code = window.S(label).slugify().s; |
203 code = window.S(label).slugify().s; |
209 } |
204 } |
210 |
205 |
211 var hexc; |
206 var hexc; |
212 if(color.substring(0, 4) === 'rgb(') { |
207 if(color.substring(0, 4) === 'rgb(') { |
213 var rgbc = parseColor(color); |
208 hexc = colorToHex(color); |
214 hexc = rgbToHex(rgbc[0],rgbc[1], rgbc[2]); |
|
215 } |
209 } |
216 else { |
210 else { |
217 hexc = color; |
211 hexc = color; |
218 } |
212 } |
219 |
213 |
223 text: freetext, |
217 text: freetext, |
224 color: hexc, |
218 color: hexc, |
225 user : $scope.username |
219 user : $scope.username |
226 }; |
220 }; |
227 sock.send(JSON.stringify(new_annot)); |
221 sock.send(JSON.stringify(new_annot)); |
228 if(context.logging===true){ |
222 if(context.logging===true){ |
229 log('Sent: ' + JSON.stringify(new_annot)); |
223 log('Sent: ' + JSON.stringify(new_annot)); |
230 } |
224 } |
231 if(typeof c==='undefined'){ |
225 if(typeof c==='undefined'){ |
232 $scope.annotPile.push(false); |
226 $scope.annotPile.push(false); |
233 } |
227 } |