diff options
author | emkael <emkael@tlen.pl> | 2023-01-09 01:58:54 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2023-01-09 01:58:54 +0100 |
commit | 8baf03224b828536953ce82fc9ac8fbba4a0b4ce (patch) | |
tree | 3851f2b5305370b8d3023cc689802736dc91e1a1 | |
parent | 1252f092a3bf3749f4d6075f936a5b1fc87b6d3d (diff) |
Highlight neighbouring boxes as well if box fade is enabled
-rw-r--r-- | playoff.js | 37 |
1 files changed, 33 insertions, 4 deletions
@@ -71,12 +71,41 @@ var playoff = { highlightBox: function(box) { var boxes = document.getElementsByClassName('playoff_matchbox'); + var highlightBoxes = []; + var attrArr = ['data-winner', 'data-loser', 'data-place-winner', 'data-place-loser', 'data-finish-winner', 'data-finish-loser']; for (var b = 0; b < boxes.length; b++) { var boxId = boxes[b].getAttribute('data-id'); - if (box && (boxId != box)) { - boxes[b].classList.add('faded'); - } else { - boxes[b].classList.remove('faded'); + if (box && (boxId == box)) { + highlightBoxes.push(boxId); + for (const attr of attrArr) { + var attrVal = boxes[b].getAttribute(attr); + if (attrVal) { + highlightBoxes = highlightBoxes.concat(attrVal.split(' ')); + } + } + } + boxes[b].classList.remove('faded'); + } + if (box) { + for (var b = 0; b < boxes.length; b++) { + var fade = true; + var boxId = boxes[b].getAttribute('data-id'); + if (highlightBoxes.includes(boxId)) { + fade = false; + } else { + for (const attr of attrArr) { + var boxId = boxes[b].getAttribute(attr); + if (boxId) { + boxIds = boxId.split(' '); + if (boxIds.includes(box)) { + fade = false; + } + } + } + } + if (fade) { + boxes[b].classList.add('faded'); + } } } }, |