@@ -12,7 +12,12 @@ $(document).ready(function() {
1212
1313 $ . get ( '/reset-glyph-stats/' + unicode_value , function ( data ) {
1414 getData ( ) ;
15- } ) ;
15+ } ) ;
16+ } ) ;
17+
18+ $ ( window ) . resize ( function ( ) {
19+ $ ( "#glyph_rows" ) . empty ( )
20+ renderGlyphScoreRows ( ) ;
1621} ) ;
1722
1823function like_comparison ( a , b ) {
@@ -66,39 +71,7 @@ function getData() {
6671 $ ( "#glyph_rows" ) . hide ( ) ;
6772 }
6873
69- emoji_array . sort ( glyph_score_comparison ) ;
70-
71- for ( i in emoji_array ) {
72- var emoji = emoji_array [ i ] ;
73-
74- var glyph_bar = $ ( "<div>" ) ;
75- glyph_bar . addClass ( "crisp" ) ;
76- glyph_bar . css ( "width" , Math . abs ( emoji . glyph_score ) * 2 ) ;
77- glyph_bar . css ( "height" , 36 ) ;
78- glyph_bar . css ( "background-image" , 'url(' + image_prefix + emoji . unicode_value + "_" + emoji . vendor_name + ".png)" ) ;
79- glyph_bar . css ( "background-repeat" , "repeat-x" ) ;
80- glyph_bar . css ( "background-size" , "36px 36px" ) ;
81-
82- var glyph_row = $ ( "<tr>" ) ;
83- glyph_row . addClass ( "glyph_row" ) ;
84-
85- var negative_column = $ ( "<td>" ) ;
86- if ( emoji . glyph_score < 0 ) {
87- glyph_bar . addClass ( "negative_bar" ) ;
88- negative_column . append ( glyph_bar ) ;
89- }
90- glyph_row . append ( negative_column ) ;
91-
92- glyph_row . append ( $ ( "<td style=\"text-align: center;\">" ) . text ( emoji . vendor_name ) ) ;
93-
94- var positive_column = $ ( "<td>" ) ;
95- if ( emoji . glyph_score > 0 ) {
96- positive_column . append ( glyph_bar ) ;
97- }
98- glyph_row . append ( positive_column ) ;
99-
100- $ ( "#glyph_rows" ) . append ( glyph_row ) ;
101- }
74+ renderGlyphScoreRows ( ) ;
10275
10376 return ;
10477
@@ -124,4 +97,48 @@ function getData() {
12497 $ ( "#table_by_hate" ) . append ( tr ) ;
12598 }
12699 } ) ;
100+ }
101+
102+ function renderGlyphScoreRows ( ) {
103+ emoji_array . sort ( glyph_score_comparison ) ;
104+
105+ var barWidth = ( $ ( "#glyph_rows" ) . width ( ) / 2 ) - 40 ;
106+
107+ var header = $ ( "<tr><th>Negative</th><th>Vendor</th><th>Positive</th></tr>" ) ;
108+
109+ $ ( "#glyph_rows" ) . append ( header ) ;
110+
111+ for ( i in emoji_array ) {
112+ var emoji = emoji_array [ i ] ;
113+ console . log ( emoji . vendor_name + " " + emoji . glyph_score ) ;
114+
115+
116+ var glyph_bar = $ ( "<div>" ) ;
117+ glyph_bar . addClass ( "crisp" ) ;
118+ glyph_bar . css ( "width" , Math . abs ( emoji . glyph_score ) * barWidth / 100 ) ;
119+ glyph_bar . css ( "height" , 36 ) ;
120+ glyph_bar . css ( "background-image" , 'url(' + image_prefix + emoji . unicode_value + "_" + emoji . vendor_name + ".png)" ) ;
121+ glyph_bar . css ( "background-repeat" , "repeat-x" ) ;
122+ glyph_bar . css ( "background-size" , "36px 36px" ) ;
123+
124+ var glyph_row = $ ( "<tr>" ) ;
125+ glyph_row . addClass ( "glyph_row" ) ;
126+
127+ var negative_column = $ ( "<td>" ) ;
128+ if ( emoji . glyph_score < 0 ) {
129+ glyph_bar . addClass ( "negative_bar" ) ;
130+ negative_column . append ( glyph_bar ) ;
131+ }
132+ glyph_row . append ( negative_column ) ;
133+
134+ glyph_row . append ( $ ( "<td style=\"text-align: center;\">" ) . text ( emoji . vendor_name ) ) ;
135+
136+ var positive_column = $ ( "<td>" ) ;
137+ if ( emoji . glyph_score > 0 ) {
138+ positive_column . append ( glyph_bar ) ;
139+ }
140+ glyph_row . append ( positive_column ) ;
141+
142+ $ ( "#glyph_rows" ) . append ( glyph_row ) ;
143+ }
127144}
0 commit comments