File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -96,11 +96,22 @@ function getCityColor(team) {
9696 'Köln' : '#6b5aac'
9797 } ;
9898
99- return colorlist [ team . event . city ] ? colorlist [ team . event . city ] : randomColor ( ) ;
99+ return colorlist [ team . event . city ] ? colorlist [ team . event . city ] : stringColor ( team . event . city ) ;
100100}
101101
102- function randomColor ( ) {
103- return '#' + Math . floor ( Math . random ( ) * 16777215 ) . toString ( 16 ) ;
102+ function stringColor ( string ) {
103+ var hash = 0 ;
104+ if ( string . length === 0 ) return hash ;
105+ for ( var i = 0 ; i < string . length ; i ++ ) {
106+ hash = string . charCodeAt ( i ) + ( ( hash << 5 ) - hash ) ;
107+ hash = hash & hash ;
108+ }
109+ var color = '#' ;
110+ for ( var j = 0 ; j < 3 ; j ++ ) {
111+ var value = ( hash >> ( j * 8 ) ) & 255 ;
112+ color += ( '00' + value . toString ( 16 ) ) . substr ( - 2 ) ;
113+ }
114+ return color ;
104115}
105116
106117function colorGradientByWeight ( color1 , color2 , weight ) {
You can’t perform that action at this time.
0 commit comments