Added tournament cards to the main page
These little cards show the most recent tournaments, the number of which is defined in the db_config file (default 6)
This commit is contained in:
parent
63223d7fb6
commit
6dc7256e92
@ -7,15 +7,21 @@ $dbUsername = "USERNAME";
|
||||
$dbPassword = "PASSWORD";
|
||||
$dbName = "DBNAME";
|
||||
|
||||
|
||||
/*////// USER-CONFIGURABLE VARIABLES HERE /////////
|
||||
|
||||
|
||||
/*///// MISC VARIABLES ///////
|
||||
////////////////////////////*/
|
||||
|
||||
// The maximum number of tourneys we show on the home page
|
||||
$tourneyCardLimit = 6;
|
||||
|
||||
|
||||
/*/////////////////////////////////////////////////
|
||||
I don't recommend you change these, but if you
|
||||
know what you're doing, have at 'er
|
||||
|
||||
/////////////////////////////////////////////////*/
|
||||
|
||||
|
||||
$userTableName = "users"; // name of the table containing user data
|
||||
$gameDataTableName = "games"; // table containing replay data
|
||||
$tournamentDataTableName = "tournaments"; // tournament data table
|
||||
|
@ -10,6 +10,7 @@ session_start();
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
|
||||
<link rel="stylesheet" href="/styles/primary.css" />
|
||||
<link rel="stylesheet" href="/styles/data_display.css" />
|
||||
<link rel="stylesheet" href="/styles/tourney_results.css" />
|
||||
<script src="/scripts/tools.js"></script>
|
||||
<script src="/scripts/results.js"></script>
|
||||
<script>verifyPageInFrame()</script>
|
||||
@ -117,7 +118,7 @@ session_start();
|
||||
<body id="resultsDisplayBody">
|
||||
<div id="generalResultsDisplayPanel" style="display:block;">
|
||||
<h2>General Information</h2>
|
||||
<div id="infoNav"><p class="infoLink" onclick="toggleInformationDisplay();resizeIframe(parent.document.getElementById('dataFrame'));">Recent Tourney Results</p></div>
|
||||
<div id="infoNav"><p class="infoLink" onclick="toggleInformationDisplay();refreshTourneyDisplay();resizeIframe(parent.document.getElementById('dataFrame'));">Recent Tourney Results</p></div>
|
||||
<p class="newLine"> </p>
|
||||
<hr class="tableLine newLine">
|
||||
<div id="generalResultsTable">
|
||||
@ -185,24 +186,24 @@ session_start();
|
||||
|
||||
<div id="tourneyResultsDisplayPanel" style="display:none;">
|
||||
<h2>Recent Tourney Results</h2>
|
||||
<div id="infoNav"><p class="infoLink" onclick="toggleInformationDisplay();resizeIframe(parent.document.getElementById('dataFrame'));">General Information</p></div>
|
||||
<div id="infoNav"><p class="infoLink" onclick="toggleInformationDisplay();refreshTourneyDisplay();resizeIframe(parent.document.getElementById('dataFrame'));">General Information</p></div>
|
||||
<p class="newLine"></p>
|
||||
<div class="resultsNavPanelAllButton">
|
||||
<input type="radio" id="allButton" name="resultsDivision" value="all" onclick="" checked="checked">
|
||||
<input type="radio" id="allButton" name="resultsDivision" value="all" onclick="refreshTourneyDisplay();" checked="checked">
|
||||
<label for="allButton" id="allButton">All</label>
|
||||
</div>
|
||||
<p class="newLine"></p>
|
||||
<div class="resultsNavPanel">
|
||||
<input type="radio" id="openButton" name="resultsDivision" value="open" onclick="">
|
||||
<input type="radio" id="openButton" name="resultsDivision" value="open" onclick="refreshTourneyDisplay();">
|
||||
<label for="openButton" id="openButton">Open</label>
|
||||
<input type="radio" id="intermediateButton" name="resultsDivision" value="intermediate" onclick="">
|
||||
<input type="radio" id="intermediateButton" name="resultsDivision" value="intermediate" onclick="refreshTourneyDisplay();">
|
||||
<label for="intermediateButton" id="intermediateButton">Intermediate</label>
|
||||
<input type="radio" id="mainButton" name="resultsDivision" value="main" onclick="">
|
||||
<input type="radio" id="mainButton" name="resultsDivision" value="main" onclick="refreshTourneyDisplay();">
|
||||
<label for="mainButton" id="mainButton">Main</label>
|
||||
</div>
|
||||
<hr class="tableLine newLine">
|
||||
<p> </p>
|
||||
<div id="divisionDisplay">
|
||||
<div id="recentTourneyDisplay">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
@ -42,23 +42,17 @@ function refreshDisplay() {
|
||||
html += "<p>Top 10 Winners</p>"
|
||||
html += "<hr class=\"tableLineLightCentre\">";
|
||||
|
||||
|
||||
|
||||
|
||||
html += "<iframe src=\"/display/division_results.php?division=" + currentDivision + "&month=" + document.getElementById("month").value + "&year=" + document.getElementById("year").value + "\" name=\"divisionFrame\" class=\"divisionFrame\" id=\"divisionFrame\" onload=\"resizeIframe(this);var obj=parent.document.getElementById('dataFrame');resizeIframe(obj);\"></iframe>";
|
||||
|
||||
html += "</div>";
|
||||
// TODO;
|
||||
|
||||
// CREATE OUTPUT DISPLAY
|
||||
|
||||
|
||||
document.getElementById("divisionDisplay").innerHTML = html;
|
||||
|
||||
}
|
||||
|
||||
function toggleInformationDisplay() {
|
||||
console.log("echo");
|
||||
// Used to swap between 'general information' and 'recent tourney results' on the home page
|
||||
var infoDiv = document.getElementById("generalResultsDisplayPanel");
|
||||
var tourneyDiv = document.getElementById("tourneyResultsDisplayPanel");
|
||||
|
||||
@ -69,4 +63,25 @@ function toggleInformationDisplay() {
|
||||
infoDiv.style.display = "block";
|
||||
tourneyDiv.style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
function refreshTourneyDisplay() {
|
||||
// Used to refresh the data in the iframe on the main page, under the 'recent tourney results'
|
||||
// Grab the division buttons by their name
|
||||
var divisionButtons = document.getElementsByName("resultsDivision");
|
||||
var currentDivision = "";
|
||||
|
||||
|
||||
// Loop through the division buttons and see which one is checked
|
||||
// Set the current division to that option
|
||||
for (var i = 0; i < divisionButtons.length; i++) {
|
||||
if (divisionButtons[i].checked) {
|
||||
currentDivision = divisionButtons[i].value;
|
||||
}
|
||||
}
|
||||
|
||||
// Create variable for easier readability
|
||||
var html = "<iframe src=\"/tournament/recent_results.php?division=" + currentDivision + "\" name=\"recentTourneyFrame\" class=\"recentTourneyFrame\" id=\"recentTourneyFrame\" onload=\"resizeIframe(this);var obj=parent.document.getElementById('dataFrame');resizeIframe(obj);\"></iframe>";
|
||||
|
||||
document.getElementById("recentTourneyDisplay").innerHTML = html;
|
||||
}
|
@ -321,6 +321,16 @@
|
||||
margin-top: 5%;
|
||||
}
|
||||
|
||||
#tourneyResultsDisplayPanel {
|
||||
order: 2;
|
||||
width: 92%;
|
||||
margin-right: 0;
|
||||
padding-left: 2%;
|
||||
padding-right: 2%;
|
||||
margin-top: 5%;
|
||||
}
|
||||
|
||||
|
||||
#divisionDisplayPanel {
|
||||
order: 1;
|
||||
width: 94%;
|
||||
|
@ -9,6 +9,11 @@
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.newLineThin {
|
||||
width: 100%;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
.disabled {
|
||||
pointer-events: none;
|
||||
cursor: default;
|
||||
|
55
styles/tourney_results.css
Normal file
55
styles/tourney_results.css
Normal file
@ -0,0 +1,55 @@
|
||||
.recentTourneyResultsPanel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-wrap: nowrap;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
align-items: center;
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
}
|
||||
|
||||
.recentTourneyFrame {
|
||||
flex-grow: 1;
|
||||
flex-shrink: 1;
|
||||
margin: auto;
|
||||
padding: 0;
|
||||
border: none;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.tourneyCard {
|
||||
border: 2px solid rgb(0, 0, 255);
|
||||
border-radius: 20px;
|
||||
box-shadow: 0px 2px 4px;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
padding-top: 5px;
|
||||
padding-bottom: 5px;
|
||||
}
|
||||
|
||||
|
||||
.tourneyCardHeader {
|
||||
width: 100%;
|
||||
text-align: left;
|
||||
margin: 0;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.tourneyCardLeft {
|
||||
text-align: left;
|
||||
margin: 0;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
}
|
||||
|
||||
.tourneyCardRight {
|
||||
text-align: right;
|
||||
margin: 0;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
}
|
96
tournament/recent_results.php
Normal file
96
tournament/recent_results.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
session_start();
|
||||
|
||||
include("../admin/db_config.php");
|
||||
|
||||
try { // Try opening the SQL database connection
|
||||
$conn = new PDO("mysql:host=$servername; dbname=$dbName", $dbUsername, $dbPassword);
|
||||
// set the PDO error mode to exception
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
// Get the division from the page
|
||||
$division = $_GET["division"];
|
||||
|
||||
// If we want all the data, we don't need to select a division in the SQL query
|
||||
if ($division == "all") {
|
||||
$sqlGetTourneyInfo = $conn->prepare("SELECT tournamentName,tournamentDate,tournamentDivision,numPlayers,winningTeamName,winner1,winner2,winner3,winner4 FROM " . $tournamentDataTableName . " ORDER BY tournamentDate DESC LIMIT $tourneyCardLimit");
|
||||
} else {
|
||||
$sqlGetTourneyInfo = $conn->prepare("SELECT tournamentName,tournamentDate,tournamentDivision,numPlayers,winningTeamName,winner1,winner2,winner3,winner4 FROM " . $tournamentDataTableName . " WHERE tournamentDivision='" . $division . "' ORDER BY tournamentDate DESC LIMIT $tourneyCardLimit");
|
||||
}
|
||||
|
||||
$sqlGetTourneyInfo->execute();
|
||||
|
||||
} catch (PDOException $e) { // failed connection
|
||||
echo "Connection failed: " . $e->getMessage();
|
||||
}
|
||||
|
||||
$tourneyResults = $sqlGetTourneyInfo->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
?>
|
||||
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no" />
|
||||
<link rel="stylesheet" href="/styles/primary.css" />
|
||||
<link rel="stylesheet" href="/styles/db_management.css" />
|
||||
<link rel="stylesheet" href="/styles/tourney_results.css" />
|
||||
<script src="/scripts/tools.js"></script>
|
||||
<script>verifyPageInFrame()</script>
|
||||
<title>no title</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="recentTourneyResultsPanel">
|
||||
<?php
|
||||
foreach ($tourneyResults as $result) {
|
||||
$tourneyName = $result["tournamentName"];
|
||||
$tourneyDate = $result["tournamentDate"];
|
||||
$division = $result["tournamentDivision"];
|
||||
$numPlayers = $result["numPlayers"];
|
||||
$winningTeamName = $result["winningTeamName"];
|
||||
$winner1 = $result["winner1"];
|
||||
$winner2 = $result["winner2"];
|
||||
$winner3 = $result["winner3"];
|
||||
$winner4 = $result["winner4"];
|
||||
// Format date
|
||||
$tourneyDate = DateTime::createFromFormat('Y-m-d', $tourneyDate);
|
||||
$tourneyDate = $tourneyDate->format('M j, Y');
|
||||
echo ("
|
||||
<div class=\"tourneyCard\">
|
||||
<p class=\"tourneyCardHeader\">$tourneyName</p>
|
||||
<p class=\"newLineThin\"></p>
|
||||
<p class=\"tourneyCardLeft\">$tourneyDate</p>
|
||||
<p class=\"tourneyCardRight underlined\">$winningTeamName</p>
|
||||
<p class=\"newLineThin\"></p>
|
||||
<p class=\"tourneyCardLeft\">$division</p>
|
||||
<p class=\"tourneyCardRight\"><a href=\"/user/$winner1\" class=\"plainLinkBlack\" onclick=\"redirect('this', '/user/$winner1');\">$winner1</a></p>
|
||||
<p class=\"newLineThin\"></p>
|
||||
<p class=\"tourneyCardLeft\">" . $numPlayers . "v" . $numPlayers . "</p>");
|
||||
if ($numPlayers >= 2) {
|
||||
echo "<p class=\"tourneyCardRight\"><a href=\"/user/$winner2\" class=\"plainLinkBlack\" onclick=\"redirect('this', '/user/$winner2');\">$winner2</a></p>";
|
||||
}
|
||||
echo "<p class=\"newLineThin\"></p>";
|
||||
if ($numPlayers >= 3) {
|
||||
echo ("
|
||||
<p class=\"tourneyCardLeft\"></p>
|
||||
<p class=\"tourneyCardRight\"><a href=\"/user/$winner3\" class=\"plainLinkBlack\" onclick=\"redirect('this', '/user/$winner3');\">$winner3</a></p>
|
||||
<p class=\"newLineThin\"></p>");
|
||||
}
|
||||
if ($numPlayers == 4) {
|
||||
echo ("
|
||||
<p class=\"tourneyCardLeft\"></p>
|
||||
<p class=\"tourneyCardRight\"><a href=\"/user/$winner4\" class=\"plainLinkBlack\" onclick=\"redirect('this', '/user/$winner4');\">$winner4</a></p>
|
||||
<p class=\"newLineThin\"></p>");
|
||||
}
|
||||
echo ("</div>
|
||||
<p class=\"newLineThin\"> </p>
|
||||
");
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
||||
</html>
|
Loading…
x
Reference in New Issue
Block a user