Remove debug statements
This commit is contained in:
parent
4d5e98f403
commit
734cab1711
12
index.html
12
index.html
@ -72,7 +72,6 @@
|
|||||||
|
|
||||||
function vote(idx) {
|
function vote(idx) {
|
||||||
voted = true;
|
voted = true;
|
||||||
console.log(`voting ${idx}`);
|
|
||||||
socket.emit('vote', idx);
|
socket.emit('vote', idx);
|
||||||
choice_buttons.className = 'voted';
|
choice_buttons.className = 'voted';
|
||||||
}
|
}
|
||||||
@ -82,7 +81,7 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
socket.on('choices', (new_choices, new_question) => {
|
socket.on('choices', (new_choices, new_question) => {
|
||||||
console.log(`new question ${new_question}: ${new_choices}`);
|
console.log(`Received new question ${new_question}: ${new_choices}`);
|
||||||
|
|
||||||
choices = new_choices;
|
choices = new_choices;
|
||||||
voted = false;
|
voted = false;
|
||||||
@ -108,16 +107,14 @@
|
|||||||
|
|
||||||
socket.on('results', (results) => {
|
socket.on('results', (results) => {
|
||||||
|
|
||||||
console.log(`results: ${results}`);
|
console.log(`Received results: ${results}`);
|
||||||
|
|
||||||
const sum = results.reduce((a,b) => a+b);
|
const sum = results.reduce((a,b) => a+b);
|
||||||
console.log(`sum is ${sum}`);
|
|
||||||
const max = Math.max(...results);
|
const max = Math.max(...results);
|
||||||
results.map((score, idx) => {
|
results.map((score, idx) => {
|
||||||
|
|
||||||
const li = choice_buttons.children[idx];
|
const li = choice_buttons.children[idx];
|
||||||
const width = Math.round(100 * score / sum);
|
const width = Math.round(100 * score / sum);
|
||||||
console.log(`set ${idx} to ${width}`);
|
|
||||||
li.style.width = `${width}%`;
|
li.style.width = `${width}%`;
|
||||||
li.textContent = `${choices[idx]} : ${score}`;
|
li.textContent = `${choices[idx]} : ${score}`;
|
||||||
if (score === max) {
|
if (score === max) {
|
||||||
@ -125,12 +122,9 @@
|
|||||||
} else {
|
} else {
|
||||||
li.classList.remove('winner');
|
li.classList.remove('winner');
|
||||||
}
|
}
|
||||||
|
|
||||||
//bar.setAttribute("max", sum);
|
|
||||||
//bar.setAttribute("value", score);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
2
index.js
2
index.js
@ -1,3 +1,5 @@
|
|||||||
|
// Liliquiz v0.1 (c) Maxime Augier <max@xolus.net>
|
||||||
|
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import { createServer } from 'node:http';
|
import { createServer } from 'node:http';
|
||||||
import { fileURLToPath } from 'node:url';
|
import { fileURLToPath } from 'node:url';
|
||||||
|
Loading…
Reference in New Issue
Block a user