Skip to content

Commit

Permalink
v1 version of results page + footer
Browse files Browse the repository at this point in the history
  • Loading branch information
benparsons committed Mar 17, 2017
1 parent c1305aa commit ff75f5d
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 43 deletions.
1 change: 1 addition & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function initialiseGlyphs() {
most_hated = {};

$.get("/get-emoji/" + window.location.pathname.split('/')[2], function(data) {
$(".results_link").attr("href", "/results/" + data[0].unicode_value);
$("#emoji_name").html(data[0].emoji_name);
document.title = "EmojiRank: " + data[0].emoji_name;
data = shuffle(data);
Expand Down
7 changes: 0 additions & 7 deletions results.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,6 @@ <h1 id="emoji_name"></h1>
There are no votes for this emoji yet, why don't you <a class="vote_link" href="/">cast the first vote</a>?
</div>
<table id="glyph_rows">
<tr>
<th>Negative</th>
<th>Vendor</th>
<th>Positive</th>
</tr>
</table>
<div style="display: none;">
<table id="table_by_like">
Expand All @@ -48,9 +43,7 @@ <h1 id="emoji_name"></h1>
</div>
</main>
<footer>
<div id="option"><a href="http://www.facebook.com/emojirank">Feedback</a></div>
<div id="option"><a class="vote_link" href="/">Vote</a></div>
<div id="option"><a href="/next">Next</a></div>
<div id="footer_text"><div class="addthis_inline_share_toolbox"></div></div>
</footer>
<script type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-58a70a324daea26b"></script>
Expand Down
85 changes: 51 additions & 34 deletions results.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ $(document).ready(function() {

$.get('/reset-glyph-stats/' + unicode_value, function(data) {
getData();
});
});
});

$( window ).resize(function() {
$("#glyph_rows").empty()
renderGlyphScoreRows();
});

function like_comparison(a, b) {
Expand Down Expand Up @@ -66,39 +71,7 @@ function getData() {
$("#glyph_rows").hide();
}

emoji_array.sort(glyph_score_comparison);

for (i in emoji_array) {
var emoji = emoji_array[i];

var glyph_bar = $("<div>");
glyph_bar.addClass("crisp");
glyph_bar.css("width", Math.abs(emoji.glyph_score) * 2);
glyph_bar.css("height", 36);
glyph_bar.css("background-image", 'url(' + image_prefix + emoji.unicode_value + "_" + emoji.vendor_name + ".png)");
glyph_bar.css("background-repeat", "repeat-x");
glyph_bar.css("background-size", "36px 36px");

var glyph_row = $("<tr>");
glyph_row.addClass("glyph_row");

var negative_column = $("<td>");
if (emoji.glyph_score < 0) {
glyph_bar.addClass("negative_bar");
negative_column.append(glyph_bar);
}
glyph_row.append(negative_column);

glyph_row.append($("<td style=\"text-align: center;\">").text(emoji.vendor_name));

var positive_column = $("<td>");
if (emoji.glyph_score > 0) {
positive_column.append(glyph_bar);
}
glyph_row.append(positive_column);

$("#glyph_rows").append(glyph_row);
}
renderGlyphScoreRows();

return;

Expand All @@ -124,4 +97,48 @@ function getData() {
$("#table_by_hate").append(tr);
}
});
}

function renderGlyphScoreRows() {
emoji_array.sort(glyph_score_comparison);

var barWidth = ($("#glyph_rows").width() / 2) - 40;

var header = $("<tr><th>Negative</th><th>Vendor</th><th>Positive</th></tr>");

$("#glyph_rows").append(header);

for (i in emoji_array) {
var emoji = emoji_array[i];
console.log(emoji.vendor_name + " " + emoji.glyph_score);


var glyph_bar = $("<div>");
glyph_bar.addClass("crisp");
glyph_bar.css("width", Math.abs(emoji.glyph_score) * barWidth/100);
glyph_bar.css("height", 36);
glyph_bar.css("background-image", 'url(' + image_prefix + emoji.unicode_value + "_" + emoji.vendor_name + ".png)");
glyph_bar.css("background-repeat", "repeat-x");
glyph_bar.css("background-size", "36px 36px");

var glyph_row = $("<tr>");
glyph_row.addClass("glyph_row");

var negative_column = $("<td>");
if (emoji.glyph_score < 0) {
glyph_bar.addClass("negative_bar");
negative_column.append(glyph_bar);
}
glyph_row.append(negative_column);

glyph_row.append($("<td style=\"text-align: center;\">").text(emoji.vendor_name));

var positive_column = $("<td>");
if (emoji.glyph_score > 0) {
positive_column.append(glyph_bar);
}
glyph_row.append(positive_column);

$("#glyph_rows").append(glyph_row);
}
}
1 change: 1 addition & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ table#glyph_rows {
margin: auto;
padding: 20px;
padding-bottom: 50px;
width: 100%;
}

.glyph_row {
Expand Down
3 changes: 1 addition & 2 deletions vote.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ <h3>World rankings</h3>
</div>
</main>
<footer>
<div id="option"><a href="http://www.facebook.com/emojirank">Feedback</a></div>
<!--div id="option"><a href="/stats">Stats</a></div-->
<div id="option"><a class="results_link" href="/">Results</a></div>
<div id="option"><a href="/next">Next</a></div>
<div id="footer_text"><div class="addthis_inline_share_toolbox"></div></div>
</footer>
Expand Down

0 comments on commit ff75f5d

Please sign in to comment.