|
|
|
@ -1,20 +1,36 @@ |
|
|
|
|
const UI = { |
|
|
|
|
CLASSNAMES: { |
|
|
|
|
ITEM: 'event-item', |
|
|
|
|
YEAR: 'event-year', |
|
|
|
|
FLAG: 'event-flag', |
|
|
|
|
LOCATION: 'event-location', |
|
|
|
|
EVENT: { |
|
|
|
|
ITEM: 'event-item', |
|
|
|
|
YEAR: 'event-year', |
|
|
|
|
FLAG: 'event-flag', |
|
|
|
|
LOCATION: 'event-location', |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
SORT: { |
|
|
|
|
ITEM: 'sort-item', |
|
|
|
|
TEXT: 'sort-text', |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
DATA: { |
|
|
|
|
ROOT: 'data-root', |
|
|
|
|
EVENT: 'data-event-key', |
|
|
|
|
ROUND: 'data-round-key', |
|
|
|
|
SORT: 'data-sort-key', |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
findRoot: (node) => { |
|
|
|
|
while (node !== document.body && node.getAttribute(UI.DATA.EVENT) === null) { |
|
|
|
|
node = node.parentNode; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return node; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
updateEventsPane: (eventKey) => { |
|
|
|
|
const events = document.querySelectorAll(`.${UI.CLASSNAMES.ITEM}`); |
|
|
|
|
|
|
|
|
|
const events = document.querySelectorAll(`.${UI.CLASSNAMES.EVENT.ITEM}`); |
|
|
|
|
|
|
|
|
|
events.forEach(node => { |
|
|
|
|
const classes = node.className.split(' '); |
|
|
|
|
classes.splice(1, classes.indexOf('active')); |
|
|
|
@ -25,6 +41,34 @@ const UI = { |
|
|
|
|
activeEventNode.className += ' active'; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
|
|
item.appendChild(text); |
|
|
|
|
item.appendChild(hide); |
|
|
|
|
roundsDiv.appendChild(item); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
buildEventsPane: (onClick) => { |
|
|
|
|
const eventsList = [ |
|
|
|
|
{ year: 1930, location: "Uruguay", icon: "uy" }, |
|
|
|
@ -61,13 +105,13 @@ const UI = { |
|
|
|
|
const flag = document.createElement('div'); |
|
|
|
|
const flagIcon = document.createElement('div'); |
|
|
|
|
|
|
|
|
|
item.className = UI.CLASSNAMES.ITEM; |
|
|
|
|
year.className = UI.CLASSNAMES.YEAR; |
|
|
|
|
location.className = UI.CLASSNAMES.LOCATION; |
|
|
|
|
flag.className = UI.CLASSNAMES.FLAG; |
|
|
|
|
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('data-event-key', evt.year); |
|
|
|
|
item.setAttribute(UI.DATA.EVENT, evt.year); |
|
|
|
|
|
|
|
|
|
year.innerHTML = evt.year; |
|
|
|
|
location.innerHTML = evt.location; |
|
|
|
@ -81,4 +125,105 @@ const UI = { |
|
|
|
|
eventsDiv.appendChild(item); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
buildSortPane: (onClick) => { |
|
|
|
|
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' }, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
const sortDiv = document.querySelector('.sort'); |
|
|
|
|
|
|
|
|
|
while (sortDiv.hasChildNodes()) { |
|
|
|
|
sortDiv.firstChild.remove(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
sortList.forEach(sort => { |
|
|
|
|
const item = document.createElement('div'); |
|
|
|
|
const text = document.createElement('div'); |
|
|
|
|
|
|
|
|
|
item.className = UI.CLASSNAMES.SORT.ITEM; |
|
|
|
|
item.addEventListener('click', onClick); |
|
|
|
|
item.setAttribute(UI.DATA.SORT, sort.value); |
|
|
|
|
|
|
|
|
|
text.className = UI.CLASSNAMES.SORT.TEXT; |
|
|
|
|
text.innerHTML = sort.text; |
|
|
|
|
|
|
|
|
|
item.appendChild(text); |
|
|
|
|
sortDiv.appendChild(item); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
buildRoundsPane: (onClick) => { |
|
|
|
|
// <div class="option-item inactive">
|
|
|
|
|
// <div class="option-text">Round Robin</div>
|
|
|
|
|
// <div class="option-toggle">Hide</div>
|
|
|
|
|
// </div>
|
|
|
|
|
//
|
|
|
|
|
// <div class="option-item">
|
|
|
|
|
// <div class="option-text">Round of 16</div>
|
|
|
|
|
// <div class="option-toggle">Hide</div>
|
|
|
|
|
// </div>
|
|
|
|
|
//
|
|
|
|
|
// <div class="option-item">
|
|
|
|
|
// <div class="option-text">Quarterfinals</div>
|
|
|
|
|
// <div class="option-toggle">Hide</div>
|
|
|
|
|
// </div>
|
|
|
|
|
//
|
|
|
|
|
// <div class="option-item">
|
|
|
|
|
// <div class="option-text">Semifinals</div>
|
|
|
|
|
// <div class="option-toggle">Hide</div>
|
|
|
|
|
// </div>
|
|
|
|
|
//
|
|
|
|
|
// <div class="option-item">
|
|
|
|
|
// <div class="option-text">Third Place</div>
|
|
|
|
|
// <div class="option-toggle">Hide</div>
|
|
|
|
|
// </div>
|
|
|
|
|
//
|
|
|
|
|
// <div class="option-item">
|
|
|
|
|
// <div class="option-text">Final</div>
|
|
|
|
|
// <div class="option-toggle">Hide</div>
|
|
|
|
|
// </div>
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
getRoundName: (name) => { |
|
|
|
|
const name2 = name.match(/^Matchday/) ? 'First round' : name; |
|
|
|
|
|
|
|
|
|
switch (name2) { |
|
|
|
|
case 'Preliminary round': |
|
|
|
|
case 'First round': |
|
|
|
|
case 'First round replays': |
|
|
|
|
case 'Group-1 Play-off': |
|
|
|
|
case 'Group-2 Play-off': |
|
|
|
|
case 'Group-3 Play-off': |
|
|
|
|
case 'Group-4 Play-off': |
|
|
|
|
return "Preliminaries"; |
|
|
|
|
case 'Round of 16': |
|
|
|
|
return "Round of 16"; |
|
|
|
|
case 'Quarter-finals': |
|
|
|
|
case 'Quarter-finals replays': |
|
|
|
|
return "Quarter Finals"; |
|
|
|
|
case 'Semi-finals': |
|
|
|
|
return "Semi Finals"; |
|
|
|
|
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"; |
|
|
|
|
case 'Quarterfinals': |
|
|
|
|
return "Quarterfinals"; |
|
|
|
|
case 'Semifinals': |
|
|
|
|
return "Semifinals"; |
|
|
|
|
case 'Final': |
|
|
|
|
case 'Finals': |
|
|
|
|
return "Final"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.error(`Unknown round name: ${name}`); |
|
|
|
|
return name; |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|