function game_container(game) {
let top_team, bot_team;
if (game.data.WTeam) {
if (game.data.WTeam.pos == "top") {
top_team = game.data.WTeam;
} else if (game.data.WTeam.pos == "bot") {
bot_team = game.data.WTeam;
}
}
if (game.data.LTeam) {
if (game.data.LTeam.pos == "top") {
top_team = game.data.LTeam;
} else if (game.data.LTeam.pos == "bot") {
bot_team = game.data.LTeam;
}
}
let div = d3
.create("div")
.style("width", function () {
if (game.data.round == 6) {
return 1.4 * team_width + "px";
} else {
return team_width + "px";
}
})
.style("height", function () {
if (game.data.round == 6) {
return 1.4 * game_height + "px";
} else {
return game_height + "px";
}
})
.style("left", function () {
if (game.data.round == 6) {
return (game.x2 - 0.2 * team_width).toString() + "px";
} else {
return game.x2 + "px";
}
})
.style("top", function () {
if (game.data.round == 6) {
return (game.y2 - 0.2 * game_height).toString() + "px";
} else {
return game.y2 + "px";
}
})
.style("border", "solid 0.5px black")
.style("position", "absolute");
if (game.data.WTeam && game.data.LTeam && game.data.WTeam.win) {
if (game.data.WTeam.seed - game.data.LTeam.seed > 4) {
div.append(() => team_container(top_team, game.data.round, "upset"));
div.append(() => team_container(bot_team, game.data.round, "upset"));
} else if (game.data.round == 6) {
if (game.data.WTeam.pos == "top") {
div.append(() => team_container(top_team, game.data.round, "champion"));
div.append(() => team_container(bot_team, game.data.round, "bot_team"));
} else {
div.append(() => team_container(top_team, game.data.round, "top_team"));
div.append(() => team_container(bot_team, game.data.round, "champion"));
}
} else {
div.append(() => team_container(top_team, game.data.round, "top_team"));
div.append(() => team_container(bot_team, game.data.round, "bot_team"));
}
} else {
div.append(() => team_container(top_team, game.data.round, "top_team"));
div.append(() => team_container(bot_team, game.data.round, "bot_team"));
}
div.on("click", function (evt) {
if (evt.metaKey) {
let result_text = `2024,,${game.data.WTeam.TeamID},WS,${game.data.LTeam.TeamID},LS,,
${game.data.WTeam.TeamName}, ${game.data.LTeam.TeamName}`;
pbcopy(result_text);
}
});
return div.node();
}