Skip to content

Commit

Permalink
Using a loop to display a table
Browse files Browse the repository at this point in the history
  • Loading branch information
modos189 committed Aug 14, 2024
1 parent 10db076 commit ee0cc17
Showing 1 changed file with 14 additions and 78 deletions.
92 changes: 14 additions & 78 deletions plugins/scoreboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,84 +108,20 @@ function makeTable (portals,linksCount,fieldsCount) {
'<th class="mac">__MACHINA__</th>' +
'</tr>\n';

html +=
'<tr><td>Portals</td>' +
'<td>' +
portals.enl.total +
'</td>' +
'<td>' +
portals.res.total +
'</td>' +
'<td>' +
portals.mac.total +
'</td>' +
'</tr>' +
'<tr><td>avg Level</td>' +
'<td>' +
portals.enl.levels +
'</td>' +
'<td>' +
portals.res.levels +
'</td>' +
'<td>' +
portals.mac.levels +
'</td>' +
'</tr>' +
'<tr><td>avg Health</td>' +
'<td>' +
portals.enl.health +
'</td>' +
'<td>' +
portals.res.health +
'</td>' +
'<td>' +
portals.mac.health +
'</td>' +
'</tr>' +
'<tr><td>Level 8</td>' +
'<td>' +
portals.enl.level8 +
'</td>' +
'<td>' +
portals.res.level8 +
'</td>' +
'<td>' +
portals.mac.level8 +
'</td>' +
'</tr>' +
'<tr><td>Max Level</td>' +
'<td>' +
portals.enl.maxLevel +
'</td>' +
'<td>' +
portals.res.maxLevel +
'</td>' +
'<td>' +
portals.mac.maxLevel +
'</td>' +
'</tr>' +
'<tr><td>Links</td>' +
'<td>' +
linksCount.enl +
'</td>' +
'<td>' +
linksCount.res +
'</td>' +
'<td>' +
linksCount.mac +
'</td>' +
'</tr>' +
'<tr><td>Fields</td>' +
'<td>' +
fieldsCount.enl +
'</td>' +
'<td>' +
fieldsCount.res +
'</td>' +
'<td>' +
fieldsCount.mac +
'</td>' +
'</tr>';
const lines = [
['Portals', portals.enl.total, portals.res.total, portals.mac.total],
['avg Level', portals.enl.levels, portals.res.levels, portals.mac.levels],
['avg Health', portals.enl.health, portals.res.health, portals.mac.health],
['Level 8', portals.enl.level8, portals.res.level8, portals.mac.level8],
['Max Level', portals.enl.maxLevel, portals.res.maxLevel, portals.mac.maxLevel],
['Links', linksCount.enl, linksCount.res, linksCount.mac],
['Fields', fieldsCount.enl, fieldsCount.res, fieldsCount.mac],
];

html += lines.map((line) => {
const cells = line.map((cell) => `<td>${cell}</td>`);
return `<tr>${cells}</tr>`;
});

html += '</table>';
return html;
Expand Down

0 comments on commit ee0cc17

Please sign in to comment.