This commit is contained in:
RochesterX
2025-11-18 21:16:35 -05:00
parent 908129e38f
commit 9e88712e9f
21 changed files with 235 additions and 120 deletions

View File

@@ -1,4 +1,5 @@
import { postData, verifyLogin } from "./client.js";
import { formatSalary } from "./utils.js";
const searchForm = document.getElementById("searchForm");
@@ -15,7 +16,7 @@ if (searchForm)searchForm.onsubmit = async e => {
e.preventDefault();
if (!verifyLogin()) return;
let resultObject = await postData("https://project.rochesterx.dev/getPlayers", {
let resultObject = await postData("/getPlayers", {
player: document.getElementById("query").value
}, token);
@@ -42,7 +43,7 @@ if (searchForm)searchForm.onsubmit = async e => {
//}
row.innerHTML = `
<td>${player.player_id}</td>
<td>${player.player_name}</td>
<td><a href="/player/${player.player_id}">${player.player_name}</a></td>
<td>${formatSalary(player.salary)}</td>
<td>${player.team_name}</td>
<td>${player.position}</td>
@@ -56,7 +57,6 @@ function updateTableVisibility() {
if (!tableBody) return;
const rows = tableBody.querySelectorAll("tr");
console.log(rows);
if (rows == null) return;
if (rows.length != 0) {
table.style.display = "";
@@ -64,45 +64,3 @@ function updateTableVisibility() {
table.style.display = "none";
}
}
function formatText(text) {
if (text == null) return "—";
if (typeof(text) === "string") {
return text;
}
else {
return "Unknown format";
}
}
function formatSalary(text) {
if (text == null) return "—";
try {
var millions = (parseInt(text, 10) / 1000000).toFixed(2);
return `$${millions} million`;
} catch (e) {
return "Unknown format"
}
}
function formatDate(date) {
if (date == null) return "—";
if (typeof(date) === "string") {
return date.split("T")[0];
}
else {
return "Unknown format";
}
}
function formatDateTime(date) {
if (date == null) return "—";
if (typeof(date) === "string") {
return date.split("T")[0] + " at " + date.split("T")[1].split(".")[0];
}
else {
return "Unknown format";
}
}