Skip to content

Commit

Permalink
Clarified comments, Change functions to arrow functions and removed e…
Browse files Browse the repository at this point in the history
…xtra spaces
  • Loading branch information
Abel-Zambrano committed Jul 28, 2021
1 parent 36662b9 commit 7bf6086
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions pages/wins/wins.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
//cardData[index][question_str] = answer_str
let cardData = []
const keys = rawData[0]
rawData.slice(1).forEach((data) => {
rawData.slice(1).forEach( data => {
let cardObj = {}
for (let i = 0; i < keys.length; i++) {
cardObj[keys[i]] = data[i];
Expand All @@ -100,11 +100,10 @@
window.localStorage.setItem('data', JSON.stringify(cardData));
makeCards(cardData);
ifPageEmpty();

}


//Create The Filters From The Displayed Cards On Page Load
//Create The "Role" and "Team" Filters From The Displayed Cards On Page Load
document.addEventListener("DOMContentLoaded", createFilter);
function createFilter(){

Expand All @@ -118,12 +117,11 @@
Array.isArray(team) ? teamArr.push(...team) : teamArr.push(team);

})
//Assign Role for each Wins-Card
responses.querySelectorAll('.wins-card-role:not([style*="display:none"]):not([style*="display: none"]').forEach(item =>{
let value = item.textContent.replace("Role(s):","").trim();
let role = value.split(",").map(x=>x.trim());
Array.isArray(role) ? roleArr.push(...role) : roleArr.push(role);


})


Expand Down Expand Up @@ -169,7 +167,7 @@
let queryObj = { };

//Calculate and Create Updated Query String
incomingFilterData.forEach(function(e){
incomingFilterData.forEach( e => {
//Find boxes that are checked
if(e.checked){
let data = e.value.split("_");
Expand Down Expand Up @@ -203,10 +201,6 @@

//Update URL parameters
window.history.replaceState(null, '', urlParameter.replaceAll(" ","+"));




}

//Update UI on URL history change and on DomContent loaded
Expand Down Expand Up @@ -296,20 +290,20 @@

const iconContainer = cloneCardTemplate.querySelector(cardSelector);

cardList.forEach( (item) => {
cardList.forEach( item => {
if (badgeIcons.hasOwnProperty(item)) {
iconContainer.insertAdjacentHTML('beforeend',
`<div class='${view}-item-container'>
<img class="${view}-badge-icon" alt="${badgeIcons[item]}" src="${SVG_FILE_PATH}${badgeIcons[item]}">
<div class="${view}-text-bubble" data-wins="font-styling">${item}</div>
</div>`
<img class="${view}-badge-icon" alt="${badgeIcons[item]}" src="${SVG_FILE_PATH}${badgeIcons[item]}">
<div class="${view}-text-bubble" data-wins="font-styling">${item}</div>
</div>`
)
} else if (item !== '') {
iconContainer.insertAdjacentHTML('beforeend',
`<div class='${view}-item-container'>
<img class="${view}-badge-icon" alt="${badgeIcons[otherIcon]}" src="${SVG_FILE_PATH}${otherIcon}">
<div class="${view}-text-bubble" data-wins="font-styling">${item}</div>
</div>`
<img class="${view}-badge-icon" alt="${badgeIcons[otherIcon]}" src="${SVG_FILE_PATH}${otherIcon}">
<div class="${view}-text-bubble" data-wins="font-styling">${item}</div>
</div>`
)
}
})
Expand Down

0 comments on commit 7bf6086

Please sign in to comment.