Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tokgozkerem committed Mar 17, 2024
0 parents commit b74b94e
Show file tree
Hide file tree
Showing 39 changed files with 450 additions and 0 deletions.
232 changes: 232 additions & 0 deletions draw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
const pots = {
"POT 1": [
"Man City",
"Sevilla",
"Barcelona",
"Napoli",
"Bayern",
"Paris",
"Benfica",
"Feyenoord",
"Liverpool",
],
"POT 2": [
"Real Madrid",
"Man United",
"Internazionale",
"Dortmund",
"Atletico",
"Leipzig",
"Porto",
"Arsenal",
"Atalanta",
],
"POT 3": [
"Shakhtar",
"Salzburg",
"Milan",
"Braga",
"PSV",
"Lazio",
"Crvena zvezda",
"Copenhagen",
"Marseille",
],
"POT 4": [
"Young Boys",
"Real Sociedad",
"Galatasaray",
"Celtic",
"Newcastle",
"Union Berlin",
"Antwerp",
"Lens",
"Molde",
],
};

// HTML içine tablo oluşturma fonksiyonu
function createTable(potName, teams) {
const table = document.createElement("table");
const tableHead = document.createElement("thead");
const tableBody = document.createElement("tbody");

const headRow = document.createElement("tr");
const headCell = document.createElement("td");
const headSpan = document.createElement("span");
headSpan.textContent = potName;
headSpan.id = `${potName.replace(/\s+/g, "-").toLowerCase()}-heading`; // id ekleyelim
headCell.appendChild(headSpan);
headRow.appendChild(headCell);
tableHead.appendChild(headRow);

teams.forEach((teamName) => {
const bodyRow = document.createElement("tr");
const bodyCell = document.createElement("td");

// Create div container for logo and team name
const teamContainer = document.createElement("div");
teamContainer.classList.add("team-container");

// Create image element for logo
const img = document.createElement("img");
img.onload = function () {
// Adjust size after image loads
this.width = 25;
this.height = 25; // Set height to 50 pixels
};
img.src = `images/${teamName.replace(/\s+/g, "_").toLowerCase()}_logo.png`;
img.alt = `${teamName} Logo`;
img.classList.add("team-logo");

// Create span element for team name
const teamNameSpan = document.createElement("span");
teamNameSpan.textContent = teamName.toUpperCase();
teamNameSpan.classList.add("team-name");

// Append image and team name to team container
teamContainer.appendChild(img);
teamContainer.appendChild(teamNameSpan);

// Append team container to body cell
bodyCell.appendChild(teamContainer);

// Append body cell to body row
bodyRow.appendChild(bodyCell);

// Append body row to table body
tableBody.appendChild(bodyRow);
});

table.appendChild(tableHead);
table.appendChild(tableBody);
return table;
}

// Tabloları HTML'e ekleme
const drawContainer = document.getElementById("drawContainer");
for (const [potName, teams] of Object.entries(pots)) {
drawContainer.appendChild(createTable(potName, teams));
}

// Yeni tablo oluşturma fonksiyonu
function createLeftPanelTable(teams) {
const table = document.createElement("table");
const tableBody = document.createElement("tbody");

teams.forEach((teamName) => {
const bodyRow = document.createElement("tr");
const bodyCell = document.createElement("td");

// Create div container for logo and team name
const teamContainer = document.createElement("div");
teamContainer.classList.add("team-container");

// Create image element for logo
const img = document.createElement("img");
img.src = `images/${teamName.replace(/\s+/g, "_").toLowerCase()}_logo.png`;
img.alt = `${teamName} Logo`;
img.classList.add("team-logo");
img.width = 25;
img.height = 25;

// Create span element for team name
const teamNameSpan = document.createElement("span");
teamNameSpan.textContent = teamName.toUpperCase();
teamNameSpan.classList.add("team-name");

// Append image and team name to team container
teamContainer.appendChild(img);
teamContainer.appendChild(teamNameSpan);

// Append team container to body cell
bodyCell.appendChild(teamContainer);

// Append body cell to body row
bodyRow.appendChild(bodyCell);

// Append body row to table body
tableBody.appendChild(bodyRow);
});

table.appendChild(tableBody);
return table;
}
const groups = [[], [], [], []];

