Navigation Menu

Skip to content

Commit

Permalink
fix codeclimate
Browse files Browse the repository at this point in the history
  • Loading branch information
fewieden committed Mar 1, 2017
1 parent fe6b2fb commit 2b5a522
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 27 deletions.
43 changes: 16 additions & 27 deletions MMM-NFL.js
Expand Up @@ -278,12 +278,7 @@ Module.register('MMM-NFL', {
row.appendChild(homeTeam);

const homeLogo = document.createElement('td');
const homeIcon = document.createElement('img');
homeIcon.src = this.file(`icons/${data.h}${this.config.helmets ? '_helmet' : ''}.png`);
if (!this.config.colored) {
homeIcon.classList.add('icon');
}
homeLogo.appendChild(homeIcon);
homeLogo.appendChild(this.createIcon(data.h));
row.appendChild(homeLogo);

const homeScore = document.createElement('td');
Expand All @@ -299,15 +294,7 @@ Module.register('MMM-NFL', {
row.appendChild(awayScore);

const awayLogo = document.createElement('td');
const awayIcon = document.createElement('img');
awayIcon.src = this.file(`icons/${data.v}${this.config.helmets ? '_helmet' : ''}.png`);
if (!this.config.colored) {
awayIcon.classList.add('icon');
}
if (this.config.helmets) {
awayIcon.classList.add('away');
}
awayLogo.appendChild(awayIcon);
awayLogo.appendChild(this.createIcon(data.v, true));
row.appendChild(awayLogo);

const awayTeam = document.createElement('td');
Expand Down Expand Up @@ -352,12 +339,7 @@ Module.register('MMM-NFL', {
row.appendChild(team);

const logo = document.createElement('td');
const icon = document.createElement('img');
icon.src = this.file(`icons/${teamName}${this.config.helmets ? '_helmet' : ''}.png`);
if (!this.config.colored) {
icon.classList.add('icon');
}
logo.appendChild(icon);
logo.appendChild(this.createIcon(teamName));
row.appendChild(logo);

const byeWeek = document.createElement('td');
Expand Down Expand Up @@ -421,12 +403,7 @@ Module.register('MMM-NFL', {
row.appendChild(teamName);

const team = document.createElement('td');
const teamIcon = document.createElement('img');
teamIcon.src = this.file(`icons/${this.statistics.data.players[i].team}${this.config.helmets ? '_helmet' : ''}.png`);
if (!this.config.colored) {
teamIcon.classList.add('icon');
}
team.appendChild(teamIcon);
team.appendChild(this.createIcon(this.statistics.data.players[i].team));
row.appendChild(team);

const value = document.createElement('td');
Expand Down Expand Up @@ -460,5 +437,17 @@ Module.register('MMM-NFL', {
list.appendChild(item);
}
appendTo.appendChild(list);
},

createIcon(team, flip = false) {
const teamIcon = document.createElement('img');
teamIcon.src = this.file(`icons/${team}${this.config.helmets ? '_helmet' : ''}.png`);
if (!this.config.colored) {
teamIcon.classList.add('icon');
}
if (flip && this.config.helmets) {
teamIcon.classList.add('away');
}
return teamIcon;
}
});
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -17,6 +17,7 @@ National Football League Module for MagicMirror<sup>2</sup>
* [moment-timezone](https://www.npmjs.com/package/moment-timezone)

## Installation

1. Clone this repo into `~/MagicMirror/modules` directory.
1. Configure your `~/MagicMirror/config/config.js`:

Expand All @@ -29,6 +30,7 @@ National Football League Module for MagicMirror<sup>2</sup>
}
}
```

1. Run command `npm install --productive` in `~/MagicMirror/modules/MMM-NFL` directory.

## Config Options
Expand Down

0 comments on commit 2b5a522

Please sign in to comment.