From 4a0199cda6ac523849770923464c38f1b7909c99 Mon Sep 17 00:00:00 2001 From: RochesterX Date: Wed, 26 Nov 2025 22:52:05 -0500 Subject: [PATCH] Filter --- public/assets/css/style.css | 2 +- public/player.html | 2 +- public/search.html | 22 ++++++++++++++++++++++ public/search.js | 11 ++++++++++- server.js | 8 ++++++-- 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/public/assets/css/style.css b/public/assets/css/style.css index ae459c9..12b81d6 100644 --- a/public/assets/css/style.css +++ b/public/assets/css/style.css @@ -294,7 +294,7 @@ p { } .mark { - width: 24px; + width: 32px; height: 24px; border: 2px solid #606060; border-radius: 4px; diff --git a/public/player.html b/public/player.html index 48e0e82..67056b1 100644 --- a/public/player.html +++ b/public/player.html @@ -14,7 +14,7 @@ Name ID - Salary + Contract Team Position diff --git a/public/search.html b/public/search.html index 2fb76fc..aec02cd 100644 --- a/public/search.html +++ b/public/search.html @@ -21,6 +21,28 @@

Search players by name:

+ + +
+ + + + +
+ + diff --git a/public/search.js b/public/search.js index 8c3312b..15627b8 100644 --- a/public/search.js +++ b/public/search.js @@ -15,9 +15,18 @@ updateTableVisibility(); if (searchForm)searchForm.onsubmit = async e => { e.preventDefault(); if (!verifyLogin()) return; + + const formData = new FormData(searchForm); + + let positions = formData.getAll("days"); + + while (positions.length !== 4) { + positions.push("NOPE"); + } let resultObject = await postData("/getPlayers", { - player: document.getElementById("query").value + player: document.getElementById("query").value, + positions: positions }, token); if (resultObject.matches.length === 0) { diff --git a/server.js b/server.js index 11b480c..16bf5ce 100644 --- a/server.js +++ b/server.js @@ -161,11 +161,15 @@ app.post("/toggleWatched", authenticate, async (req, res) => { }); app.post("/getPlayers", authenticate, async (req, res) => { - const { player } = req.body; + const { player, positions } = req.body; const result = await pool.request() .input("query", sql.VarChar, player) - .query(`SELECT p.PlayerID, p.PlayerName, c.TotalValue, p.Team, p.Position FROM Player AS p JOIN Contract AS c ON p.PlayerID = c.PlayerID WHERE p.PlayerName LIKE '%' + @query + '%'`); + .input("one", sql.VarChar, positions[0]) + .input("two", sql.VarChar, positions[1]) + .input("three", sql.VarChar, positions[2]) + .input("four", sql.VarChar, positions[3]) + .query(`SELECT p.PlayerID, p.PlayerName, c.TotalValue, p.Team, p.Position FROM Player AS p JOIN Contract AS c ON p.PlayerID = c.PlayerID WHERE p.PlayerName LIKE '%' + @query + '%' AND p.Position IN (@one, @two, @three, @four);`); res.status(200).json({ query: player, matches: result.recordset }); });