Created
December 19, 2017 14:51
-
-
Save florianboudot/25e1c8d2e4d326810190b4c188eb48af to your computer and use it in GitHub Desktop.
team sorter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const body = document.querySelector('body') | |
const bodyStyles = 'height: 100vh; display:flex; justify-content:center; font-size:40px; align-items:center' | |
const teamAStyles = 'color:indianred; width:200px; list-style:none' | |
const teamBStyles = 'color:royalblue; width:200px; list-style:none' | |
body.innerHTML = ` | |
<div style="${bodyStyles}"> | |
<ul style="${teamAStyles}">loading</ul> | |
<ul style="${teamBStyles}">loading</ul> | |
</div>` | |
const names = ['π Flo', 'π Nico', 'π€£ B.Lucet', 'π B.Vidal', 'π€ Claire', 'π Ludo', 'π€ Caro', 'π LΓ©o'] | |
const team1 = [] | |
let n | |
let INTERVAL = null | |
INTERVAL = setInterval(function () { | |
if (team1.length < names.length) { | |
n = Math.floor(Math.random() * names.length) | |
team1.push(names[n]) | |
names.splice(n, 1) | |
body.innerHTML = ` | |
<div style="${bodyStyles}"> | |
<ul style="${teamAStyles}"><li>${team1.join('</li><li>')}</li></ul> | |
<ul style="${teamBStyles}">loading</ul> | |
</div> | |
` | |
} else { | |
clearInterval(INTERVAL) | |
body.innerHTML = ` | |
<div style="${bodyStyles}"> | |
<ul style="${teamAStyles}"><li>${team1.join('</li><li>')}</li></ul> | |
<ul style="${teamBStyles}"><li>${names.join('</li><li>')}</li></ul> | |
</div> | |
` | |
} | |
}, 5000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment