|
|
|
@ -21,21 +21,24 @@ const UI = { |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
findRoot: (node) => { |
|
|
|
|
while (node !== document.body && node.getAttribute(UI.DATA.EVENT) === null) { |
|
|
|
|
while (node !== document.body && node.getAttribute(UI.DATA.ROOT) === null) { |
|
|
|
|
node = node.parentNode; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return node; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
updateEventsPane: (eventKey) => { |
|
|
|
|
const events = document.querySelectorAll(`.${UI.CLASSNAMES.EVENT.ITEM}`); |
|
|
|
|
|
|
|
|
|
events.forEach(node => { |
|
|
|
|
clearActive: (nodes) => { |
|
|
|
|
nodes.forEach(node => { |
|
|
|
|
const classes = node.className.split(' '); |
|
|
|
|
classes.splice(1, classes.indexOf('active')); |
|
|
|
|
node.className = classes.join(' '); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
updateEventsPane: (eventKey) => { |
|
|
|
|
const eventItems = document.querySelectorAll(`.${UI.CLASSNAMES.EVENT.ITEM}`); |
|
|
|
|
UI.clearActive(eventItems); |
|
|
|
|
|
|
|
|
|
const activeEventNode = document.querySelector(`[${UI.DATA.EVENT}="${eventKey}"`); |
|
|
|
|
activeEventNode.className += ' active'; |
|
|
|
@ -43,29 +46,16 @@ const UI = { |
|
|
|
|
|
|
|
|
|
updateRoundsPane: (rounds) => { |
|
|
|
|
const roundsDiv = document.querySelector('.rounds'); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
while (roundsDiv.hasChildNodes()) { |
|
|
|
|
roundsDiv.firstChild.remove(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.warn(rounds) |
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
updateSortPane: (sort) => { |
|
|
|
|
const sortItems = document.querySelectorAll('.sort-item'); |
|
|
|
|
UI.clearActive(sortItems); |
|
|
|
|
|
|
|
|
|
item.appendChild(text); |
|
|
|
|
item.appendChild(hide); |
|
|
|
|
roundsDiv.appendChild(item); |
|
|
|
|
sortItems.forEach(node => { |
|
|
|
|
if (node.getAttribute(UI.DATA.SORT) === sort) { |
|
|
|
|
node.className += ' active'; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
@ -106,15 +96,17 @@ const UI = { |
|
|
|
|
const flagIcon = document.createElement('div'); |
|
|
|
|
|
|
|
|
|
item.className = UI.CLASSNAMES.EVENT.ITEM; |
|
|
|
|
year.className = UI.CLASSNAMES.EVENT.YEAR; |
|
|
|
|
location.className = UI.CLASSNAMES.EVENT.LOCATION; |
|
|
|
|
flag.className = UI.CLASSNAMES.EVENT.FLAG; |
|
|
|
|
|
|
|
|
|
item.addEventListener('click', onClick); |
|
|
|
|
item.setAttribute(UI.DATA.EVENT, evt.year); |
|
|
|
|
item.setAttribute(UI.DATA.ROOT, true); |
|
|
|
|
|
|
|
|
|
year.className = UI.CLASSNAMES.EVENT.YEAR; |
|
|
|
|
year.innerHTML = evt.year; |
|
|
|
|
|
|
|
|
|
location.className = UI.CLASSNAMES.EVENT.LOCATION; |
|
|
|
|
location.innerHTML = evt.location; |
|
|
|
|
|
|
|
|
|
flag.className = UI.CLASSNAMES.EVENT.FLAG; |
|
|
|
|
flagIcon.className = `flag-icon flag-icon-${evt.icon}`; |
|
|
|
|
|
|
|
|
|
flag.appendChild(flagIcon); |
|
|
|
@ -126,12 +118,12 @@ const UI = { |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
buildSortPane: (onClick) => { |
|
|
|
|
buildSortPane: (onClick, SORT_TYPES) => { |
|
|
|
|
const sortList = [ |
|
|
|
|
{ text: 'Order by continent', value: null }, |
|
|
|
|
{ text: 'Order by goals scored', value: 'goals-scored' }, |
|
|
|
|
{ text: 'Order by country name', value: 'country-name' }, |
|
|
|
|
{ text: 'Order by country population', value: 'country-population' }, |
|
|
|
|
{ text: 'Order by goals scored', value: SORT_TYPES.GOALS }, |
|
|
|
|
{ text: 'Order by country name', value: SORT_TYPES.COUNTRY }, |
|
|
|
|
{ text: 'Order by country population', value: SORT_TYPES.POPULATION }, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
const sortDiv = document.querySelector('.sort'); |
|
|
|
@ -147,6 +139,8 @@ const UI = { |
|
|
|
|
item.className = UI.CLASSNAMES.SORT.ITEM; |
|
|
|
|
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; |
|
|
|
@ -157,36 +151,29 @@ const UI = { |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
buildRoundsPane: (onClick) => { |
|
|
|
|
// <div class="option-item inactive">
|
|
|
|
|
// <div class="option-text">Round Robin</div>
|
|
|
|
|
// <div class="option-toggle">Hide</div>
|
|
|
|
|
// </div>
|
|
|
|
|
// const roundsDiv = document.querySelector('.rounds');
|
|
|
|
|
//
|
|
|
|
|
// <div class="option-item">
|
|
|
|
|
// <div class="option-text">Round of 16</div>
|
|
|
|
|
// <div class="option-toggle">Hide</div>
|
|
|
|
|
// </div>
|
|
|
|
|
// while (roundsDiv.hasChildNodes()) {
|
|
|
|
|
// roundsDiv.firstChild.remove();
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// <div class="option-item">
|
|
|
|
|
// <div class="option-text">Quarterfinals</div>
|
|
|
|
|
// <div class="option-toggle">Hide</div>
|
|
|
|
|
// </div>
|
|
|
|
|
// rounds.forEach(round => {
|
|
|
|
|
// const item = document.createElement('div');
|
|
|
|
|
// item.className = 'round-item';
|
|
|
|
|
// item.setAttribute('data-round-id', round.roundId);
|
|
|
|
|
//
|
|
|
|
|
// <div class="option-item">
|
|
|
|
|
// <div class="option-text">Semifinals</div>
|
|
|
|
|
// <div class="option-toggle">Hide</div>
|
|
|
|
|
// </div>
|
|
|
|
|
// const hide = document.createElement('div');
|
|
|
|
|
// hide.className = 'round-hide';
|
|
|
|
|
// hide.innerHTML = 'hide';
|
|
|
|
|
//
|
|
|
|
|
// <div class="option-item">
|
|
|
|
|
// <div class="option-text">Third Place</div>
|
|
|
|
|
// <div class="option-toggle">Hide</div>
|
|
|
|
|
// </div>
|
|
|
|
|
// const text = document.createElement('div');
|
|
|
|
|
// text.className = 'round-text';
|
|
|
|
|
// text.innerHTML = round.roundName;
|
|
|
|
|
//
|
|
|
|
|
// <div class="option-item">
|
|
|
|
|
// <div class="option-text">Final</div>
|
|
|
|
|
// <div class="option-toggle">Hide</div>
|
|
|
|
|
// </div>
|
|
|
|
|
|
|
|
|
|
// item.appendChild(text);
|
|
|
|
|
// item.appendChild(hide);
|
|
|
|
|
// roundsDiv.appendChild(item);
|
|
|
|
|
// });
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
getRoundName: (name) => { |
|
|
|
|