Commit 8199748c authored by Leon Byford's avatar Leon Byford

Doodle

parent bff93966
......@@ -9,6 +9,8 @@
/feed /feed.xml
/tag/* /tag#:splat
/api https://doodle.com/api/v2.0/polls/hzfpb28qf59e7gfb 200
# SHORTCUTS
/deploys https://app.netlify.com/sites/ldjb-blog/deploys
/netloan http://netloan.bexley.gov.uk/netloan #vm-netloan01.bexley.gov.uk/10.216.2.17
---
layout: page
title: Doodle poll results
---
### Social watching: Q3 2018 anime
<p><a href="https://doodle.com/poll/hzfpb28qf59e7gfb">Vote on Doodle</a></p>
<table id="results" border="1" style="width: 100%; border: 1px;"></table>
<p id="updated"></p>
<script src="/lib/doodle.js"></script>
<style>
td.title {
width: 50%;
}
@media screen and (min-width: 640px) {
td.title {
width: 0;
white-space: nowrap;
}
}
td {
border: 1px solid black;
}
</style>
\ No newline at end of file
if (location.hash == "#hzfpb28qf59e7gfb") {
fetch("api").then(
d => d.json().then(
j => {
populateResults(j);}));
}
else {
document.write("hash not provided");
}
function populateResults(data) {
updated.innerHTML = "Updated: " + new Date(data.latestChange);
let arrResults = [];
for (let option in data.options) {
let votes = 0;
for (let participant in data.participants) {
votes += data.participants[participant].preferences[option];
}
arrResults.push([votes, '<tr><td class="title">'
+ data.options[option].text
+ '</td><td title="'
+ (votes / data.participantsCount * 100).toFixed(1)
+ '%"><div style="width: '
+ votes / data.participantsCount * 100
+ '%; background: #66f; color: '
+ (votes > 0 ? "#fff" : "#000")
+ '; text-align: center;">'
+ votes
+ '</div></td></tr>']);
}
arrResults.sort((a,b) => b[0]-a[0]);
arrResults.forEach(result => {
results.innerHTML += result[1];
});
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment