Skip to content

Commit

Permalink
feat(jury-tool): show vote results
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin-Frost committed May 25, 2024
1 parent 5e1ab84 commit 04df116
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions jury/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}

#events > div {
min-height: 200px;
min-height: 350px;
}

div {
Expand All @@ -32,12 +32,17 @@
margin-top: 0;
}

h4 {
margin-bottom: 0.5rem;
}

pre {
background-color: #f9f9f9;
border: 1px solid #ccc;
border-radius: 5px;
padding: 1rem;
margin: 0;
margin-bottom: 1rem;
}

#urlInputContainer {
Expand Down Expand Up @@ -74,7 +79,7 @@ <h1>Jury Tool</h1>

let backendUrl = '';

// Create html elements for each event
// Create HTML elements for each event
events.forEach((event) => {
const div = document.createElement('div');
div.id = event;
Expand All @@ -84,10 +89,23 @@ <h1>Jury Tool</h1>
h3.textContent = event;
document.getElementById(event).appendChild(h3);

const pre = document.createElement('pre');
pre.id = event + '-data';
pre.textContent = 'Enter a backend URL to start';
document.getElementById(event).appendChild(pre);
const h4Subscribe = document.createElement('h4');
h4Subscribe.textContent = 'Current Action';
document.getElementById(event).appendChild(h4Subscribe);

const preSubscribe = document.createElement('pre');
preSubscribe.id = event + '-data';
preSubscribe.textContent = 'Enter a backend URL to start';
document.getElementById(event).appendChild(preSubscribe);

const h4Vote = document.createElement('h4');
h4Vote.textContent = 'Votes';
document.getElementById(event).appendChild(h4Vote);

const preVote = document.createElement('pre');
preVote.id = event + '-vote';
preVote.textContent = 'Enter a backend URL to start';
document.getElementById(event).appendChild(preVote);
});

document.getElementById('setUrlButton').addEventListener('click', () => {
Expand All @@ -101,6 +119,7 @@ <h1>Jury Tool</h1>
// Update text to "Loading..." once fetching starts
events.forEach((event) => {
document.getElementById(event + '-data').textContent = 'Loading...';
document.getElementById(event + '-vote').textContent = 'Loading...';
});

// Update data for each event, every second
Expand All @@ -112,6 +131,13 @@ <h1>Jury Tool</h1>
document.getElementById(event + '-data').textContent =
JSON.stringify(data, null, 2);
});

fetch(`${backendUrl}/events/${event}/vote/results`)
.then((response) => response.json())
.then((data) => {
document.getElementById(event + '-vote').textContent =
JSON.stringify(data, null, 2);
});
});
}, 1000);
}
Expand Down

0 comments on commit 04df116

Please sign in to comment.