|
|
|
@ -11,6 +11,12 @@ const UI = { |
|
|
|
|
ITEM: 'sort-item', |
|
|
|
|
TEXT: 'sort-text', |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
ROUND: { |
|
|
|
|
ITEM: 'round-item', |
|
|
|
|
HIDE: 'round-hide', |
|
|
|
|
TEXT: 'round-text', |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
DATA: { |
|
|
|
@ -20,6 +26,11 @@ const UI = { |
|
|
|
|
SORT: 'data-sort-key', |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
I18N: { |
|
|
|
|
HIDE: 'hide', |
|
|
|
|
SHOW: 'show', |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
findRoot: (node) => { |
|
|
|
|
while (node !== document.body && node.getAttribute(UI.DATA.ROOT) === null) { |
|
|
|
|
node = node.parentNode; |
|
|
|
@ -36,6 +47,23 @@ const UI = { |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
toggleRoundItem: (target) => { |
|
|
|
|
const hide = target.querySelector(`.${UI.CLASSNAMES.ROUND.HIDE}`); |
|
|
|
|
hide.innerHTML = (hide.innerHTML === UI.I18N.HIDE ? UI.I18N.SHOW : UI.I18N.HIDE); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
toggleRoundRibbons: (roundsToShow, ROUND_TYPES, allRounds) => { |
|
|
|
|
const ribbons = document.querySelectorAll('.ribbon'); |
|
|
|
|
ribbons.forEach(ribbon => { |
|
|
|
|
const name = allRounds[ribbon.getAttribute("data-round-id")]; |
|
|
|
|
const type = UI.getRoundType(name, ROUND_TYPES); |
|
|
|
|
|
|
|
|
|
roundsToShow.indexOf(type) === -1 |
|
|
|
|
? ribbon.style.display = 'none' |
|
|
|
|
: ribbon.style.display = 'inline'; |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
updateEventsPane: (eventKey) => { |
|
|
|
|
const eventItems = document.querySelectorAll(`.${UI.CLASSNAMES.EVENT.ITEM}`); |
|
|
|
|
UI.clearActive(eventItems); |
|
|
|
@ -140,7 +168,6 @@ const UI = { |
|
|
|
|
item.addEventListener('click', onClick); |
|
|
|
|
item.setAttribute(UI.DATA.SORT, sort.value); |
|
|
|
|
item.setAttribute(UI.DATA.ROOT, true); |
|
|
|
|
item.addEventListener('click', onClick); |
|
|
|
|
|
|
|
|
|
text.className = UI.CLASSNAMES.SORT.TEXT; |
|
|
|
|
text.innerHTML = sort.text; |
|
|
|
@ -150,33 +177,44 @@ const UI = { |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
buildRoundsPane: (onClick) => { |
|
|
|
|
// const roundsDiv = document.querySelector('.rounds');
|
|
|
|
|
//
|
|
|
|
|
// while (roundsDiv.hasChildNodes()) {
|
|
|
|
|
// roundsDiv.firstChild.remove();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// rounds.forEach(round => {
|
|
|
|
|
// const item = document.createElement('div');
|
|
|
|
|
// item.className = 'round-item';
|
|
|
|
|
// item.setAttribute('data-round-id', round.roundId);
|
|
|
|
|
//
|
|
|
|
|
// const hide = document.createElement('div');
|
|
|
|
|
// hide.className = 'round-hide';
|
|
|
|
|
// hide.innerHTML = 'hide';
|
|
|
|
|
//
|
|
|
|
|
// const text = document.createElement('div');
|
|
|
|
|
// text.className = 'round-text';
|
|
|
|
|
// text.innerHTML = round.roundName;
|
|
|
|
|
//
|
|
|
|
|
// item.appendChild(text);
|
|
|
|
|
// item.appendChild(hide);
|
|
|
|
|
// roundsDiv.appendChild(item);
|
|
|
|
|
// });
|
|
|
|
|
buildRoundsPane: (onClick, ROUND_TYPES) => { |
|
|
|
|
const roundsList = [ |
|
|
|
|
{ text: 'Preliminaries', value: ROUND_TYPES.PRELIM }, |
|
|
|
|
{ text: 'Round of 16', value: ROUND_TYPES.ROUNDOF16 }, |
|
|
|
|
{ text: 'Quarterfinals', value: ROUND_TYPES.QUARTERFINAL }, |
|
|
|
|
{ text: 'Semifinals', value: ROUND_TYPES.SEMIFINAL }, |
|
|
|
|
{ text: 'Consolation', value: ROUND_TYPES.CONSOLATION }, |
|
|
|
|
{ text: 'Final', value: ROUND_TYPES.FINAL }, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
const roundsDiv = document.querySelector('.rounds'); |
|
|
|
|
|
|
|
|
|
while (roundsDiv.hasChildNodes()) { |
|
|
|
|
roundsDiv.firstChild.remove(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
roundsList.forEach(round => { |
|
|
|
|
const item = document.createElement('div'); |
|
|
|
|
item.className = UI.CLASSNAMES.ROUND.ITEM; |
|
|
|
|
item.addEventListener('click', onClick); |
|
|
|
|
item.setAttribute(UI.DATA.ROUND, round.value); |
|
|
|
|
item.setAttribute(UI.DATA.ROOT, true); |
|
|
|
|
|
|
|
|
|
const hide = document.createElement('div'); |
|
|
|
|
hide.className = UI.CLASSNAMES.ROUND.HIDE; |
|
|
|
|
hide.innerHTML = 'hide'; |
|
|
|
|
|
|
|
|
|
const text = document.createElement('div'); |
|
|
|
|
text.className = UI.CLASSNAMES.ROUND.TEXT; |
|
|
|
|
text.innerHTML = round.text; |
|
|
|
|
|
|
|
|
|
item.appendChild(text); |
|
|
|
|
item.appendChild(hide); |
|
|
|
|
roundsDiv.appendChild(item); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
getRoundName: (name) => { |
|
|
|
|
getRoundType: (name, ROUND_TYPES) => { |
|
|
|
|
const name2 = name.match(/^Matchday/) ? 'First round' : name; |
|
|
|
|
|
|
|
|
|
switch (name2) { |
|
|
|
@ -187,27 +225,25 @@ const UI = { |
|
|
|
|
case 'Group-2 Play-off': |
|
|
|
|
case 'Group-3 Play-off': |
|
|
|
|
case 'Group-4 Play-off': |
|
|
|
|
return "Preliminaries"; |
|
|
|
|
return ROUND_TYPES.PRELIM; |
|
|
|
|
case 'Round of 16': |
|
|
|
|
return "Round of 16"; |
|
|
|
|
case 'Quarter-finals': |
|
|
|
|
case 'Quarter-finals replays': |
|
|
|
|
return "Quarter Finals"; |
|
|
|
|
case 'Semi-finals': |
|
|
|
|
return "Semi Finals"; |
|
|
|
|
return ROUND_TYPES.ROUNDOF16; |
|
|
|
|
case 'Third place match': |
|
|
|
|
case 'Third-place match': |
|
|
|
|
case 'Match for third place': |
|
|
|
|
case 'Third place play-off': |
|
|
|
|
case 'Third-place play-off': |
|
|
|
|
return "Third Place Match"; |
|
|
|
|
return ROUND_TYPES.CONSOLATION; |
|
|
|
|
case 'Quarterfinals': |
|
|
|
|
return "Quarterfinals"; |
|
|
|
|
case 'Quarter-finals': |
|
|
|
|
case 'Quarter-finals replays': |
|
|
|
|
return ROUND_TYPES.QUARTERFINAL; |
|
|
|
|
case 'Semifinals': |
|
|
|
|
return "Semifinals"; |
|
|
|
|
case 'Semi-finals': |
|
|
|
|
return ROUND_TYPES.SEMIFINAL; |
|
|
|
|
case 'Final': |
|
|
|
|
case 'Finals': |
|
|
|
|
return "Final"; |
|
|
|
|
return ROUND_TYPES.FINAL; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.error(`Unknown round name: ${name}`); |
|
|
|
|