Implement FPS Counter with Cookie Management Across Multiple Games
- Added functionality to display an FPS counter in various games based on a cookie setting. - Introduced a utility function to retrieve cookies and check if the FPS counter is enabled. - Updated the FPS calculation logic to start or hide the counter based on user preferences. - Ensured consistent implementation across multiple HTML files, including games like "Bubble Game", "Basketball Legends", and others. - Enhanced the main index and settings pages to manage FPS counter visibility and added a clock feature.
This commit is contained in:
@@ -46,9 +46,27 @@ function yes(){
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
const fpsCounter = document.getElementById("fps-counter"); // Moved this to the correct place
|
const fpsCounter = document.getElementById("fps-counter");
|
||||||
|
|
||||||
function calculateFPS() {
|
// Utility function to get a cookie
|
||||||
|
function getCookie(name) {
|
||||||
|
const cookies = document.cookie.split(';');
|
||||||
|
for (let i = 0; i < cookies.length; i++) {
|
||||||
|
const cookie = cookies[i].trim();
|
||||||
|
if (cookie.startsWith(name + '=')) {
|
||||||
|
return cookie.substring(name.length + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if FPS Counter is enabled
|
||||||
|
const fpsCounterEnabled = getCookie('fpsCounter') === 'true';
|
||||||
|
|
||||||
|
if (fpsCounterEnabled) {
|
||||||
|
fpsCounter.style.display = 'block'; // Show FPS counter
|
||||||
|
|
||||||
|
function calculateFPS() {
|
||||||
let lastFrameTime = performance.now();
|
let lastFrameTime = performance.now();
|
||||||
let frames = 0;
|
let frames = 0;
|
||||||
|
|
||||||
@@ -65,7 +83,10 @@ function calculateFPS() {
|
|||||||
requestAnimationFrame(frameLoop);
|
requestAnimationFrame(frameLoop);
|
||||||
}
|
}
|
||||||
frameLoop();
|
frameLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateFPS(); // Ensure the FPS calculation starts
|
calculateFPS(); // Start FPS calculation
|
||||||
|
} else {
|
||||||
|
fpsCounter.style.display = 'none'; // Hide FPS counter
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -81,9 +81,27 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
const fpsCounter = document.getElementById("fps-counter"); // Moved this to the correct place
|
const fpsCounter = document.getElementById("fps-counter");
|
||||||
|
|
||||||
function calculateFPS() {
|
// Utility function to get a cookie
|
||||||
|
function getCookie(name) {
|
||||||
|
const cookies = document.cookie.split(';');
|
||||||
|
for (let i = 0; i < cookies.length; i++) {
|
||||||
|
const cookie = cookies[i].trim();
|
||||||
|
if (cookie.startsWith(name + '=')) {
|
||||||
|
return cookie.substring(name.length + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if FPS Counter is enabled
|
||||||
|
const fpsCounterEnabled = getCookie('fpsCounter') === 'true';
|
||||||
|
|
||||||
|
if (fpsCounterEnabled) {
|
||||||
|
fpsCounter.style.display = 'block'; // Show FPS counter
|
||||||
|
|
||||||
|
function calculateFPS() {
|
||||||
let lastFrameTime = performance.now();
|
let lastFrameTime = performance.now();
|
||||||
let frames = 0;
|
let frames = 0;
|
||||||
|
|
||||||
@@ -100,7 +118,10 @@ function calculateFPS() {
|
|||||||
requestAnimationFrame(frameLoop);
|
requestAnimationFrame(frameLoop);
|
||||||
}
|
}
|
||||||
frameLoop();
|
frameLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateFPS(); // Ensure the FPS calculation starts
|
calculateFPS(); // Start FPS calculation
|
||||||
|
} else {
|
||||||
|
fpsCounter.style.display = 'none'; // Hide FPS counter
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
+25
-4
@@ -47,9 +47,27 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
const fpsCounter = document.getElementById("fps-counter"); // Moved this to the correct place
|
const fpsCounter = document.getElementById("fps-counter");
|
||||||
|
|
||||||
function calculateFPS() {
|
// Utility function to get a cookie
|
||||||
|
function getCookie(name) {
|
||||||
|
const cookies = document.cookie.split(';');
|
||||||
|
for (let i = 0; i < cookies.length; i++) {
|
||||||
|
const cookie = cookies[i].trim();
|
||||||
|
if (cookie.startsWith(name + '=')) {
|
||||||
|
return cookie.substring(name.length + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if FPS Counter is enabled
|
||||||
|
const fpsCounterEnabled = getCookie('fpsCounter') === 'true';
|
||||||
|
|
||||||
|
if (fpsCounterEnabled) {
|
||||||
|
fpsCounter.style.display = 'block'; // Show FPS counter
|
||||||
|
|
||||||
|
function calculateFPS() {
|
||||||
let lastFrameTime = performance.now();
|
let lastFrameTime = performance.now();
|
||||||
let frames = 0;
|
let frames = 0;
|
||||||
|
|
||||||
@@ -66,7 +84,10 @@ function calculateFPS() {
|
|||||||
requestAnimationFrame(frameLoop);
|
requestAnimationFrame(frameLoop);
|
||||||
}
|
}
|
||||||
frameLoop();
|
frameLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateFPS(); // Ensure the FPS calculation starts
|
calculateFPS(); // Start FPS calculation
|
||||||
|
} else {
|
||||||
|
fpsCounter.style.display = 'none'; // Hide FPS counter
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -142,9 +142,27 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
const fpsCounter = document.getElementById("fps-counter"); // Moved this to the correct place
|
const fpsCounter = document.getElementById("fps-counter");
|
||||||
|
|
||||||
function calculateFPS() {
|
// Utility function to get a cookie
|
||||||
|
function getCookie(name) {
|
||||||
|
const cookies = document.cookie.split(';');
|
||||||
|
for (let i = 0; i < cookies.length; i++) {
|
||||||
|
const cookie = cookies[i].trim();
|
||||||
|
if (cookie.startsWith(name + '=')) {
|
||||||
|
return cookie.substring(name.length + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if FPS Counter is enabled
|
||||||
|
const fpsCounterEnabled = getCookie('fpsCounter') === 'true';
|
||||||
|
|
||||||
|
if (fpsCounterEnabled) {
|
||||||
|
fpsCounter.style.display = 'block'; // Show FPS counter
|
||||||
|
|
||||||
|
function calculateFPS() {
|
||||||
let lastFrameTime = performance.now();
|
let lastFrameTime = performance.now();
|
||||||
let frames = 0;
|
let frames = 0;
|
||||||
|
|
||||||
@@ -161,7 +179,10 @@ function calculateFPS() {
|
|||||||
requestAnimationFrame(frameLoop);
|
requestAnimationFrame(frameLoop);
|
||||||
}
|
}
|
||||||
frameLoop();
|
frameLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateFPS(); // Ensure the FPS calculation starts
|
calculateFPS(); // Start FPS calculation
|
||||||
|
} else {
|
||||||
|
fpsCounter.style.display = 'none'; // Hide FPS counter
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
+25
-4
@@ -38,9 +38,27 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
const fpsCounter = document.getElementById("fps-counter"); // Moved this to the correct place
|
const fpsCounter = document.getElementById("fps-counter");
|
||||||
|
|
||||||
function calculateFPS() {
|
// Utility function to get a cookie
|
||||||
|
function getCookie(name) {
|
||||||
|
const cookies = document.cookie.split(';');
|
||||||
|
for (let i = 0; i < cookies.length; i++) {
|
||||||
|
const cookie = cookies[i].trim();
|
||||||
|
if (cookie.startsWith(name + '=')) {
|
||||||
|
return cookie.substring(name.length + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if FPS Counter is enabled
|
||||||
|
const fpsCounterEnabled = getCookie('fpsCounter') === 'true';
|
||||||
|
|
||||||
|
if (fpsCounterEnabled) {
|
||||||
|
fpsCounter.style.display = 'block'; // Show FPS counter
|
||||||
|
|
||||||
|
function calculateFPS() {
|
||||||
let lastFrameTime = performance.now();
|
let lastFrameTime = performance.now();
|
||||||
let frames = 0;
|
let frames = 0;
|
||||||
|
|
||||||
@@ -57,7 +75,10 @@ function calculateFPS() {
|
|||||||
requestAnimationFrame(frameLoop);
|
requestAnimationFrame(frameLoop);
|
||||||
}
|
}
|
||||||
frameLoop();
|
frameLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateFPS(); // Ensure the FPS calculation starts
|
calculateFPS(); // Start FPS calculation
|
||||||
|
} else {
|
||||||
|
fpsCounter.style.display = 'none'; // Hide FPS counter
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -81,9 +81,27 @@ Drop a star on the repo if you enjoy.
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
const fpsCounter = document.getElementById("fps-counter"); // Moved this to the correct place
|
const fpsCounter = document.getElementById("fps-counter");
|
||||||
|
|
||||||
function calculateFPS() {
|
// Utility function to get a cookie
|
||||||
|
function getCookie(name) {
|
||||||
|
const cookies = document.cookie.split(';');
|
||||||
|
for (let i = 0; i < cookies.length; i++) {
|
||||||
|
const cookie = cookies[i].trim();
|
||||||
|
if (cookie.startsWith(name + '=')) {
|
||||||
|
return cookie.substring(name.length + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if FPS Counter is enabled
|
||||||
|
const fpsCounterEnabled = getCookie('fpsCounter') === 'true';
|
||||||
|
|
||||||
|
if (fpsCounterEnabled) {
|
||||||
|
fpsCounter.style.display = 'block'; // Show FPS counter
|
||||||
|
|
||||||
|
function calculateFPS() {
|
||||||
let lastFrameTime = performance.now();
|
let lastFrameTime = performance.now();
|
||||||
let frames = 0;
|
let frames = 0;
|
||||||
|
|
||||||
@@ -100,7 +118,10 @@ function calculateFPS() {
|
|||||||
requestAnimationFrame(frameLoop);
|
requestAnimationFrame(frameLoop);
|
||||||
}
|
}
|
||||||
frameLoop();
|
frameLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateFPS(); // Ensure the FPS calculation starts
|
calculateFPS(); // Start FPS calculation
|
||||||
|
} else {
|
||||||
|
fpsCounter.style.display = 'none'; // Hide FPS counter
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
+27
-5
@@ -38,10 +38,29 @@
|
|||||||
z-index: 1000; /* Ensure it stays on top */
|
z-index: 1000; /* Ensure it stays on top */
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
|
||||||
const fpsCounter = document.getElementById("fps-counter"); // Moved this to the correct place
|
|
||||||
|
|
||||||
function calculateFPS() {
|
<script>
|
||||||
|
const fpsCounter = document.getElementById("fps-counter");
|
||||||
|
|
||||||
|
// Utility function to get a cookie
|
||||||
|
function getCookie(name) {
|
||||||
|
const cookies = document.cookie.split(';');
|
||||||
|
for (let i = 0; i < cookies.length; i++) {
|
||||||
|
const cookie = cookies[i].trim();
|
||||||
|
if (cookie.startsWith(name + '=')) {
|
||||||
|
return cookie.substring(name.length + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if FPS Counter is enabled
|
||||||
|
const fpsCounterEnabled = getCookie('fpsCounter') === 'true';
|
||||||
|
|
||||||
|
if (fpsCounterEnabled) {
|
||||||
|
fpsCounter.style.display = 'block'; // Show FPS counter
|
||||||
|
|
||||||
|
function calculateFPS() {
|
||||||
let lastFrameTime = performance.now();
|
let lastFrameTime = performance.now();
|
||||||
let frames = 0;
|
let frames = 0;
|
||||||
|
|
||||||
@@ -58,7 +77,10 @@ function calculateFPS() {
|
|||||||
requestAnimationFrame(frameLoop);
|
requestAnimationFrame(frameLoop);
|
||||||
}
|
}
|
||||||
frameLoop();
|
frameLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateFPS(); // Ensure the FPS calculation starts
|
calculateFPS(); // Start FPS calculation
|
||||||
|
} else {
|
||||||
|
fpsCounter.style.display = 'none'; // Hide FPS counter
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -38,9 +38,27 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
const fpsCounter = document.getElementById("fps-counter"); // Moved this to the correct place
|
const fpsCounter = document.getElementById("fps-counter");
|
||||||
|
|
||||||
function calculateFPS() {
|
// Utility function to get a cookie
|
||||||
|
function getCookie(name) {
|
||||||
|
const cookies = document.cookie.split(';');
|
||||||
|
for (let i = 0; i < cookies.length; i++) {
|
||||||
|
const cookie = cookies[i].trim();
|
||||||
|
if (cookie.startsWith(name + '=')) {
|
||||||
|
return cookie.substring(name.length + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if FPS Counter is enabled
|
||||||
|
const fpsCounterEnabled = getCookie('fpsCounter') === 'true';
|
||||||
|
|
||||||
|
if (fpsCounterEnabled) {
|
||||||
|
fpsCounter.style.display = 'block'; // Show FPS counter
|
||||||
|
|
||||||
|
function calculateFPS() {
|
||||||
let lastFrameTime = performance.now();
|
let lastFrameTime = performance.now();
|
||||||
let frames = 0;
|
let frames = 0;
|
||||||
|
|
||||||
@@ -57,7 +75,10 @@ function calculateFPS() {
|
|||||||
requestAnimationFrame(frameLoop);
|
requestAnimationFrame(frameLoop);
|
||||||
}
|
}
|
||||||
frameLoop();
|
frameLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateFPS(); // Ensure the FPS calculation starts
|
calculateFPS(); // Start FPS calculation
|
||||||
|
} else {
|
||||||
|
fpsCounter.style.display = 'none'; // Hide FPS counter
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -162,9 +162,27 @@ window.JOT_formatRelativeToNow=function(a,b){a=((new Date).getTime()-a)/6E4;if(1
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
const fpsCounter = document.getElementById("fps-counter"); // Moved this to the correct place
|
const fpsCounter = document.getElementById("fps-counter");
|
||||||
|
|
||||||
function calculateFPS() {
|
// Utility function to get a cookie
|
||||||
|
function getCookie(name) {
|
||||||
|
const cookies = document.cookie.split(';');
|
||||||
|
for (let i = 0; i < cookies.length; i++) {
|
||||||
|
const cookie = cookies[i].trim();
|
||||||
|
if (cookie.startsWith(name + '=')) {
|
||||||
|
return cookie.substring(name.length + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if FPS Counter is enabled
|
||||||
|
const fpsCounterEnabled = getCookie('fpsCounter') === 'true';
|
||||||
|
|
||||||
|
if (fpsCounterEnabled) {
|
||||||
|
fpsCounter.style.display = 'block'; // Show FPS counter
|
||||||
|
|
||||||
|
function calculateFPS() {
|
||||||
let lastFrameTime = performance.now();
|
let lastFrameTime = performance.now();
|
||||||
let frames = 0;
|
let frames = 0;
|
||||||
|
|
||||||
@@ -181,7 +199,10 @@ function calculateFPS() {
|
|||||||
requestAnimationFrame(frameLoop);
|
requestAnimationFrame(frameLoop);
|
||||||
}
|
}
|
||||||
frameLoop();
|
frameLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateFPS(); // Ensure the FPS calculation starts
|
calculateFPS(); // Start FPS calculation
|
||||||
|
} else {
|
||||||
|
fpsCounter.style.display = 'none'; // Hide FPS counter
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -240,6 +240,14 @@
|
|||||||
<div class="game-title">Fnaf Collection</div>
|
<div class="game-title">Fnaf Collection</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div class="game">
|
<div class="game">
|
||||||
<a href="games/The-Shadow-Reform.html">
|
<a href="games/The-Shadow-Reform.html">
|
||||||
<img src="assets/kaertt.png" alt="The Shadow Reform">
|
<img src="assets/kaertt.png" alt="The Shadow Reform">
|
||||||
|
|||||||
@@ -34,7 +34,25 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
const fpsCounter = document.getElementById("fps-counter"); // Moved this to the correct place
|
const fpsCounter = document.getElementById("fps-counter");
|
||||||
|
|
||||||
|
// Utility function to get a cookie
|
||||||
|
function getCookie(name) {
|
||||||
|
const cookies = document.cookie.split(';');
|
||||||
|
for (let i = 0; i < cookies.length; i++) {
|
||||||
|
const cookie = cookies[i].trim();
|
||||||
|
if (cookie.startsWith(name + '=')) {
|
||||||
|
return cookie.substring(name.length + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if FPS Counter is enabled
|
||||||
|
const fpsCounterEnabled = getCookie('fpsCounter') === 'true';
|
||||||
|
|
||||||
|
if (fpsCounterEnabled) {
|
||||||
|
fpsCounter.style.display = 'block'; // Show FPS counter
|
||||||
|
|
||||||
function calculateFPS() {
|
function calculateFPS() {
|
||||||
let lastFrameTime = performance.now();
|
let lastFrameTime = performance.now();
|
||||||
@@ -55,5 +73,8 @@
|
|||||||
frameLoop();
|
frameLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateFPS(); // Ensure the FPS calculation starts
|
calculateFPS(); // Start FPS calculation
|
||||||
</script>
|
} else {
|
||||||
|
fpsCounter.style.display = 'none'; // Hide FPS counter
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -34,9 +34,27 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
const fpsCounter = document.getElementById("fps-counter"); // Moved this to the correct place
|
const fpsCounter = document.getElementById("fps-counter");
|
||||||
|
|
||||||
function calculateFPS() {
|
// Utility function to get a cookie
|
||||||
|
function getCookie(name) {
|
||||||
|
const cookies = document.cookie.split(';');
|
||||||
|
for (let i = 0; i < cookies.length; i++) {
|
||||||
|
const cookie = cookies[i].trim();
|
||||||
|
if (cookie.startsWith(name + '=')) {
|
||||||
|
return cookie.substring(name.length + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if FPS Counter is enabled
|
||||||
|
const fpsCounterEnabled = getCookie('fpsCounter') === 'true';
|
||||||
|
|
||||||
|
if (fpsCounterEnabled) {
|
||||||
|
fpsCounter.style.display = 'block'; // Show FPS counter
|
||||||
|
|
||||||
|
function calculateFPS() {
|
||||||
let lastFrameTime = performance.now();
|
let lastFrameTime = performance.now();
|
||||||
let frames = 0;
|
let frames = 0;
|
||||||
|
|
||||||
@@ -53,7 +71,10 @@ function calculateFPS() {
|
|||||||
requestAnimationFrame(frameLoop);
|
requestAnimationFrame(frameLoop);
|
||||||
}
|
}
|
||||||
frameLoop();
|
frameLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateFPS(); // Ensure the FPS calculation starts
|
calculateFPS(); // Start FPS calculation
|
||||||
|
} else {
|
||||||
|
fpsCounter.style.display = 'none'; // Hide FPS counter
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -28,9 +28,27 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
const fpsCounter = document.getElementById("fps-counter"); // Moved this to the correct place
|
const fpsCounter = document.getElementById("fps-counter");
|
||||||
|
|
||||||
function calculateFPS() {
|
// Utility function to get a cookie
|
||||||
|
function getCookie(name) {
|
||||||
|
const cookies = document.cookie.split(';');
|
||||||
|
for (let i = 0; i < cookies.length; i++) {
|
||||||
|
const cookie = cookies[i].trim();
|
||||||
|
if (cookie.startsWith(name + '=')) {
|
||||||
|
return cookie.substring(name.length + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if FPS Counter is enabled
|
||||||
|
const fpsCounterEnabled = getCookie('fpsCounter') === 'true';
|
||||||
|
|
||||||
|
if (fpsCounterEnabled) {
|
||||||
|
fpsCounter.style.display = 'block'; // Show FPS counter
|
||||||
|
|
||||||
|
function calculateFPS() {
|
||||||
let lastFrameTime = performance.now();
|
let lastFrameTime = performance.now();
|
||||||
let frames = 0;
|
let frames = 0;
|
||||||
|
|
||||||
@@ -47,7 +65,10 @@ function calculateFPS() {
|
|||||||
requestAnimationFrame(frameLoop);
|
requestAnimationFrame(frameLoop);
|
||||||
}
|
}
|
||||||
frameLoop();
|
frameLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateFPS(); // Ensure the FPS calculation starts
|
calculateFPS(); // Start FPS calculation
|
||||||
|
} else {
|
||||||
|
fpsCounter.style.display = 'none'; // Hide FPS counter
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -31,9 +31,27 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
const fpsCounter = document.getElementById("fps-counter"); // Moved this to the correct place
|
const fpsCounter = document.getElementById("fps-counter");
|
||||||
|
|
||||||
function calculateFPS() {
|
// Utility function to get a cookie
|
||||||
|
function getCookie(name) {
|
||||||
|
const cookies = document.cookie.split(';');
|
||||||
|
for (let i = 0; i < cookies.length; i++) {
|
||||||
|
const cookie = cookies[i].trim();
|
||||||
|
if (cookie.startsWith(name + '=')) {
|
||||||
|
return cookie.substring(name.length + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if FPS Counter is enabled
|
||||||
|
const fpsCounterEnabled = getCookie('fpsCounter') === 'true';
|
||||||
|
|
||||||
|
if (fpsCounterEnabled) {
|
||||||
|
fpsCounter.style.display = 'block'; // Show FPS counter
|
||||||
|
|
||||||
|
function calculateFPS() {
|
||||||
let lastFrameTime = performance.now();
|
let lastFrameTime = performance.now();
|
||||||
let frames = 0;
|
let frames = 0;
|
||||||
|
|
||||||
@@ -50,7 +68,10 @@ function calculateFPS() {
|
|||||||
requestAnimationFrame(frameLoop);
|
requestAnimationFrame(frameLoop);
|
||||||
}
|
}
|
||||||
frameLoop();
|
frameLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateFPS(); // Ensure the FPS calculation starts
|
calculateFPS(); // Start FPS calculation
|
||||||
|
} else {
|
||||||
|
fpsCounter.style.display = 'none'; // Hide FPS counter
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -28,9 +28,27 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
const fpsCounter = document.getElementById("fps-counter"); // Moved this to the correct place
|
const fpsCounter = document.getElementById("fps-counter");
|
||||||
|
|
||||||
function calculateFPS() {
|
// Utility function to get a cookie
|
||||||
|
function getCookie(name) {
|
||||||
|
const cookies = document.cookie.split(';');
|
||||||
|
for (let i = 0; i < cookies.length; i++) {
|
||||||
|
const cookie = cookies[i].trim();
|
||||||
|
if (cookie.startsWith(name + '=')) {
|
||||||
|
return cookie.substring(name.length + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if FPS Counter is enabled
|
||||||
|
const fpsCounterEnabled = getCookie('fpsCounter') === 'true';
|
||||||
|
|
||||||
|
if (fpsCounterEnabled) {
|
||||||
|
fpsCounter.style.display = 'block'; // Show FPS counter
|
||||||
|
|
||||||
|
function calculateFPS() {
|
||||||
let lastFrameTime = performance.now();
|
let lastFrameTime = performance.now();
|
||||||
let frames = 0;
|
let frames = 0;
|
||||||
|
|
||||||
@@ -47,7 +65,10 @@ function calculateFPS() {
|
|||||||
requestAnimationFrame(frameLoop);
|
requestAnimationFrame(frameLoop);
|
||||||
}
|
}
|
||||||
frameLoop();
|
frameLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateFPS(); // Ensure the FPS calculation starts
|
calculateFPS(); // Start FPS calculation
|
||||||
|
} else {
|
||||||
|
fpsCounter.style.display = 'none'; // Hide FPS counter
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -31,9 +31,27 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
const fpsCounter = document.getElementById("fps-counter"); // Moved this to the correct place
|
const fpsCounter = document.getElementById("fps-counter");
|
||||||
|
|
||||||
function calculateFPS() {
|
// Utility function to get a cookie
|
||||||
|
function getCookie(name) {
|
||||||
|
const cookies = document.cookie.split(';');
|
||||||
|
for (let i = 0; i < cookies.length; i++) {
|
||||||
|
const cookie = cookies[i].trim();
|
||||||
|
if (cookie.startsWith(name + '=')) {
|
||||||
|
return cookie.substring(name.length + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if FPS Counter is enabled
|
||||||
|
const fpsCounterEnabled = getCookie('fpsCounter') === 'true';
|
||||||
|
|
||||||
|
if (fpsCounterEnabled) {
|
||||||
|
fpsCounter.style.display = 'block'; // Show FPS counter
|
||||||
|
|
||||||
|
function calculateFPS() {
|
||||||
let lastFrameTime = performance.now();
|
let lastFrameTime = performance.now();
|
||||||
let frames = 0;
|
let frames = 0;
|
||||||
|
|
||||||
@@ -50,7 +68,10 @@ function calculateFPS() {
|
|||||||
requestAnimationFrame(frameLoop);
|
requestAnimationFrame(frameLoop);
|
||||||
}
|
}
|
||||||
frameLoop();
|
frameLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateFPS(); // Ensure the FPS calculation starts
|
calculateFPS(); // Start FPS calculation
|
||||||
|
} else {
|
||||||
|
fpsCounter.style.display = 'none'; // Hide FPS counter
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
+53
@@ -82,6 +82,7 @@
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<div id="clock" style="font-size: 1.5rem; margin-top: 10px; font-family: 'Orbitron', sans-serif; color: var(--text-color); display: none;"></div>
|
||||||
<h1>Moon Gaming</h1>
|
<h1>Moon Gaming</h1>
|
||||||
<div class="button-container">
|
<div class="button-container">
|
||||||
<button class="button" onclick="location.href='setting.html'">Settings</button>
|
<button class="button" onclick="location.href='setting.html'">Settings</button>
|
||||||
@@ -133,6 +134,58 @@
|
|||||||
// Apply saved mode on load
|
// Apply saved mode on load
|
||||||
const darkModeEnabled = getCookie('darkMode') === 'true';
|
const darkModeEnabled = getCookie('darkMode') === 'true';
|
||||||
applyDarkMode(darkModeEnabled);
|
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
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -91,6 +91,10 @@
|
|||||||
<span>Enable Text-to-Speech</span>
|
<span>Enable Text-to-Speech</span>
|
||||||
<button id="toggleTextToSpeech">Enable</button>
|
<button id="toggleTextToSpeech">Enable</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="setting-item">
|
||||||
|
<span>Show Date and Time</span>
|
||||||
|
<button id="toggleDateTime">Enable</button>
|
||||||
|
</div>
|
||||||
<div class="setting-item clear-cookies">
|
<div class="setting-item clear-cookies">
|
||||||
<span>Clear Cookies</span>
|
<span>Clear Cookies</span>
|
||||||
<button id="clearCookies">Clear</button>
|
<button id="clearCookies">Clear</button>
|
||||||
@@ -237,6 +241,27 @@
|
|||||||
// Apply saved Text-to-Speech preference on load
|
// Apply saved Text-to-Speech preference on load
|
||||||
applyTextToSpeechSetting(textToSpeechEnabled);
|
applyTextToSpeechSetting(textToSpeechEnabled);
|
||||||
|
|
||||||
|
// Date and Time Toggle
|
||||||
|
const toggleDateTimeButton = document.getElementById('toggleDateTime');
|
||||||
|
const dateTimeEnabled = getCookie('dateTime') === 'true';
|
||||||
|
|
||||||
|
function applyDateTimeSetting(enabled) {
|
||||||
|
if (enabled) {
|
||||||
|
toggleDateTimeButton.textContent = 'Disable';
|
||||||
|
} else {
|
||||||
|
toggleDateTimeButton.textContent = 'Enable';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleDateTimeButton.addEventListener('click', () => {
|
||||||
|
const isDateTimeEnabled = getCookie('dateTime') === 'true';
|
||||||
|
setCookie('dateTime', !isDateTimeEnabled, 30); // Save preference for 30 days
|
||||||
|
applyDateTimeSetting(!isDateTimeEnabled);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Apply saved Date and Time preference on load
|
||||||
|
applyDateTimeSetting(dateTimeEnabled);
|
||||||
|
|
||||||
// Regional Settings
|
// Regional Settings
|
||||||
const regionSelect = document.getElementById('regionSelect');
|
const regionSelect = document.getElementById('regionSelect');
|
||||||
const savedRegion = getCookie('region') || 'us'; // Default to 'us'
|
const savedRegion = getCookie('region') || 'us'; // Default to 'us'
|
||||||
@@ -279,6 +304,7 @@
|
|||||||
applyFPSCounterSetting(false); // Default: FPS Counter disabled
|
applyFPSCounterSetting(false); // Default: FPS Counter disabled
|
||||||
applyMaturityFilterSetting(false); // Default: Maturity Filter disabled
|
applyMaturityFilterSetting(false); // Default: Maturity Filter disabled
|
||||||
applyTextToSpeechSetting(false); // Default: Text-to-Speech disabled
|
applyTextToSpeechSetting(false); // Default: Text-to-Speech disabled
|
||||||
|
applyDateTimeSetting(false); // Default: Date and Time disabled
|
||||||
|
|
||||||
alert('Settings have been reset to default!');
|
alert('Settings have been reset to default!');
|
||||||
});
|
});
|
||||||
|
|||||||
+25
-4
@@ -28,9 +28,27 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
const fpsCounter = document.getElementById("fps-counter"); // Moved this to the correct place
|
const fpsCounter = document.getElementById("fps-counter");
|
||||||
|
|
||||||
function calculateFPS() {
|
// Utility function to get a cookie
|
||||||
|
function getCookie(name) {
|
||||||
|
const cookies = document.cookie.split(';');
|
||||||
|
for (let i = 0; i < cookies.length; i++) {
|
||||||
|
const cookie = cookies[i].trim();
|
||||||
|
if (cookie.startsWith(name + '=')) {
|
||||||
|
return cookie.substring(name.length + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if FPS Counter is enabled
|
||||||
|
const fpsCounterEnabled = getCookie('fpsCounter') === 'true';
|
||||||
|
|
||||||
|
if (fpsCounterEnabled) {
|
||||||
|
fpsCounter.style.display = 'block'; // Show FPS counter
|
||||||
|
|
||||||
|
function calculateFPS() {
|
||||||
let lastFrameTime = performance.now();
|
let lastFrameTime = performance.now();
|
||||||
let frames = 0;
|
let frames = 0;
|
||||||
|
|
||||||
@@ -47,7 +65,10 @@ function calculateFPS() {
|
|||||||
requestAnimationFrame(frameLoop);
|
requestAnimationFrame(frameLoop);
|
||||||
}
|
}
|
||||||
frameLoop();
|
frameLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
calculateFPS(); // Ensure the FPS calculation starts
|
calculateFPS(); // Start FPS calculation
|
||||||
|
} else {
|
||||||
|
fpsCounter.style.display = 'none'; // Hide FPS counter
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
Reference in New Issue
Block a user