|
@@ -3,6 +3,17 @@ const TESTS_LIST = ['Charles', 'Baruch','Frédéric', 'John', 'Dan', |
|
|
'Albert', 'Beth', 'Erykah', 'Aretha', 'Lucio', |
|
|
'Albert', 'Beth', 'Erykah', 'Aretha', 'Lucio', |
|
|
'Bartleby','Zach','Patti','Aesop','Vernon'] |
|
|
'Bartleby','Zach','Patti','Aesop','Vernon'] |
|
|
|
|
|
|
|
|
|
|
|
const NOBODY = '***NOBODY'; |
|
|
|
|
|
|
|
|
|
|
|
function groupSizeChanged(val){ |
|
|
|
|
|
let nbParticipants = document.getElementsByClassName('participant').length; |
|
|
|
|
|
let meetsPerRound = val - 1; |
|
|
|
|
|
let maxRounds = Math.floor(nbParticipants / meetsPerRound); |
|
|
|
|
|
|
|
|
|
|
|
document.getElementById('nbRounds').max = maxRounds |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var participants; |
|
|
var participants; |
|
|
|
|
|
|
|
|
function loadParticipantsFileChooser(){ |
|
|
function loadParticipantsFileChooser(){ |
|
@@ -39,20 +50,30 @@ function addParticipant(name){ |
|
|
newInput.value = name; |
|
|
newInput.value = name; |
|
|
document.getElementById('participants').appendChild(newInput) |
|
|
document.getElementById('participants').appendChild(newInput) |
|
|
|
|
|
|
|
|
|
|
|
//outch... |
|
|
|
|
|
document.getElementById('nbPerGroup').disabled = false; |
|
|
|
|
|
document.getElementById('nbRounds').disabled = false; |
|
|
|
|
|
document.getElementById('btn-do-it').disabled = false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function russellize(){ |
|
|
function russellize(){ |
|
|
let availablesPerParticipants = new Map() |
|
|
|
|
|
|
|
|
|
|
|
participants.forEach(function (p) { |
|
|
|
|
|
availablesPerParticipants.set(p,participants.slice().filter(el => el !== p)) |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
let k = document.getElementById('nbPerGroup').value |
|
|
let k = document.getElementById('nbPerGroup').value |
|
|
let nbRounds = document.getElementById('nbRounds').value |
|
|
let nbRounds = document.getElementById('nbRounds').value |
|
|
let nbGroups = Math.ceil(participants.length / k) |
|
|
let nbGroups = Math.ceil(participants.length / k) |
|
|
let rounds = new Array() |
|
|
let rounds = new Array() |
|
|
|
|
|
|
|
|
|
|
|
let missingParticipants = nbGroups * k - participants.length |
|
|
|
|
|
for(let n = 0; n < missingParticipants; n++) |
|
|
|
|
|
participants.push(NOBODY + n); |
|
|
|
|
|
|
|
|
|
|
|
let availablesPerParticipants = new Map() |
|
|
|
|
|
|
|
|
|
|
|
participants.forEach(function (p) { |
|
|
|
|
|
availablesPerParticipants.set(p,participants.slice().filter(el => el !== p)) |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
for(let i = 1; i <= nbRounds; i++){ |
|
|
for(let i = 1; i <= nbRounds; i++){ |
|
|
let round = new Array() |
|
|
let round = new Array() |
|
|
let availables = participants.slice() |
|
|
let availables = participants.slice() |
|
@@ -163,8 +184,12 @@ function renderRounds(rounds){ |
|
|
groupBlock.appendChild(list) |
|
|
groupBlock.appendChild(list) |
|
|
groupBlock.classList.add('group') |
|
|
groupBlock.classList.add('group') |
|
|
group.forEach(function (p) { |
|
|
group.forEach(function (p) { |
|
|
|
|
|
let emptySlot = p.indexOf(NOBODY) >= 0 |
|
|
let item = document.createElement('li') |
|
|
let item = document.createElement('li') |
|
|
item.appendChild(document.createTextNode(p)) |
|
|
|
|
|
|
|
|
if(emptySlot) |
|
|
|
|
|
item.classList='empty-slot' |
|
|
|
|
|
let pTxt = emptySlot ? '' : p; |
|
|
|
|
|
item.appendChild(document.createTextNode(pTxt)) |
|
|
list.appendChild(item) |
|
|
list.appendChild(item) |
|
|
}) |
|
|
}) |
|
|
y ++ |
|
|
y ++ |
|
|