Changed the games form so that it will now auto-fill no matter how many players are selected (not just the original two)

Added new hidden tag to primary.css which allows us to hide content we don't need right now
This commit is contained in:
Taylor Courage 2025-03-08 11:28:55 -05:00
parent 8d2cca0438
commit 8d57b4b721
4 changed files with 55 additions and 25 deletions

View File

@ -20,7 +20,6 @@
$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);
echo "<p>Connected successfully</p>";
// Need to check if values were sent over POST, otherwise set to N/A
@ -49,25 +48,23 @@
} else {
$orangePlayer1 = "N/A";
}
if (isset($_POST["orangePlayer2"])) {
$orangePlayer2 = $_POST["orangePlayer2"];
} else {
$orangePlayer2 = "N/A";
}
if (isset($_POST["orangePlayer3"])) {
$orangePlayer3 = $_POST["orangePlayer3"];
} else {
$orangePlayer3 = "N/A";
}
if (isset($_POST["orangePlayer4"])) {
$orangePlayer4 = $_POST["orangePlayer4"];
} else {
$orangePlayer4 = "N/A";
}
// Grab values from POST
$gameName = $_POST["gameName"];
$gameDate = $_POST["gameDate"];
$numPlayers = $_POST["numPlayers"];
@ -75,23 +72,15 @@
$blueTeamName = $_POST["blueTeamName"];
$orangeScore = $_POST["orangeScore"];
$orangeTeamName = $_POST["orangeTeamName"];
/*
$bluePlayer1 = $_POST["bluePlayer1"];
$bluePlayer2 = $_POST["bluePlayer2"];
$bluePlayer3 = $_POST["bluePlayer3"];
$bluePlayer4 = $_POST["bluePlayer4"];
$orangePlayer1 = $_POST["orangePlayer1"];
$orangePlayer2 = $_POST["orangePlayer2"];
$orangePlayer3 = $_POST["orangePlayer3"];
$orangePlayer4 = $_POST["orangePlayer4"];
*/
$tourneyName = $_POST["tourneyName"];
$ballchasingID = $_POST["ballchasingID"];
$tourneyName = $_POST["tourneyName"];
$notes = $_POST["notes"];
// Get the uploader's information from the SESSION variables
$uploadedBy = $_SESSION["username"];
$uploadedByID = $_SESSION["userID"];
// Get winning team
if ($blueScore > $orangeScore) {
$winningTeam = "blue";
} elseif ($blueScore < $orangeScore) {
@ -100,7 +89,20 @@
$winningTeam = $_POST["winners"];
}
// Check if we got a ballchasing URL or ID
if (!filter_var($ballchasingID, FILTER_VALIDATE_URL)) {
// NOT A LINK
// DO NOTHING - KEEP THE ID
} else {
// IS A LINK
// Strip the URL and path to get the raw ID
$ballchasingPath = parse_url($ballchasingID, PHP_URL_PATH);
list($urlPathBlank, $replaysPath, $ballchasingID) = explode("/", $ballchasingPath);
}
// SQL Query to insert data
$insert = $conn->prepare("INSERT INTO " . $gameDataTableName . " (
gameName,
gameDate,
@ -148,6 +150,7 @@
)");
// Assign variables to SQL command/preparation
$insert->bindValue(":gameName", $gameName);
$insert->bindValue(":gameDate", $gameDate);
$insert->bindValue(":uploadedBy", $uploadedBy);
@ -174,7 +177,9 @@
$insert->execute();
echo "Successfully uploaded new game record";
echo "<div class=\"userMessage\">";
echo "<p>Successfully uploaded new game record</p>";
echo "</div>";
} catch (PDOException $e) { // failed connection
echo "Connection failed: " . $e->getMessage();

View File

@ -65,15 +65,14 @@ try { // Try opening the SQL database connection
<link rel="stylesheet" href="/styles/admin_nav.css" />
<link rel="stylesheet" href="/styles/game_management.css" />
<link rel="stylesheet" href="https://code.jquery.com/ui/1.14.1/themes/base/jquery-ui.css">
<script src="/scripts/game_management.js"></script>
<script src="/scripts/tools.js"></script>
<script src="https://code.jquery.com/jquery-3.7.1.js"></script>
<script src="https://code.jquery.com/ui/1.14.1/jquery-ui.js"></script>
<script src="/scripts/game_management.js"></script>
<script src="/scripts/tools.js"></script>
<title>GAME ADDING FORM</title>
<script>
$( function() {
var userList = <?php echo json_encode($userList); ?>;
$(".playerInput").autocomplete({
source: userList,
});
@ -114,7 +113,7 @@ try { // Try opening the SQL database connection
</div>
<div class="optionsArea">
<label for="numPlayers">Players:</label>
<select id="numPlayers" name="numPlayers" tabindex="1" onchange="addPlayers()">
<select id="numPlayers" name="numPlayers" tabindex="1" onchange="changePlayers()">
<option value="1">1v1</option>
<option value="2" selected="selected">2v2</option>
<option value="3">3v3</option>
@ -138,7 +137,7 @@ try { // Try opening the SQL database connection
<p class="newLine">If this game was part of a tournament, select it below</p>
<input type="text" name="tourneyName" id="tourneyName" maxlength="150" tabindex="4">
<p class="newLine">If you have uploaded a replay of this game to <a href="#" onclick="redirect('ballchasing', 'https://ballchasing.com')" class="plainLinkBlue">ballchasing.com</a>, enter the ID code below.</p>
<input type="text" name="ballchasingID" id="ballchasingID" maxlength="50" tabindex="4">
<input type="text" name="ballchasingID" id="ballchasingID" maxlength="100" tabindex="4">
<p class="newLine"></p>
<p>If you have any notes about the game, leave them below</p>
<textarea name="notes" id="notes" tabindex="4"></textarea>

View File

@ -53,15 +53,37 @@ function addPlayers(){
playerSubHeader.innerHTML = "<p class=\"tableSubHeader\">PLAYER</p>";
awaySubHeader.innerHTML = "<p class=\"tableSubHeader\">AWAY</p>";
// Finally create the appropriate number of rows for players, based on the user input
for (var i = 1; i <= numberPlayers; i++) {
// Create the number of rows for players
for (var i = 1; i <= 4; i++) {
row = playerDataTable.insertRow(-1);
var bluePlayer = row.insertCell(0);
var playerNum = row.insertCell(1);
var orangePlayer = row.insertCell(2);
bluePlayer.innerHTML = "<input type=\"text\" name=\"bluePlayer" + i + "\" id=\"" + i + "\" class=\"playerInput\" maxlength=\"30\" tabindex=\"2\">";
bluePlayer.innerHTML = "<input type=\"text\" name=\"bluePlayer" + i + "\" id=\"bluePlayer" + i + "\" class=\"playerInput\" maxlength=\"30\" tabindex=\"2\">";
playerNum.innerHTML = "- " + i + " -";
orangePlayer.innerHTML = "<input type=\"text\" name=\"orangePlayer" + i + "\" id=\"" + i + "\" class=\"playerInput\" maxlength=\"30\" tabindex=\"3\">";
orangePlayer.innerHTML = "<input type=\"text\" name=\"orangePlayer" + i + "\" id=\"orangePlayer" + i + "\" class=\"playerInput\" maxlength=\"30\" tabindex=\"3\">";
row.id = "row" + i;
row.classList.add("hidden");
}
for (var i = 1; i <= numberPlayers; i++) {
document.getElementById("row" + i).classList.remove("hidden");
}
console.log(userList);
}
function changePlayers() {
// Changes the number of players displayed
var numberPlayers = document.getElementById("numPlayers").value;
for (var i = 1; i <= 4; i++) {
document.getElementById("row" + i).classList.add("hidden");
}
for (var i = 1; i <= numberPlayers; i++) {
document.getElementById("row" + i).classList.remove("hidden");
}
}

View File

@ -8,6 +8,10 @@
cursor: default;
}
.hidden {
visibility: hidden;
}
#body {
background-image: linear-gradient(to right, rgba(0, 0, 255, .8), rgba(255, 165, 0, .8));
padding-top: 2%;