Fixes to file structure
This commit is contained in:
73
public/assets/js/club-page/favorite-button.js
Normal file
73
public/assets/js/club-page/favorite-button.js
Normal file
@@ -0,0 +1,73 @@
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
var favoriteButton = document.getElementById("club-favorite-button");
|
||||
if (favoriteButton) {
|
||||
favoriteButton.addEventListener("click", function() {
|
||||
var userID = document.getElementById("userID").value;
|
||||
var teamID = document.getElementById("teamID").value;
|
||||
var teamName = document.getElementById("teamName").value;
|
||||
var teamLogo = document.getElementById("teamLogo").value;
|
||||
|
||||
if (favoriteButton.src.includes("/favorited.png")) {
|
||||
removeFavoriteTeam(userID, teamID);
|
||||
} else {
|
||||
addFavoriteTeam(userID, teamID, teamName, teamLogo);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
async function addFavoriteTeam(userID, teamID, teamName, teamLogo){
|
||||
try {
|
||||
const response = await fetch('/favteam/add', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
userID: userID,
|
||||
teamID: teamID,
|
||||
teamName: teamName,
|
||||
teamLogo: teamLogo
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to add favorite team');
|
||||
}
|
||||
|
||||
if (response.status === 200) {
|
||||
console.log('New favorite team added successfully.');
|
||||
var favoriteButton = document.getElementById("club-favorite-button");
|
||||
favoriteButton.src = "/img/club-page/favorited.png";
|
||||
location.reload(); // Refresh the page
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error adding favorite team:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function removeFavoriteTeam(userID, teamID) {
|
||||
try {
|
||||
const response = await fetch('/favteam/remove', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
userID: userID,
|
||||
teamID: teamID
|
||||
})
|
||||
});
|
||||
|
||||
if (response.status === 200) {
|
||||
console.log('Favorite team removed successfully.');
|
||||
var favoriteButton = document.getElementById("club-favorite-button");
|
||||
favoriteButton.src = "/img/club-page/unfavorited.png";
|
||||
location.reload(); // Refresh the page
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error removing favorite team:', error);
|
||||
}
|
||||
}
|
||||
0
public/assets/js/club-page/player-card-hover.js
Normal file
0
public/assets/js/club-page/player-card-hover.js
Normal file
29
public/assets/js/league-page/change-goal-difference-color.js
Normal file
29
public/assets/js/league-page/change-goal-difference-color.js
Normal file
@@ -0,0 +1,29 @@
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
var goalDifferenceCells = document.querySelectorAll("#league-table-goal-difference-column"); // Selecting the cells in the goal_difference column
|
||||
|
||||
goalDifferenceCells.forEach(function(cell) {
|
||||
var goalDifference = parseInt(cell.textContent);
|
||||
var color;
|
||||
|
||||
if (goalDifference < 0)
|
||||
{
|
||||
// Gradually darken the text color for negative goal differences
|
||||
var darkenFactor = Math.ceil(goalDifference / -10); // Calculate the darken factor
|
||||
var shade = Math.max(0, 255 - darkenFactor * 25); // Calculate the shade of red
|
||||
color = "rgb(" + shade + ", 0, 0)"; // Create the color value
|
||||
}
|
||||
else if (goalDifference > 0)
|
||||
{
|
||||
// Gradually darken the text color for positive goal differences
|
||||
var darkenFactor = Math.floor(goalDifference / 10); // Calculate the darken factor
|
||||
var shade = Math.max(0, 155 - darkenFactor * 15); // Adjusted the starting point to make greens darker
|
||||
color = "rgb(0, " + shade + ", 0)"; // Create the color value
|
||||
}
|
||||
else
|
||||
{
|
||||
color = "inherit"; // If goal difference is 0, leave text color unchanged
|
||||
}
|
||||
|
||||
cell.style.color = color; // Apply the calculated color
|
||||
});
|
||||
});
|
||||
45
public/assets/js/navigation-bar/navigation-bar-follow.js
Normal file
45
public/assets/js/navigation-bar/navigation-bar-follow.js
Normal file
@@ -0,0 +1,45 @@
|
||||
// navbar-sticky.js
|
||||
|
||||
// Function to add sticky behavior to the navbar
|
||||
function makeNavbarSticky() {
|
||||
// Get the navigation bar element
|
||||
var navbar = document.getElementById("navigation-bar-container");
|
||||
var accountPane = document.querySelector(".account-portal-container"); // Use querySelector instead of getElementByClassName
|
||||
|
||||
// Get the initial offset of the navbar from the top of the page
|
||||
var navbarOffset = navbar.offsetTop;
|
||||
|
||||
// Function to add sticky behavior when scrolling
|
||||
function stickyNavbar() {
|
||||
// Check if the current scroll position is greater than or equal to the initial offset of the navbar
|
||||
if (window.pageYOffset >= navbarOffset) {
|
||||
// Add the 'fixed-top' class to make the navbar sticky
|
||||
navbar.classList.add("fixed-top");
|
||||
// Add padding to the body to prevent content from jumping when the navbar becomes sticky
|
||||
document.body.style.paddingTop = navbar.offsetHeight + "px";
|
||||
|
||||
// Adjust the position of the account pane
|
||||
accountPane.style.position = "fixed"; // Make the account pane fixed
|
||||
accountPane.style.top = navbar.offsetHeight + 20 + 'px'; // Move the account pane below the navbar
|
||||
} else {
|
||||
// Remove the 'fixed-top' class to make the navbar non-sticky
|
||||
navbar.classList.remove("fixed-top");
|
||||
// Reset the padding of the body
|
||||
document.body.style.paddingTop = 0;
|
||||
accountPane.style.position = "absolute"; // Make the account pane fixed
|
||||
|
||||
// Set the top position of the account pane to be 150px off the top
|
||||
accountPane.style.top = "160px";
|
||||
}
|
||||
}
|
||||
|
||||
// Call the stickyNavbar function when the page is scrolled
|
||||
window.onscroll = function() {
|
||||
stickyNavbar();
|
||||
};
|
||||
}
|
||||
|
||||
// Call the makeNavbarSticky function when the page loads
|
||||
window.onload = function() {
|
||||
makeNavbarSticky();
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
var deleteButtons = document.querySelectorAll("#account-delete-favorite-team-button-hover");
|
||||
deleteButtons.forEach(function(deleteButton) {
|
||||
deleteButton.addEventListener("click", function() {
|
||||
var userID = deleteButton.getAttribute("userID");
|
||||
var teamID = deleteButton.getAttribute("teamID");
|
||||
|
||||
if (deleteButton.src.includes("/delete-club-hover.png")) {
|
||||
removeAccountFavoriteTeam(userID, teamID);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
async function removeAccountFavoriteTeam(userID, teamID) {
|
||||
try {
|
||||
const response = await fetch('/favteam/remove', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
userID: userID,
|
||||
teamID: teamID
|
||||
})
|
||||
});
|
||||
|
||||
if (response.status === 200) {
|
||||
console.log('Favorite team removed successfully.');
|
||||
location.reload(); // Refresh the page
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error removing favorite team:', error);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
$(document).ready(function() {
|
||||
|
||||
// When #user is clicked
|
||||
$('#user-profile-button').click(function() {
|
||||
|
||||
$('#register-screen-container').hide();
|
||||
// Toggle the visibility of the login container
|
||||
$('#login-pane').toggle();
|
||||
});
|
||||
|
||||
$('#register-page-login-button').click(function (event) {
|
||||
event.preventDefault(); // Prevent the default action of following the link
|
||||
|
||||
$('#register-screen-container').hide();
|
||||
$('#login-pane').show();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
// Listen for click event on the register button
|
||||
$('#register-button').click(function (event) {
|
||||
event.preventDefault(); // Prevent the default action of following the link
|
||||
|
||||
$('#login-pane').hide();
|
||||
// Show the register container
|
||||
$('#register-screen-container').show();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
// When #user is clicked
|
||||
$('#user-profile-button').click(function() {
|
||||
|
||||
// Toggle the visibility of the login container
|
||||
$('#account-pane').toggle();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user