random quote fix

This commit is contained in:
sky 2024-08-13 05:06:24 -04:00
parent f18f4a0f0b
commit 6cb7f8d20a
2 changed files with 73 additions and 79 deletions

View File

@ -1,4 +1,4 @@
<!doctype html> <!DOCTYPE html>
<html class="sl-theme-dark" lang="en"> <html class="sl-theme-dark" lang="en">
<head> <head>
<!-- initialize theme vars <!-- initialize theme vars
@ -13,16 +13,33 @@
<script src="/js/main.js"></script> <script src="/js/main.js"></script>
<script src="/js/widget.js"></script> <script src="/js/widget.js"></script>
<script src="/js/themes.js"></script> <script src="/js/themes.js"></script>
<script src="/js/randomquote.js"></script> <script>
document.addEventListener("DOMContentLoaded", () => {
fetch("/data/quotes.json")
.then((response) => response.json())
.then((data) => {
const randomQuote = data[Math.floor(Math.random() * data.length)];
if (randomQuote.includes("OGNUM1") && randomQuote.includes("SQRTNUM1")) {
const ognum = Math.floor(Math.random() * 3000);
randomQuote = `the square root of ${ognum} is ${Math.sqrt(ognum)}`;
} else if (randomQuote.includes("CURRENTURL")) {
randomQuote = window.location.hostname;
}
document.getElementById("randomquote").innerHTML = randomQuote;
})
.catch((error) => console.error("Error loading quotes:", error));
});
</script>
<link rel="stylesheet" href="/style.css" /> <link rel="stylesheet" href="/style.css" />
<link rel="manifest" href="/manifest.json"> <link rel="manifest" href="/manifest.json" />
<!-- seo + other things --> <!-- seo + other things -->
<title>Selenite</title> <title>Selenite</title>
<link rel="icon" href="/favicon.ico" /> <link rel="icon" href="/favicon.ico" />
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-3415518411898563" <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-3415518411898563" crossorigin="anonymous"></script>
crossorigin="anonymous"></script>
</head> </head>
<alerts> </alerts> <alerts> </alerts>
<body id="noscroll"> <body id="noscroll">
@ -37,24 +54,17 @@
</header> </header>
<main id="main" class="noscroll"> <main id="main" class="noscroll">
<b style="font-weight: 1000px"><h1 class="chan">selenite.</h1></b> <b style="font-weight: 1000px"><h1 class="chan">selenite.</h1></b>
<noscript <noscript>enable javascript if you want the games to actually load</noscript>
>enable javascript if you want the games to actually
load</noscript
>
<p id="randomquote">better thank me for this unblocked website</p> <p id="randomquote">better thank me for this unblocked website</p>
<div class="samerow"> <div class="samerow">
<div class="img-container"> <div class="img-container">
<a href="/users" <a href="/users"><img src="img/user_index.svg" /></a>
><img src="img/user_index.svg"
/></a>
</div> </div>
<div class="img-container"> <div class="img-container">
<a href="projects.html"><img src="img/games.svg" /></a> <a href="projects.html"><img src="img/games.svg" /></a>
</div> </div>
<div class="img-container"> <div class="img-container">
<a href="https://discord.gg/7jyufnwJNf" <a href="https://discord.gg/7jyufnwJNf"><img src="img/discord.svg" /></a>
><img src="img/discord.svg"
/></a>
</div> </div>
</div> </div>
</main> </main>

View File

@ -1,16 +0,0 @@
$.getJSON("/data/quotes.json", function (data) {
let index = data[Math.floor(Math.random() * data.length)];
if (index.includes("OGNUM1") && index.includes("SQRTNUM1")) {
let ognum = Math.floor(Math.random() * 3000);
index = "the square root of " + ognum + " is " + Math.sqrt(ognum);
} else if (index.includes("CURRENTURL")) {
index = window.location.hostname;
}
if (document.readyState === "complete") {
document.getElementById("randomquote").innerHTML = index;
} else {
document.addEventListener("DOMContentLoaded", () => {
document.getElementById("randomquote").innerHTML = index;
});
}
});