Merge branch 'main1' into test
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
let wins = parseInt(localStorage.getItem("wins")) || 0;
|
||||
let losses = parseInt(localStorage.getItem("losses")) || 0;
|
||||
|
||||
const choices = document.querySelectorAll(".choice");
|
||||
const msg = document.querySelector("#msg");
|
||||
|
||||
const winsPara = document.querySelector("#wins");
|
||||
const lossesPara = document.querySelector("#losses");
|
||||
|
||||
// Initialize the UI with saved values
|
||||
winsPara.innerText = wins;
|
||||
lossesPara.innerText = losses;
|
||||
|
||||
const genCompChoice = () => {
|
||||
const options = ["rock", "paper", "scissors"];
|
||||
const randIdx = Math.floor(Math.random() * 3);
|
||||
return options[randIdx];
|
||||
};
|
||||
|
||||
const drawGame = () => {
|
||||
msg.innerText = "Game was Draw. Play again.";
|
||||
msg.style.backgroundColor = "#081b31";
|
||||
};
|
||||
|
||||
const showWinner = (userWin, userChoice, compChoice) => {
|
||||
if (userWin) {
|
||||
wins++;
|
||||
localStorage.setItem("wins", wins); // Save wins to localStorage
|
||||
winsPara.innerText = wins;
|
||||
msg.innerText = `You win! Your ${userChoice} beats ${compChoice}`;
|
||||
msg.style.backgroundColor = "green";
|
||||
} else {
|
||||
losses++;
|
||||
localStorage.setItem("losses", losses); // Save losses to localStorage
|
||||
lossesPara.innerText = losses;
|
||||
msg.innerText = `You lost. ${compChoice} beats your ${userChoice}`;
|
||||
msg.style.backgroundColor = "red";
|
||||
}
|
||||
};
|
||||
|
||||
const playGame = (userChoice) => {
|
||||
//Generate computer choice
|
||||
const compChoice = genCompChoice();
|
||||
|
||||
if (userChoice === compChoice) {
|
||||
//Draw Game
|
||||
drawGame();
|
||||
} else {
|
||||
let userWin = true;
|
||||
if (userChoice === "rock") {
|
||||
//scissors, paper
|
||||
userWin = compChoice === "paper" ? false : true;
|
||||
} else if (userChoice === "paper") {
|
||||
//rock, scissors
|
||||
userWin = compChoice === "scissors" ? false : true;
|
||||
} else {
|
||||
//rock, paper
|
||||
userWin = compChoice === "rock" ? false : true;
|
||||
}
|
||||
showWinner(userWin, userChoice, compChoice);
|
||||
}
|
||||
};
|
||||
|
||||
choices.forEach((choice) => {
|
||||
choice.addEventListener("click", () => {
|
||||
const userChoice = choice.getAttribute("id");
|
||||
playGame(userChoice);
|
||||
});
|
||||
});
|
||||
@@ -130,6 +130,20 @@
|
||||
.event-details .save-button:hover {
|
||||
background: #45a049;
|
||||
}
|
||||
.event-details #close-details {
|
||||
background: #f44336;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
font-size: 1em;
|
||||
margin-top: 10px;
|
||||
transition: background 0.3s;
|
||||
}
|
||||
.event-details #close-details:hover {
|
||||
background: #d32f2f;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -182,6 +196,39 @@
|
||||
'2025-05-04': 'Gay Day'
|
||||
};
|
||||
|
||||
function setCookie(name, value, days) {
|
||||
const date = new Date();
|
||||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
||||
const expires = `expires=${date.toUTCString()}`;
|
||||
document.cookie = `${name}=${value};${expires};path=/`;
|
||||
}
|
||||
|
||||
function getCookie(name) {
|
||||
const nameEQ = `${name}=`;
|
||||
const cookies = document.cookie.split(';');
|
||||
for (let i = 0; i < cookies.length; i++) {
|
||||
let cookie = cookies[i].trim();
|
||||
if (cookie.indexOf(nameEQ) === 0) {
|
||||
return cookie.substring(nameEQ.length, cookie.length);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function saveCurrentMonthYear(month, year) {
|
||||
setCookie('calendarMonth', month, 30);
|
||||
setCookie('calendarYear', year, 30);
|
||||
}
|
||||
|
||||
function loadSavedMonthYear() {
|
||||
const savedMonth = getCookie('calendarMonth');
|
||||
const savedYear = getCookie('calendarYear');
|
||||
if (savedMonth !== null && savedYear !== null) {
|
||||
currentMonth = parseInt(savedMonth, 10);
|
||||
currentYear = parseInt(savedYear, 10);
|
||||
}
|
||||
}
|
||||
|
||||
function renderCalendar(month, year) {
|
||||
const firstDay = new Date(year, month, 1).getDay();
|
||||
const daysInMonth = new Date(year, month + 1, 0).getDate();
|
||||
@@ -212,6 +259,11 @@
|
||||
const eventText = events[dateKey] || 'No event selected.';
|
||||
eventDate.textContent = `Date: ${dateKey}`;
|
||||
eventDescription.textContent = eventText;
|
||||
eventDescription.className = ''; // Clear previous class
|
||||
if (eventText !== 'No event selected.') {
|
||||
const sanitizedClassName = eventText.replace(/[^a-zA-Z0-9-]/g, '').replace(/\s+/g, '-').toLowerCase();
|
||||
eventDescription.classList.add(sanitizedClassName); // Set sanitized class name based on event name
|
||||
}
|
||||
eventDetails.classList.add('active'); // Show sidebar
|
||||
}
|
||||
|
||||
@@ -225,6 +277,7 @@
|
||||
currentMonth = 11;
|
||||
currentYear--;
|
||||
}
|
||||
saveCurrentMonthYear(currentMonth, currentYear);
|
||||
renderCalendar(currentMonth, currentYear);
|
||||
});
|
||||
|
||||
@@ -234,10 +287,14 @@
|
||||
currentMonth = 0;
|
||||
currentYear++;
|
||||
}
|
||||
saveCurrentMonthYear(currentMonth, currentYear);
|
||||
renderCalendar(currentMonth, currentYear);
|
||||
});
|
||||
|
||||
loadSavedMonthYear();
|
||||
renderCalendar(currentMonth, currentYear);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<div class="Gay Day">hi mom</div>
|
||||
<p class="Gay Day">hi mom</p>
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
+62
@@ -114,6 +114,7 @@
|
||||
<button class="button" id="gamesComingSoonButton" onclick="location.href='./gametoadd.html'">Coming Soon</button>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Calendar Button -->
|
||||
<button class="calendar-button" onclick="location.href='cal.html'">Calendar</button>
|
||||
|
||||
@@ -137,6 +138,7 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// Apply dark or light mode based on cookie
|
||||
function applyDarkMode(enabled) {
|
||||
if (enabled) {
|
||||
@@ -169,6 +171,66 @@
|
||||
// Apply saved mode on load
|
||||
const darkModeEnabled = getCookie('darkMode') === 'true';
|
||||
applyDarkMode(darkModeEnabled);
|
||||
|
||||
// Clock Functionality
|
||||
function updateClock() {
|
||||
const now = new Date();
|
||||
const hours = String(now.getHours()).padStart(2, '0');
|
||||
const minutes = String(now.getMinutes()).padStart(2, '0');
|
||||
const seconds = String(now.getSeconds()).padStart(2, '0');
|
||||
const timeString = `${hours}:${minutes}:${seconds}`;
|
||||
const dateString = now.toDateString(); // Get the current date as a string
|
||||
document.getElementById('clock').innerHTML = `${dateString} <br> ${timeString}`;
|
||||
}
|
||||
|
||||
// Update the clock every second
|
||||
setInterval(updateClock, 1000);
|
||||
updateClock(); // Initialize clock immediately
|
||||
|
||||
// Ensure FPS Counter is enabled by default
|
||||
if (getCookie('fpsCounter') === null) {
|
||||
setCookie('fpsCounter', 'true', 30); // Default to enabled
|
||||
}
|
||||
|
||||
// Check if FPS Counter is enabled
|
||||
const fpsCounterEnabled = getCookie('fpsCounter') === 'true';
|
||||
|
||||
if (fpsCounterEnabled) {
|
||||
const fpsCounter = document.getElementById('fpsCounter');
|
||||
let lastFrameTime = performance.now();
|
||||
let frames = 0;
|
||||
|
||||
function calculateFPS() {
|
||||
const now = performance.now();
|
||||
frames++;
|
||||
|
||||
if (now - lastFrameTime >= 1000) {
|
||||
const fps = Math.round(frames / ((now - lastFrameTime) / 1000));
|
||||
fpsCounter.textContent = `FPS: ${fps}`;
|
||||
frames = 0;
|
||||
lastFrameTime = now;
|
||||
}
|
||||
|
||||
requestAnimationFrame(calculateFPS);
|
||||
}
|
||||
|
||||
calculateFPS(); // Start FPS calculation
|
||||
}
|
||||
|
||||
// Check if Date and Time is enabled
|
||||
const dateTimeEnabled = getCookie('dateTime') === 'true';
|
||||
|
||||
if (dateTimeEnabled) {
|
||||
document.getElementById('clock').style.display = 'block'; // Show the clock
|
||||
}
|
||||
|
||||
// Check if "Games Coming Soon" is enabled
|
||||
const gamesComingSoonEnabled = getCookie('gamesComingSoon') === 'true';
|
||||
|
||||
if (gamesComingSoonEnabled) {
|
||||
document.getElementById('gamesComingSoonButton').style.display = 'inline-block'; // Show the button
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
+3
-2
@@ -137,10 +137,10 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
// Dark Mode Toggle
|
||||
// Remove the toggle button from other pages
|
||||
const toggleDarkModeButton = document.getElementById('toggleDarkMode');
|
||||
const darkModeEnabled = getCookie('darkMode') === 'true';
|
||||
|
||||
// Ensure this button is the only one controlling dark mode
|
||||
function applyDarkMode(enabled) {
|
||||
if (enabled) {
|
||||
document.body.style.setProperty('--background-color', '#121212');
|
||||
@@ -162,6 +162,7 @@
|
||||
});
|
||||
|
||||
// Apply saved dark mode preference on load
|
||||
const darkModeEnabled = getCookie('darkMode') === 'true';
|
||||
applyDarkMode(darkModeEnabled);
|
||||
|
||||
// Clear Cookies Button
|
||||
|
||||
Reference in New Issue
Block a user