// Grup seçimlerini tanımla
const selections = [
[
{ pot: "POT 1", count: 3 },
{ pot: "POT 2", count: 2 },
{ pot: "POT 3", count: 2 },
{ pot: "POT 4", count: 2 },
],
[
{ pot: "POT 1", count: 2 },
{ pot: "POT 2", count: 3 },
{ pot: "POT 3", count: 2 },
{ pot: "POT 4", count: 2 },
],
[
{ pot: "POT 1", count: 2 },
{ pot: "POT 2", count: 2 },
{ pot: "POT 3", count: 3 },
{ pot: "POT 4", count: 2 },
],
[
{ pot: "POT 1", count: 2 },
{ pot: "POT 2", count: 2 },
{ pot: "POT 3", count: 2 },
{ pot: "POT 4", count: 3 },
],
];

// Grup seçimlerini gerçekleştir
for (let i = 0; i < selections.length; i++) {
selectTeams(groups[i], selections[i]);
}

console.log(groups);

function selectTeams(group, selections) {
for (const selection of selections) {
selectUniqueTeamsFromPot(pots[selection.pot], selection.count, group);
}
}

function selectUniqueTeamsFromPot(pot, count, selectedTeams) {
for (let i = 0; i < count; i++) {
if (pot.length === 0) {
console.error("Hata: Pot boş.");
return;
}
const teamIndex = Math.floor(Math.random() * pot.length);
selectedTeams.push(pot[teamIndex]);
pot.splice(teamIndex, 1); // Seçilen takımı listeden çıkar
}
}

// Draw butonunu seç
const drawButton = document.getElementById("drawButton");

// Draw butonuna click olayı ekle
drawButton.addEventListener("click", drawTeams);

// Takımları gruplara ayır ve ekrana ekle
function drawTeams() {
displayGroups(); // Grupları ekrana göster
}

// Grupları ekranda göster
function displayGroups() {
// Grup container'ını seç
const groupContainer = document.getElementById("groupContainer");
groupContainer.innerHTML = ""; // Grup container'ını temizle

// Grupları ekrana ekle
for (let i = 0; i < groups.length; i++) {
const groupName = `GROUP ${i + 1}`;
groupContainer.appendChild(createTable(groupName, groups[i]));
}
}
Binary file added images/antwerp_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/arsenal_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/atalanta_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/atletico_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/barcelona_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/bayern_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/benfica_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/braga_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/celtic_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/copenhagen_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/crvena_zvezda_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/dortmund_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/feyenoord_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/galatasaray_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/internazionale_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/lazio_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/leipzig_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/lens_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/liverpool_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/man_city_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/man_united_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/marseille_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/milan_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/molde_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/napoli_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/newcastle_logo.png
Binary file added images/paris_logo.png
Binary file added images/porto_logo.png
Binary file added images/psv_logo.png
Binary file added images/real_madrid_logo.png
Binary file added images/real_sociedad_logo.png
Binary file added images/salzburg_logo.png
Binary file added images/sevilla_logo.png
Binary file added images/shakhtar_logo.png
Binary file added images/union_berlin_logo.png
Binary file added images/young_boys_logo.png
19 changes: 19 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Champions League</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<div id="drawContainer"></div>
<!-- Pot tablolarının yerleştirileceği div -->
<div id="buttonContainer">
<button id="drawButton">Draw!</button>
</div>
<!-- Draw butonu -->
<div id="groupContainer"></div>
<script src="draw.js"></script>
</body>
</html>
Loading

0 comments on commit b74b94e

Please sign in to comment.