Skip to content

Commit c82e763

Browse files
Improve hearts on scoreboard by using separate column
1 parent 35fb542 commit c82e763

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

webapp/public/js/domjudge.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,6 @@ function getHeartCol(row) {
318318
td = tds[1];
319319
}
320320
if (td !== null) {
321-
if (td.children.length) {
322-
return td.children[0];
323-
}
324321
return td;
325322
}
326323

@@ -397,11 +394,10 @@ function toggle(id, show, mobile)
397394
});
398395
}
399396

400-
function addHeart(rank, row, id, isFav, mobile)
397+
function getHeartTd(rank, row, id, isFav, mobile)
401398
{
402-
var heartCol = getHeartCol(row);
403399
var iconClass = isFav ? "fas fa-heart" : "far fa-heart";
404-
return heartCol.innerHTML + "<span class=\"heart " + iconClass + "\" onclick=\"toggle(" + id + "," + (isFav ? "false" : "true") + "," + mobile + ")\"></span>";
400+
return "<td class=\"scoreaf heart\"><span class=\"heart " + iconClass + "\" onclick=\"toggle(" + id + "," + (isFav ? "false" : "true") + "," + mobile + ")\"></span></td>";
405401
}
406402

407403
function initFavouriteTeams()
@@ -432,7 +428,9 @@ function initFavouriteTeams()
432428
for (var i = 0; i < favTeams.length; i++) {
433429
if (teamname === favTeams[i]) {
434430
found = true;
435-
heartCol.innerHTML = addHeart(rank, scoreboard[j], teamIndex, found, mobile);
431+
let heartTd = getHeartTd(rank, scoreboard[j], teamIndex, found, mobile);
432+
// Insert td after heartCol
433+
heartCol.insertAdjacentHTML('afterend', heartTd);
436434
toAdd[cntFound] = scoreboard[j].cloneNode(true);
437435
if (mobile) {
438436
toAddMobile[cntFound] = scoreboard[j + 1].cloneNode(true);
@@ -455,7 +453,8 @@ function initFavouriteTeams()
455453
}
456454
}
457455
if (!found) {
458-
heartCol.innerHTML = addHeart(rank, scoreboard[j], teamIndex, found, mobile);
456+
let heartTd = getHeartTd(rank, scoreboard[j], teamIndex, found, mobile);
457+
heartCol.insertAdjacentHTML('afterend', heartTd);
459458
}
460459
if (rank !== "") {
461460
lastRank = rank;

webapp/public/style_domjudge.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ del {
198198
.scoreboard td.no-border, .scoreboard th.no-border {
199199
border: none;
200200
}
201+
.scoreboard td.heart {
202+
padding-left: 0.5rem;
203+
padding-right: 0.5rem;
204+
}
201205
.scoreboard td.rank {
202206
padding-left: 0.3em;
203207
padding-right: 0.3em;

webapp/templates/partials/scoreboard_table.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
3131
<table class="d-none d-md-table scoreboard desktop-scoreboard center {% if jury %}scoreboard_jury{% endif %}">
3232
33-
{% set teamColspan = 2 %}
33+
{% set teamColspan = 3 %}
3434
{% if showAffiliationLogos %}
3535
{% set teamColspan = teamColspan + 1 %}
3636
{% endif %}

0 commit comments

Comments
 (0)