|
|
|
@ -34,7 +34,6 @@ function renderBracket(options) { |
|
|
|
let nextMatchDistance = baseDistance; |
|
|
|
let nextMatchDistance = baseDistance; |
|
|
|
let minimumMatchDistance = 1; |
|
|
|
let minimumMatchDistance = 1; |
|
|
|
|
|
|
|
|
|
|
|
const totalRounds = document.querySelectorAll(".butterfly-round").length; |
|
|
|
|
|
|
|
const screenWidth = window.innerWidth; |
|
|
|
const screenWidth = window.innerWidth; |
|
|
|
let roundTotalCount = roundCount; |
|
|
|
let roundTotalCount = roundCount; |
|
|
|
if (doubleButterflyMode == true && roundCount > 1) { |
|
|
|
if (doubleButterflyMode == true && roundCount > 1) { |
|
|
|
@ -74,6 +73,7 @@ function renderBracket(options) { |
|
|
|
const matchGroupName = firstMatchTemplate.dataset.matchGroupName; |
|
|
|
const matchGroupName = firstMatchTemplate.dataset.matchGroupName; |
|
|
|
const matchFormat = firstMatchTemplate.dataset.matchFormat; |
|
|
|
const matchFormat = firstMatchTemplate.dataset.matchFormat; |
|
|
|
const roundId = firstMatchTemplate.dataset.roundId; // Add this line
|
|
|
|
const roundId = firstMatchTemplate.dataset.roundId; // Add this line
|
|
|
|
|
|
|
|
const realRoundIndex = firstMatchTemplate.dataset.roundIndex; // Add this line
|
|
|
|
|
|
|
|
|
|
|
|
let nameSpan = document.createElement("div"); |
|
|
|
let nameSpan = document.createElement("div"); |
|
|
|
nameSpan.className = "round-name"; |
|
|
|
nameSpan.className = "round-name"; |
|
|
|
@ -164,7 +164,8 @@ function renderBracket(options) { |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (roundIndex === roundCount - 1 && doubleButterflyMode == true) { |
|
|
|
} else if (roundIndex === roundCount - 1 && doubleButterflyMode == true) { |
|
|
|
nextMatchDistance = 0; |
|
|
|
nextMatchDistance = 0; |
|
|
|
} else if (roundIndex == finalRoundIndex) { |
|
|
|
} else if (roundIndex == finalRoundIndex && realRoundIndex == 0) { |
|
|
|
|
|
|
|
//realRoundIndex 0 means final's round
|
|
|
|
const values = Object.values(matchPositions[roundIndex - 1]); |
|
|
|
const values = Object.values(matchPositions[roundIndex - 1]); |
|
|
|
const parentPos1 = values[0]; |
|
|
|
const parentPos1 = values[0]; |
|
|
|
const parentPos2 = values[1]; |
|
|
|
const parentPos2 = values[1]; |
|
|
|
@ -199,7 +200,10 @@ function renderBracket(options) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (roundIndex < finalRoundIndex) { |
|
|
|
} else if ( |
|
|
|
|
|
|
|
(realRoundIndex == roundIndex && roundIndex <= finalRoundIndex) || |
|
|
|
|
|
|
|
(realRoundIndex != roundIndex && roundIndex < finalRoundIndex) |
|
|
|
|
|
|
|
) { |
|
|
|
const parentIndex1 = matchRealIndex * 2 + 1; |
|
|
|
const parentIndex1 = matchRealIndex * 2 + 1; |
|
|
|
const parentIndex2 = matchRealIndex * 2 + 2; |
|
|
|
const parentIndex2 = matchRealIndex * 2 + 2; |
|
|
|
const parentPos1 = matchPositions[roundIndex - 1][parentIndex1]; |
|
|
|
const parentPos1 = matchPositions[roundIndex - 1][parentIndex1]; |
|
|
|
@ -327,12 +331,8 @@ function renderBracket(options) { |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// Position title above the first match
|
|
|
|
// Position title above the first match
|
|
|
|
if ( |
|
|
|
titleDiv.style.top = `${-80}px`; // Adjust the 60px offset as needed
|
|
|
|
roundIndex < finalRoundIndex - 1 || |
|
|
|
if (roundIndex == finalRoundIndex && realRoundIndex == 0) { |
|
|
|
roundIndex > finalRoundIndex + 1 |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
titleDiv.style.top = `${-80}px`; // Adjust the 60px offset as needed
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
titleDiv.style.top = `${top - 80}px`; // Adjust the 60px offset as needed
|
|
|
|
titleDiv.style.top = `${top - 80}px`; // Adjust the 60px offset as needed
|
|
|
|
} |
|
|
|
} |
|
|
|
titleDiv.style.position = "absolute"; |
|
|
|
titleDiv.style.position = "absolute"; |
|
|
|
@ -348,6 +348,7 @@ function renderBracket(options) { |
|
|
|
|
|
|
|
|
|
|
|
if ( |
|
|
|
if ( |
|
|
|
roundIndex == finalRoundIndex && |
|
|
|
roundIndex == finalRoundIndex && |
|
|
|
|
|
|
|
realRoundIndex == 0 && |
|
|
|
matchIndex === 1 && |
|
|
|
matchIndex === 1 && |
|
|
|
matchDisabled[roundIndex][matchRealIndex] == false && |
|
|
|
matchDisabled[roundIndex][matchRealIndex] == false && |
|
|
|
displayLoserFinal == true && |
|
|
|
displayLoserFinal == true && |
|
|
|
@ -423,4 +424,23 @@ function renderBracket(options) { |
|
|
|
|
|
|
|
|
|
|
|
bracket.appendChild(roundDiv); |
|
|
|
bracket.appendChild(roundDiv); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function adjustSpacerHeight() { |
|
|
|
|
|
|
|
// Find the tallest match position to determine total height needed
|
|
|
|
|
|
|
|
let maxHeight = 0; |
|
|
|
|
|
|
|
Object.values(matchPositions).forEach((round) => { |
|
|
|
|
|
|
|
Object.values(round).forEach((position) => { |
|
|
|
|
|
|
|
if (position > maxHeight) { |
|
|
|
|
|
|
|
maxHeight = position; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add extra space for the match height itself
|
|
|
|
|
|
|
|
const spacerHeight = maxHeight + matchHeight / 2 + 40; // 100px extra padding
|
|
|
|
|
|
|
|
document.getElementById("bracket-spacer").style.height = |
|
|
|
|
|
|
|
`${spacerHeight}px`; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
adjustSpacerHeight(); |
|
|
|
} |
|
|
|
} |
|
|
|
|