|
471 | 471 | </tr>
|
472 | 472 | <tr style="height: 32px;">
|
473 | 473 | <td colspan="3" class="text-end">
|
474 |
| - {% for problem in problems %} |
475 |
| - {% set matrixItem = scoreboard.matrix[score.team.teamid][problem.probid] %} |
476 |
| - {{ problem | problemBadgeMaybe(matrixItem) }} |
477 |
| - {% endfor %} |
| 474 | + <span class="mobile-problem-badges me-2 ms-2"> |
| 475 | + {% for problem in problems %} |
| 476 | + {% set matrixItem = scoreboard.matrix[score.team.teamid][problem.probid] %} |
| 477 | + {{ problem | problemBadgeMaybe(matrixItem) }} |
| 478 | + {% endfor %} |
| 479 | + </span> |
478 | 480 | </td>
|
479 | 481 | </tr>
|
480 | 482 | {% endfor %}
|
|
598 | 600 | if (mobileScoreboard.offsetWidth === 0) {
|
599 | 601 | return;
|
600 | 602 | }
|
601 |
| - const windowWidth = window.screen.width; |
602 |
| - const teamNameMaxWidth = Math.max(100, windowWidth - 150); |
| 603 | + const windowWidth = document.body.offsetWidth; |
| 604 | + const teamNameMaxWidth = Math.max(10, windowWidth - 150); |
| 605 | + const problemBadgesMaxWidth = Math.max(10, windowWidth - 78); |
603 | 606 | document.querySelectorAll(".mobile-scoreboard .forceWidth:not(.toolong)").forEach(el => {
|
604 |
| - console.warn(el.innerText); |
605 |
| - console.warn(`teamNameMaxWidth: ${teamNameMaxWidth}, el.offsetWidth: ${el.offsetWidth}`); |
| 607 | + el.classList.remove("toolong"); |
606 | 608 | el.style.maxWidth = teamNameMaxWidth + 'px';
|
607 | 609 | if (el instanceof Element && el.scrollWidth > el.offsetWidth) {
|
608 | 610 | el.classList.add("toolong");
|
609 | 611 | } else {
|
610 | 612 | el.classList.remove("toolong");
|
611 | 613 | }
|
612 | 614 | });
|
| 615 | + document.querySelectorAll(".mobile-scoreboard .mobile-problem-badges:not(.toolong)").forEach(el => { |
| 616 | + el.classList.remove("toolong"); |
| 617 | + el.style.maxWidth = problemBadgesMaxWidth + 'px'; |
| 618 | + if (el instanceof Element && el.scrollWidth > el.offsetWidth) { |
| 619 | + el.classList.add("toolong"); |
| 620 | + const scale = el.offsetWidth / el.scrollWidth; |
| 621 | + const offset = -1 * (el.scrollWidth - el.offsetWidth) / 2; |
| 622 | + el.style.transform = `scale(${scale}) translateX(${offset}px)`; |
| 623 | + } else { |
| 624 | + el.classList.remove("toolong"); |
| 625 | + el.style.transform = null; |
| 626 | + } |
| 627 | + }); |
613 | 628 | };
|
614 | 629 | window.addEventListener('resize', () => {
|
615 | 630 | resizeMobileTeamNames();
|
|
0 commit comments