116 lines
3.2 KiB
JavaScript
116 lines
3.2 KiB
JavaScript
event_id = "292333461";
|
|
event_id_2 = "292333462";
|
|
team_id = "6882652";
|
|
|
|
function format_stat(number) {
|
|
const zeroPad = (num, places) => String(num).padStart(3, "0");
|
|
return zeroPad(Math.round(number * 1000), 3);
|
|
}
|
|
|
|
async function load_data_xxx() {
|
|
const event_id = document.querySelector('input[name="event_id"]').value;
|
|
const team_id = document.querySelector('input[name="team_id"]').value;
|
|
update_card(team_id, event_id);
|
|
}
|
|
|
|
async function update_card(team_id, event_id) {
|
|
fetch(`/${team_id}/event/${event_id}/gamecard/data`, {
|
|
method: "GET",
|
|
headers: {
|
|
Accept: "application/json",
|
|
},
|
|
})
|
|
.then((response) => response.json())
|
|
.then(function (items) {
|
|
console.log(items);
|
|
events = items.filter(function (item) {
|
|
return item.type == "event";
|
|
});
|
|
event_index = events.findIndex(function (e) {
|
|
return e.id == event_id;
|
|
});
|
|
event = events[event_index];
|
|
document.title = event.formattedTitle;
|
|
|
|
document.querySelectorAll(".event-title").forEach(function (element) {
|
|
element.innerText = event.formattedTitle;
|
|
});
|
|
|
|
document.querySelectorAll(".event-label").forEach(function (element) {
|
|
element.innerText = event.label;
|
|
});
|
|
|
|
document
|
|
.querySelectorAll(".event-location-name")
|
|
.forEach(function (element) {
|
|
element.innerText = event.locationName;
|
|
});
|
|
|
|
document.querySelectorAll(".opponent").forEach(function (element) {
|
|
element.innerText = event.opponentName;
|
|
});
|
|
|
|
document.querySelectorAll(".homeaway").forEach(function (element) {
|
|
element.innerText = event.gameType;
|
|
});
|
|
|
|
document.querySelectorAll(".event-date").forEach(function (element) {
|
|
element.innerText = new Date(event.startDate).toLocaleDateString(
|
|
"en-us",
|
|
{
|
|
weekday: "short",
|
|
day: "numeric",
|
|
// year: "numeric",
|
|
month: "short",
|
|
}
|
|
);
|
|
});
|
|
|
|
document.querySelectorAll(".event-time").forEach(function (element) {
|
|
element.innerText = new Date(event.startDate).toLocaleTimeString(
|
|
"en-us",
|
|
{
|
|
hour: "numeric",
|
|
minute: "2-digit",
|
|
}
|
|
);
|
|
});
|
|
|
|
document.getElementById("todays-game-header").innerText =
|
|
event.formattedTitle +
|
|
" - " +
|
|
new Date(event.startDate).toLocaleDateString("en-us", {
|
|
weekday: "short",
|
|
day: "numeric",
|
|
// year: "numeric",
|
|
month: "short",
|
|
}) +
|
|
" " +
|
|
new Date(event.startDate).toLocaleTimeString("en-us", {
|
|
hour: "numeric",
|
|
minute: "2-digit",
|
|
});
|
|
|
|
for (let j = -4; j < 5; j++) {
|
|
if (j < 0) {
|
|
plus_minus = "minus";
|
|
} else if (j > 0) {
|
|
plus_minus = "plus";
|
|
} else {
|
|
continue;
|
|
}
|
|
document.querySelector(
|
|
`th.today-${plus_minus}-${Math.abs(j)} div`
|
|
).textContent = new Date(
|
|
events[event_index + j].startDate
|
|
).toLocaleDateString("en-us", {
|
|
weekday: "short",
|
|
});
|
|
}
|
|
console.log({
|
|
0: events[event_index],
|
|
1: events[event_index + 1],
|
|
});
|
|
});
|
|
}
|