diff --git a/public/assets/css/style.css b/public/assets/css/style.css index f81e833..4c946c8 100644 --- a/public/assets/css/style.css +++ b/public/assets/css/style.css @@ -13,6 +13,7 @@ body { display: flex; flex-direction: column; justify-content: flex-start; + table-layout: auto; } .header { @@ -58,6 +59,45 @@ body { grid-area: sw; } +.cursor-question { + cursor: help; + + position: relative; + display: inline-block; +} + +.cursor-question .tooltip-text { + visibility: hidden; + font: 16px tahoma, sans-serif; + width: 200px; + background-color: #0C0C0C; + border: 2px solid #EEEEEE; + color: #EEEEEE; + text-align: left; + border-radius: 6px; + padding: 5px; + padding-left: 8px; + padding-right: 8px; + z-index: 1; + position: absolute; + top: 110%; + left: 50%; + transform: translate(-50%, 20px); + opacity: 0; + transition: opacity 0.3s ease-out, transform 0.3s ease-out; + font-size: 14px; +} + +.cursor-question:hover { + text-decoration: underline; +} + +.cursor-question:hover .tooltip-text { + visibility: visible; + transform: translate(-50%, 0px); + opacity: 1; +} + .box { border: 2px solid #AAAAAA; border-radius: 16px; @@ -69,11 +109,46 @@ body { justify-content: flex-start; text-justify: center; gap: 5px; + overflow: hidden; +} + +.box table { + width: 100%; +} + +.box tbody { + display: block; + overflow-y: auto; + overflow-x: hidden; + max-height: calc((100vh - 100px) / 2 - 100px); +} + +.box thead, +.box tbody tr { + display: table; + width: 100%; + table-layout: fixed; +} + +.box table td:first-child, +.box table th:first-child { + width: 35px; + white-space: nowrap; +} + +.box table thead td { + font-weight: bold; +} + +.box table td:nth-child(2), +.box table th:nth-child(2) { + width: 50px; + white-space: nowrap; } .grid-container { display: grid; - grid-template-columns: 50px, 50px; + grid-template-columns: 1fr 1fr; grid-template-rows: auto; grid-template-areas: "header header" @@ -287,12 +362,12 @@ a:focus { table { border-collapse: collapse; - border: 2px solid #CCCCCC; + border: 1px solid #CCCCCC; } thead { color: #FFFFFF; - border: 2px solid #CCCCCC; + /*border: 2px solid #CCCCCC;*/ } thead th { diff --git a/public/home.js b/public/home.js index 807c5fd..d9df785 100644 --- a/public/home.js +++ b/public/home.js @@ -24,7 +24,7 @@ async function updateOffense() { const offenseBody = document.querySelector("#offense tbody"); - let resultObject = await postData("/getHighestOffense", { amount: 10 }, token); + let resultObject = await postData("/getHighestOffense", { amount: 100 }, token); console.log(resultObject); if (resultObject.matches.length === 0) { @@ -38,6 +38,7 @@ async function updateOffense() { // headerRow.innerHTML += `
Height:
- +Weight:
- + +PayDirt Score:
+ A player's PayDirt score is calculated by weighting their offense score by their APY. It is used to evaluate the worth of their contract. +Offense Score:
+ A player's offense score is calculated by combining several of their offense stats into a weighted score. It is indicative of their overall performance. +| ${player} | l`; //} rowElement.innerHTML = ` -${row.Season} | +${row.season} | ${row.SeasonType === "REG" ? "Regular" : "Post"} | -${row.Week} | +${row.week} | ${row.pass_attempts} | ${row.complete_pass} | ${row.total_yards} | diff --git a/server.js b/server.js index e25aeec..5f28345 100644 --- a/server.js +++ b/server.js @@ -250,8 +250,8 @@ app.post("/getPlayerStats", authenticate, async (req, res) => { const result = await pool.request() .input("playerID", sql.Int, playerID) .query(` -SELECT Player.PlayerID, Player.PlayerName, Season, SeasonType, Week, pass_attempts, complete_pass, total_yards, total_tds, interception, receptions, receiving_yards, receiving_touchdown, rush_attempts, rushing_yards, rush_touchdown, fumble -FROM Player JOIN DatasetPlayerStats ON Player.PlayerID = DatasetPlayerStats.PlayerID +SELECT player.playerid, player.playername, season, seasontype, week, pass_attempts, complete_pass, total_yards, total_tds, interception, receptions, receiving_yards, receiving_touchdown, rush_attempts, rushing_yards, rush_touchdown, fumble +fROM Player JOIN DatasetPlayerStats ON Player.PlayerID = DatasetPlayerStats.PlayerID WHERE Player.PlayerID = @playerID ORDER BY Season, week; `); @@ -266,6 +266,7 @@ app.post("/getPlayerScores", authenticate, async (req, res) => { .input("playerID", sql.Int, playerID) .query(` SELECT Player.PlayerID, Player.[Position], Player.PlayerName, Player.Team, +c.TotalValue, c.TrueAvgPerYear, c.Years, c.StartYear, c.EndYear, Player.Height, Player.Weight, SUM(total_yards) AS TotalYards, SUM(passing_yards) AS PassingYards, SUM(rushing_yards) AS RushingYards, @@ -306,13 +307,14 @@ AvgPerYear, - (SUM(safety) * 100.0)) / AvgPerYear * 1000000 AS PaydirtScore -FROM Player JOIN DatasetPlayerStats ON Player.PlayerID = DatasetPlayerStats.PlayerID JOIN Contract ON Player.PlayerID = Contract.PlayerID +FROM Player JOIN DatasetPlayerStats ON Player.PlayerID = DatasetPlayerStats.PlayerID JOIN Contract AS c ON Player.PlayerID = c.PlayerID WHERE season = 2024 AND SeasonType = 'REG' AND Player.PlayerID = @playerID -GROUP BY Player.PlayerID, Player.PlayerName, Player.Team, Player.[Position], Contract.AvgPerYear +GROUP BY c.TotalValue, c.TrueAvgPerYear, c.Years, c.StartYear, Player.Height, Player.Weight, c.EndYear, Player.PlayerID, Player.PlayerName, Player.Team, Player.[Position], c.AvgPerYear ORDER BY PaydirtScore DESC; `); + console.log(result.recordset); - res.status(200).json({ matches: result.recordset }); + res.status(200).json({ match: result.recordset[0] }); }); @@ -378,7 +380,7 @@ app.post("/getPlayer", authenticate, async (req, res) => { const result = await pool.request() .input("query", sql.VarChar, id) - .query(`SELECT p.PlayerName, p.PlayerID, c.TotalValue, c.TrueAvgPerYear, c.Years, c.StartYear, c.EndYear, p.Team, p.Position, p.Height, p.Weight FROM Player AS p JOIN Contract AS c ON p.PlayerID = c.PlayerID WHERE p.PlayerID = @query`); + .query(`SELECT p.PlayerName, p.PlayerID, c.TotalValue, c.TrueAvgPerYear, c.Years, c.StartYear, c.EndYear, p.Team, p.Position FROM Player AS p JOIN Contract AS c ON p.PlayerID = c.PlayerID WHERE p.PlayerID = @query`); if (result.recordset.length !== 1) { res.status(400).json({ success: false })