diff --git a/dist/extendedPlayerProfile.js b/dist/extendedPlayerProfile.js index 290fbb5..8d23038 100644 --- a/dist/extendedPlayerProfile.js +++ b/dist/extendedPlayerProfile.js @@ -480,7 +480,20 @@ const renderTodaysStats = stats => { const statIncreaseStyle = 'color: #000; background-color: #0f0'; const statDecreaseStyle = 'color: #000; background-color: #f00'; - todaysStats.innerHTML = "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Today's stats\n
\n Points\n 0 ? statIncreaseStyle : statDecreaseStyle, "\">\n ").concat(Math.abs(stats.points).toLocaleString(), "\n
\n Rank\n 0 ? statIncreaseStyle : statDecreaseStyle, "\">\n ").concat(Math.abs(stats.rank), "\n
\n Villages\n 0 ? statIncreaseStyle : statDecreaseStyle, "\">\n ").concat(Math.abs(stats.villages).toLocaleString(), "\n
\n Score att\n 0 ? statIncreaseStyle : statDecreaseStyle, "\">\n ").concat(Math.abs(stats.scoreAtt).toLocaleString(), "\n
\n Rank (ODA)\n 0 ? statIncreaseStyle : statDecreaseStyle, "\">\n ").concat(Math.abs(stats.rankAtt), "\n
\n Score def\n 0 ? statIncreaseStyle : statDecreaseStyle, "\">\n ").concat(Math.abs(stats.scoreDef).toLocaleString(), "\n
\n Rank (ODD)\n 0 ? statIncreaseStyle : statDecreaseStyle, "\">\n ").concat(Math.abs(stats.rankDef), "\n
\n Score sup\n 0 ? statIncreaseStyle : statDecreaseStyle, "\">\n ").concat(Math.abs(stats.scoreSup).toLocaleString(), "\n
\n Rank (ODS)\n 0 ? statIncreaseStyle : statDecreaseStyle, "\">\n ").concat(Math.abs(stats.rankSup), "\n
\n Score total\n 0 ? statIncreaseStyle : statDecreaseStyle, "\">\n ").concat(Math.abs(stats.scoreTotal).toLocaleString(), "\n
\n Rank (OD)\n 0 ? statIncreaseStyle : statDecreaseStyle, "\">\n ").concat(Math.abs(stats.rankTotal), "\n
\n "); + todaysStats.innerHTML = "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n Today's stats\n
\n Points\n 0 ? statIncreaseStyle : statDecreaseStyle, "\">\n ").concat(Math.abs(stats.points).toLocaleString(), "\n
\n Rank\n 0 ? statIncreaseStyle : statDecreaseStyle, "\">\n ").concat(Math.abs(stats.rank), "\n
\n Villages\n 0 ? statIncreaseStyle : statDecreaseStyle, "\">\n ").concat(Math.abs(stats.villages).toLocaleString(), "\n
\n ODA\n 0 ? statIncreaseStyle : statDecreaseStyle, "\">\n ").concat(Math.abs(stats.scoreAtt).toLocaleString(), "\n
\n Rank (ODA)\n 0 ? statIncreaseStyle : statDecreaseStyle, "\">\n ").concat(Math.abs(stats.rankAtt), "\n
\n ODD\n 0 ? statIncreaseStyle : statDecreaseStyle, "\">\n ").concat(Math.abs(stats.scoreDef).toLocaleString(), "\n
\n Rank (ODD)\n 0 ? statIncreaseStyle : statDecreaseStyle, "\">\n ").concat(Math.abs(stats.rankDef), "\n
\n ODS\n 0 ? statIncreaseStyle : statDecreaseStyle, "\">\n ").concat(Math.abs(stats.scoreSup).toLocaleString(), "\n
\n Rank (ODS)\n 0 ? statIncreaseStyle : statDecreaseStyle, "\">\n ").concat(Math.abs(stats.rankSup), "\n
\n OD\n 0 ? statIncreaseStyle : statDecreaseStyle, "\">\n ").concat(Math.abs(stats.scoreTotal).toLocaleString(), "\n
\n Rank (OD)\n 0 ? statIncreaseStyle : statDecreaseStyle, "\">\n ").concat(Math.abs(stats.rankTotal), "\n
\n "); +}; + +const renderInADayRanks = player => { + let inADayRanks = document.querySelector('#inADayRanks'); + + if (!inADayRanks) { + inADayRanks = document.createElement('div'); + inADayRanks.id = 'inADayRanks'; + inADayRanks.width = '100%'; + otherElementsContainer.prepend(inADayRanks); + } + + inADayRanks.innerHTML = "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n 'In a day' best scores\n
\n Units defeated while attacking:\n \n ".concat(player.inADay.att.score.toLocaleString(), " (").concat(player.inADay.att.rank, ".)\n
\n Units defeated while defending:\n \n ").concat(player.inADay.def.score.toLocaleString(), " (").concat(player.inADay.def.rank, ".)\n
\n Units defeated while supporting:\n \n ").concat(player.inADay.sup.score.toLocaleString(), " (").concat(player.inADay.sup.rank, ".)\n
\n Resources plundered:\n \n ").concat(player.inADay.lootRes.score.toLocaleString(), " (").concat(player.inADay.lootRes.rank, ".)\n
\n Villages plundered:\n \n ").concat(player.inADay.lootVil.score.toLocaleString(), " (").concat(player.inADay.lootVil.rank, ".)\n
\n Resources gathered:\n \n ").concat(player.inADay.scavenge.score.toLocaleString(), " (").concat(player.inADay.scavenge.rank, ".)\n
\n Villages conquered:\n \n ").concat(player.inADay.conquer.score.toLocaleString(), " (").concat(player.inADay.conquer.rank, ".)\n
\n "); }; const render = (_ref2) => { @@ -496,37 +509,10 @@ const render = (_ref2) => { title: 'Daily growth:', data: player.dailyGrowth.toLocaleString(), id: 'dg' - }, { - title: 'Units defeated while attacking:', - data: "".concat(player.inADay.att.score.toLocaleString(), " (").concat(player.inADay.att.rank, ".)"), - id: 'kill_att' - }, { - title: 'Units defeated while defending:', - data: "".concat(player.inADay.def.score.toLocaleString(), " (").concat(player.inADay.def.rank, ".)"), - id: 'kill_def' - }, { - title: 'Units defeated while supporting:', - data: "".concat(player.inADay.sup.score.toLocaleString(), " (").concat(player.inADay.sup.rank, ".)"), - id: 'kill_sup' - }, { - title: 'Resources plundered:', - data: "".concat(player.inADay.lootRes.score.toLocaleString(), " (").concat(player.inADay.lootRes.rank, ".)"), - id: 'loot_res' - }, { - title: 'Villages plundered:', - data: "".concat(player.inADay.lootVil.score.toLocaleString(), " (").concat(player.inADay.lootVil.rank, ".)"), - id: 'loot_vil' - }, { - title: 'Resources gathered:', - data: "".concat(player.inADay.scavenge.score.toLocaleString(), " (").concat(player.inADay.scavenge.rank, ".)"), - id: 'scavenge' - }, { - title: 'Villages conquered:', - data: "".concat(player.inADay.conquer.score.toLocaleString(), " (").concat(player.inADay.conquer.rank, ".)"), - id: 'conquer' }].forEach(data => { renderTr(data); }); + renderInADayRanks(player); if (dailyPlayerStats && dailyPlayerStats.items.length > 0) { renderTodaysStats(dailyPlayerStats.items[0]); diff --git a/src/extendedPlayerProfile.js b/src/extendedPlayerProfile.js index 7640828..00fc6ee 100644 --- a/src/extendedPlayerProfile.js +++ b/src/extendedPlayerProfile.js @@ -301,7 +301,7 @@ const renderTodaysStats = (stats) => { - Score att + ODA 0 ? statIncreaseStyle : statDecreaseStyle @@ -341,7 +341,7 @@ const renderTodaysStats = (stats) => { - Score sup + ODS 0 ? statIncreaseStyle : statDecreaseStyle @@ -384,6 +384,98 @@ const renderTodaysStats = (stats) => { `; }; +const renderInADayRanks = (player) => { + let inADayRanks = document.querySelector('#inADayRanks'); + if (!inADayRanks) { + inADayRanks = document.createElement('div'); + inADayRanks.id = 'inADayRanks'; + inADayRanks.width = '100%'; + otherElementsContainer.prepend(inADayRanks); + } + + inADayRanks.innerHTML = ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ 'In a day' best scores +
+ Units defeated while attacking: + + ${player.inADay.att.score.toLocaleString()} (${ + player.inADay.att.rank + }.) +
+ Units defeated while defending: + + ${player.inADay.def.score.toLocaleString()} (${ + player.inADay.def.rank + }.) +
+ Units defeated while supporting: + + ${player.inADay.sup.score.toLocaleString()} (${ + player.inADay.sup.rank + }.) +
+ Resources plundered: + + ${player.inADay.lootRes.score.toLocaleString()} (${ + player.inADay.lootRes.rank + }.) +
+ Villages plundered: + + ${player.inADay.lootVil.score.toLocaleString()} (${ + player.inADay.lootVil.rank + }.) +
+ Resources gathered: + + ${player.inADay.scavenge.score.toLocaleString()} (${ + player.inADay.scavenge.rank + }.) +
+ Villages conquered: + + ${player.inADay.conquer.score.toLocaleString()} (${ + player.inADay.conquer.rank + }.) +
+ `; +}; + const render = ({ player, dailyPlayerStats }) => { [ { @@ -396,59 +488,11 @@ const render = ({ player, dailyPlayerStats }) => { data: player.dailyGrowth.toLocaleString(), id: 'dg', }, - { - title: 'Units defeated while attacking:', - data: `${player.inADay.att.score.toLocaleString()} (${ - player.inADay.att.rank - }.)`, - id: 'kill_att', - }, - { - title: 'Units defeated while defending:', - data: `${player.inADay.def.score.toLocaleString()} (${ - player.inADay.def.rank - }.)`, - id: 'kill_def', - }, - { - title: 'Units defeated while supporting:', - data: `${player.inADay.sup.score.toLocaleString()} (${ - player.inADay.sup.rank - }.)`, - id: 'kill_sup', - }, - { - title: 'Resources plundered:', - data: `${player.inADay.lootRes.score.toLocaleString()} (${ - player.inADay.lootRes.rank - }.)`, - id: 'loot_res', - }, - { - title: 'Villages plundered:', - data: `${player.inADay.lootVil.score.toLocaleString()} (${ - player.inADay.lootVil.rank - }.)`, - id: 'loot_vil', - }, - { - title: 'Resources gathered:', - data: `${player.inADay.scavenge.score.toLocaleString()} (${ - player.inADay.scavenge.rank - }.)`, - id: 'scavenge', - }, - { - title: 'Villages conquered:', - data: `${player.inADay.conquer.score.toLocaleString()} (${ - player.inADay.conquer.rank - }.)`, - id: 'conquer', - }, ].forEach((data) => { renderTr(data); }); + renderInADayRanks(player); if (dailyPlayerStats && dailyPlayerStats.items.length > 0) { renderTodaysStats(dailyPlayerStats.items[0]); }