Skip to content

Commit ff75f5d

Browse files
committed
v1 version of results page + footer
1 parent c1305aa commit ff75f5d

File tree

5 files changed

+54
-43
lines changed

5 files changed

+54
-43
lines changed

main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ function initialiseGlyphs() {
3535
most_hated = {};
3636

3737
$.get("/get-emoji/" + window.location.pathname.split('/')[2], function(data) {
38+
$(".results_link").attr("href", "/results/" + data[0].unicode_value);
3839
$("#emoji_name").html(data[0].emoji_name);
3940
document.title = "EmojiRank: " + data[0].emoji_name;
4041
data = shuffle(data);

results.html

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ <h1 id="emoji_name"></h1>
2828
There are no votes for this emoji yet, why don't you <a class="vote_link" href="/">cast the first vote</a>?
2929
</div>
3030
<table id="glyph_rows">
31-
<tr>
32-
<th>Negative</th>
33-
<th>Vendor</th>
34-
<th>Positive</th>
35-
</tr>
3631
</table>
3732
<div style="display: none;">
3833
<table id="table_by_like">
@@ -48,9 +43,7 @@ <h1 id="emoji_name"></h1>
4843
</div>
4944
</main>
5045
<footer>
51-
<div id="option"><a href="http://www.facebook.com/emojirank">Feedback</a></div>
5246
<div id="option"><a class="vote_link" href="/">Vote</a></div>
53-
<div id="option"><a href="/next">Next</a></div>
5447
<div id="footer_text"><div class="addthis_inline_share_toolbox"></div></div>
5548
</footer>
5649
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-58a70a324daea26b"></script>

results.js

Lines changed: 51 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -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

1823
function 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
}

style.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ table#glyph_rows {
125125
margin: auto;
126126
padding: 20px;
127127
padding-bottom: 50px;
128+
width: 100%;
128129
}
129130

130131
.glyph_row {

vote.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ <h3>World rankings</h3>
3737
</div>
3838
</main>
3939
<footer>
40-
<div id="option"><a href="http://www.facebook.com/emojirank">Feedback</a></div>
41-
<!--div id="option"><a href="/stats">Stats</a></div-->
40+
<div id="option"><a class="results_link" href="/">Results</a></div>
4241
<div id="option"><a href="/next">Next</a></div>
4342
<div id="footer_text"><div class="addthis_inline_share_toolbox"></div></div>
4443
</footer>

0 commit comments

Comments
 (0)