Results site in .NET Core

This commit is contained in:
Elton Stoneman
2018-09-26 10:29:39 +01:00
parent 879e5bc477
commit 985af62bb1
14 changed files with 165 additions and 42 deletions

View File

@ -95,12 +95,12 @@ body {
text-transform: uppercase;
}
#choice .choice.dogs {
#choice .choice.resultb {
color: #00cbca;
float: right;
}
#choice .choice.cats {
#choice .choice.resulta {
color: #2196f3;
float: left;
}

View File

@ -3,14 +3,23 @@
var connection = new signalR.HubConnectionBuilder().withUrl("/resultsHub").build();
connection.on("UpdateResults", function (results) {
data = JSON.parse(json);
document.body.style.opacity=1;
var a = parseInt(data.optionA || 0);
var b = parseInt(data.optionB || 0);
var a = parseInt(results.optionA || 0);
var b = parseInt(results.optionB || 0);
var percentages = getPercentages(a, b);
document.getElementById("optionA").innerText = percentages.a + "%";
document.getElementById("optionB").innerText = percentages.b + "%";
if (results.voteCount > 0) {
var totalVotes = results.voteCount + (results.voteCount > 1 ? " votes" : " vote");
document.getElementById("totalVotes").innerText = totalVotes;
}
var bg1 = document.getElementById('background-stats-1');
var bg2 = document.getElementById('background-stats-2');
bg1.style.width = percentages.a + "%";
bg2.style.width = percentages.b + "%";
});
connection.start().catch(function (err) {

View File

@ -1,4 +0,0 @@
// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification
// for details on configuring this project to bundle and minify static web assets.
// Write your Javascript code.