Skip to content

Commit

Permalink
Release Candidate v0.13.1 (#86)
Browse files Browse the repository at this point in the history
- Display player headshots when available for individual sports

Note:  Must clear cache and refresh after upgrade.
  • Loading branch information
vasqued2 authored Jun 15, 2024
1 parent 4131bfd commit 0864704
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 24 deletions.
8 changes: 7 additions & 1 deletion dist/const.js
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
export let VERSION = "v0.13.0"
export let VERSION = "v0.13.1";

export let GOLF_HEADSHOT_URL = "https://a.espncdn.com/i/headshots/golf/players/full/";
export let MMA_HEADSHOT_URL = "https://a.espncdn.com/i/headshots/mma/players/full/";
export let RACING_HEADSHOT_URL = "https://a.espncdn.com/i/headshots/rpm/players/full/";
export let TENNIS_HEADSHOT_URL = "https://a.espncdn.com/i/headshots/tennis/players/full/";
export let ERROR_HEADSHOT_URL = "https://cdn-icons-png.freepik.com/512/9706/9706583.png";
8 changes: 4 additions & 4 deletions dist/render_in.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function renderIn(c) {
.on-second { opacity: ${c.onSecondOp}; display: inline-block; }
.on-third { opacity: ${c.onThirdOp}; display: inline-block; }
.pitcher { opacity: 0.0; display: inline-block; }
.in-row0 { display:${c.seriesSummaryDisplay}; font-size: 1.2em; text-align: center; margin: 4px; }
.in-series-info { display:${c.seriesSummaryDisplay}; font-size: 1.2em; text-align: center; margin: 4px; }
.in-row1 { font-size: 1em; height: 1em; margin: 6px 0 2px; }
.in-row2 { ; font-size: 1em; height: 1em; margin: 6px 0 2px; }
.in-row1, .in-row2 { display: flex; justify-content: space-between; align-items: center; margin: 2px 0; }
Expand All @@ -56,12 +56,11 @@ export function renderIn(c) {
<ha-card>
<div class="card">
<div class="title">${c.title}</div>
<div class="in-row0">${c.seriesSummary}</div>
<img class="team-bg" src="${c.logoBG[1]}" />
<img class="opponent-bg" src="${c.logoBG[2]}" />
<div class="card-content">
<div class="team">
<img class="logo" src="${c.logo[1]}" />
<img class="logo" src="${c.logo[1]}" onerror="this.onerror=null; this.src='${c.logoError[1]}';" />
<div class="circle">${c.initials[1]}</div>
<div class="name"><span class="rank">${c.rank[1]}</span> ${c.name[1]}</div>
<div class="record">${c.record[1]}</div>
Expand All @@ -77,7 +76,7 @@ export function renderIn(c) {
<div class="score">${c.score[2]}</div>
<div class="possession2">&bull;</div>
<div class="team">
<img class="logo" src="${c.logo[2]}" />
<img class="logo" src="${c.logo[2]}" onerror="this.onerror=null; this.src='${c.logoError[2]}';" />
<div class="circle">${c.initials[2]}</div>
<div class="name"><span class="rank">${c.rank[2]}</span> ${c.name[2]}</div>
<div class="record">${c.record[2]}</div>
Expand All @@ -98,6 +97,7 @@ export function renderIn(c) {
<div class="on-first">&bull;</div>
</div>
<div class="outs">${c.in0}</div>
<div class="in-series-info">${c.seriesSummary}</div>
<div class="line1"></div>
<div class="in-row1">
<div class="venue">${c.venue}</div>
Expand Down
8 changes: 4 additions & 4 deletions dist/render_post.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,17 @@ export function renderPost(c) {
.divider { font-size: 2.5em; text-align: center; opacity: 0; }
.name { font-size: 1.4em; margin-bottom: 4px; }
.rank { font-size:0.8em; display: ${c.rankDisplay}; }
.post-row0 { display:${c.seriesSummaryDisplay}; font-size: 1.2em; text-align: center; margin: 4px; }
.post-series-info { display:${c.seriesSummaryDisplay}; font-size: 1.2em; text-align: center; margin: 4px; }
.post-row1 { font-size: 1.2em; text-align: center; }
</style>
<ha-card>
<div class="card">
<div class="title">${c.title}</div>
<div class="post-row0">${c.seriesSummary}</div>
<img class="team-bg" src="${c.logoBG[1]}" />
<img class="opponent-bg" src="${c.logoBG[2]}" />
<div class="card-content">
<div class="team">
<img class="logo" src="${c.logo[1]}" />
<img class="logo" src="${c.logo[1]}" onerror="this.onerror=null; this.src='${c.logoError[1]}';" />
<div class="circle">${c.initials[1]}</div>
<div class="name"><span class="rank">${c.rank[1]}</span> ${c.name[1]}</div>
<div class="record">${c.record[1]}</div>
Expand All @@ -41,13 +40,14 @@ export function renderPost(c) {
<div class="divider">&nbsp&nbsp&nbsp</div>
<div class="score score2op">${c.score[2]}</div>
<div class="team">
<img class="logo" src="${c.logo[2]}" />
<img class="logo" src="${c.logo[2]}" onerror="this.onerror=null; this.src='${c.logoError[2]}';" />
<div class="circle">${c.initials[2]}</div>
<div class="name"><span class="rank">${c.rank[2]}</span> ${c.name[2]}</div>
<div class="record">${c.record[2]}</div>
</div>
</div>
<div class="post-row1">${c.finalTerm}</div>
<div class="post-series-info">${c.seriesSummary}</div>
</div>
</ha-card>
`; // Return the HTML template
Expand Down
8 changes: 4 additions & 4 deletions dist/render_pre.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,18 @@ export function renderPre(c) {
.gameday { font-size: 1.4em; height: 1.4em; }
.gamedate { font-size: 1.1em; height: 1.1em; }
.gametime { font-size: 1.1em; height: 1.1em; }
.pre-row0 { display:${c.seriesSummaryDisplay}; font-size: 1.2em; text-align: center; margin: 4px; }
.pre-series-info { display:${c.seriesSummaryDisplay}; font-size: 1.2em; text-align: center; margin: 4px; }
.pre-row1 { font-weight: 500; font-size: 1.2em; height: 1.2em; margin: 6px 0 2px; }
.pre-row1, .pre-row2, .pre-row3 { display: flex; justify-content: space-between; align-items: center; margin: 2px 0; }
</style>
<ha-card>
<div class="card">
<div class="title">${c.title}</div>
<div class="pre-row0">${c.seriesSummary}</div>
<img class="team-bg" src="${c.logoBG[1]}" />
<img class="opponent-bg" src="${c.logoBG[2]}" />
<div class="card-content">
<div class="team">
<img class="logo" src="${c.logo[1]}" />
<img class="logo" src="${c.logo[1]}" onerror="this.onerror=null; this.src='${c.logoError[1]}';" />
<div class="circle">${c.initials[1]}</div>
<div class="name"><span class="rank">${c.rank[1]}</span> ${c.name[1]}</div>
<div class="record">${c.record[1]}</div>
Expand All @@ -44,12 +43,13 @@ export function renderPre(c) {
<div class="gametime">${c.gameTime}</div>
</div>
<div class="team">
<img class="logo" src="${c.logo[2]}" />
<img class="logo" src="${c.logo[2]}" onerror="this.onerror=null; this.src='${c.logoError[2]}';" />
<div class="circle">${c.initials[2]}</div>
<div class="name"><span class="rank">${c.rank[2]}</span> ${c.name[2]}</div>
<div class="record">${c.record[2]}</div>
</div>
</div>
<div class="pre-series-info">${c.seriesSummary}</div>
<div class="line"></div>
<div class="pre-row1">
<div class="date">${c.startTerm} ${c.startTime}</div>
Expand Down
5 changes: 5 additions & 0 deletions dist/set_defaults.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { ERROR_HEADSHOT_URL } from "./const.js";

//
// Initialize card data
//
export function initCardData(c) {
c.logoBG = [];
c.logo = [];
c.logoError = [];
c.name = [];
c.initials = [];
c.rank = [];
Expand Down Expand Up @@ -64,12 +67,14 @@ export function setDefaults(t, lang, stateObj, c, o, sport, team, oppo) {
// Set Scoreboard data

c.logo[team] = stateObj.attributes.team_logo;
c.logoError[team] = ERROR_HEADSHOT_URL;
c.logoBG[team] = stateObj.attributes.team_logo;
c.name[team] = stateObj.attributes.team_name;
c.rank[team] = stateObj.attributes.team_rank;
c.record[team] = stateObj.attributes.team_record;
c.winner[team] = stateObj.attributes.team_winner || false;
c.logo[oppo] = stateObj.attributes.opponent_logo;
c.logoError[oppo] = ERROR_HEADSHOT_URL;
c.logoBG[oppo] = stateObj.attributes.opponent_logo;
c.name[oppo] = stateObj.attributes.opponent_name;
c.rank[oppo] = stateObj.attributes.opponent_rank;
Expand Down
35 changes: 24 additions & 11 deletions dist/set_sports.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { GOLF_HEADSHOT_URL, MMA_HEADSHOT_URL, RACING_HEADSHOT_URL, TENNIS_HEADSHOT_URL } from "./const.js";

//
// Call function to set the data for the sport
//
Expand Down Expand Up @@ -119,6 +121,8 @@ export function setGolf(t, stateObj, c, team, oppo) {
c.finalTerm = stateObj.attributes.clock;
c.timeoutsDisplay = 'none';

c.logo[team] = GOLF_HEADSHOT_URL + stateObj.attributes.team_id + ".png";
c.logo[oppo] = GOLF_HEADSHOT_URL + stateObj.attributes.opponent_id + ".png";
}

//
Expand Down Expand Up @@ -149,6 +153,9 @@ export function setMMA(t, stateObj, c, team, oppo) {
c.timeoutsDisplay = 'none';
c.barDisplay = "none";
c.barWrapDisplay = "none";

c.logo[team] = MMA_HEADSHOT_URL + stateObj.attributes.team_id + ".png";
c.logo[oppo] = MMA_HEADSHOT_URL + stateObj.attributes.opponent_id + ".png";
}


Expand Down Expand Up @@ -177,17 +184,19 @@ export function setRacing(t, stateObj, c, team, oppo) {
c.barLabel[team] = t.translate("racing.teamBarLabel", "%s", String(stateObj.attributes.team_total_shots));
c.barLabel[oppo] = t.translate("racing.teamBarLabel", "%s", String(stateObj.attributes.team_total_shots));

if (stateObj.attributes.league.includes("NASCAR")) {
c.logo[team] = null;
c.logo[oppo] = null;
c.initials[team] = "";
c.initials[oppo] = "";
if (c.name[team] && c.name[oppo]) {
c.initials[team] = c.name[team].split(" ").map((n)=>n[0]).join("");
c.initials[oppo] = c.name[oppo].split(" ").map((n)=>n[0]).join("");
c.initialsDisplay = 'inline';
}
}
// if (stateObj.attributes.league.includes("NASCAR")) {
// c.logo[team] = null;
// c.logo[oppo] = null;
// c.initials[team] = "";
// c.initials[oppo] = "";
// if (c.name[team] && c.name[oppo]) {
// c.initials[team] = c.name[team].split(" ").map((n)=>n[0]).join("");
// c.initials[oppo] = c.name[oppo].split(" ").map((n)=>n[0]).join("");
// c.initialsDisplay = 'inline';
// }
// }
c.logo[team] = RACING_HEADSHOT_URL + stateObj.attributes.team_id + ".png";
c.logo[oppo] = RACING_HEADSHOT_URL + stateObj.attributes.opponent_id + ".png";
}

//
Expand Down Expand Up @@ -248,6 +257,10 @@ export function setTennis(t, stateObj, c, team, oppo) {
}
c.timeouts[team] = stateObj.attributes.team_sets_won;
c.timeouts[oppo] = stateObj.attributes.opponent_sets_won;

c.logo[team] = TENNIS_HEADSHOT_URL + stateObj.attributes.team_id + ".png";
c.logo[oppo] = TENNIS_HEADSHOT_URL + stateObj.attributes.opponent_id + ".png";

c.title = c.title || stateObj.attributes.event_name

c.timeoutsDisplay = 'inline';
Expand Down

0 comments on commit 0864704

Please sign in to comment.