Skip to content

Commit db6b321

Browse files
authored
Good changes
1 parent 7d7b29d commit db6b321

5 files changed

Lines changed: 76 additions & 139 deletions

File tree

.prettierrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"printWidth": 999999,
3-
"tabWidth": 3
2+
"printWidth": 999999,
3+
"tabWidth": 3
44
}

css/index.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@
5858
bottom: 0px;
5959
left: 230px;
6060
z-index: 105;
61-
transition: left 0.3s ease, bottom 0.3s ease;
61+
transition:
62+
left 0.3s ease,
63+
bottom 0.3s ease;
6264
border-radius: 50%;
6365
background-color: #212121;
6466
display: flex;
@@ -144,7 +146,7 @@ input[type="text"] {
144146
background-image: url("https://img.icons8.com/material-outlined/24/000000/search--v1.png");
145147
background-position: 10px 10px;
146148
background-repeat: no-repeat;
147-
padding: 12px 20px 12px 48px;
149+
padding: 14px 20px 14px 48px;
148150
transition: width 0.4s ease-in-out;
149151
}
150152

index.html

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ <h1>
4646
<img title="music_icon" id="icon" src="/img/play.png" />
4747
</div>
4848
<audio id="mySong">
49-
<source src="/media/beet-juice.mp4" type="/audio/ogg" />
49+
<source src="/media/beet-juice.mp4" />
5050
</audio>
5151
</header>
5252
<br />
@@ -74,13 +74,12 @@ <h1>
7474
<span id="progress-value"></span>
7575
</div>
7676
</div>
77-
78-
<script src="/js/main.js"></script>
79-
<script src="/js/seasonal.js"></script>
80-
<script src="/js/disguise.js"></script>
81-
<div id="tsparticles"></div>
82-
<script src="https://cdn.jsdelivr.net/npm/tsparticles@3.8.1/tsparticles.bundle.min.js"></script>
8377
</div>
8478
</div>
8579
</body>
80+
<script src="/js/main.js"></script>
81+
<script src="/js/seasonal.js"></script>
82+
<script src="/js/disguise.js"></script>
83+
<div id="tsparticles"></div>
84+
<script src="https://cdn.jsdelivr.net/npm/tsparticles@3.8.1/tsparticles.bundle.min.js"></script>
8685
</html>

js/main.js

Lines changed: 59 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,141 +1,77 @@
1-
document.addEventListener("DOMContentLoaded", () => {
2-
const loadingBar = document.getElementById("loading-bar");
3-
loadingBar.style.width = "100%";
4-
setTimeout(() => {
5-
loadingBar.style.opacity = 0;
6-
setTimeout(() => (loadingBar.style.display = "none"), 500);
7-
}, 500);
8-
9-
const goToTopButton = document.getElementById("go-to-top-button");
10-
if (goToTopButton) {
11-
goToTopButton.addEventListener("click", () => {
12-
window.scroll({ top: 0, behavior: "smooth" });
13-
});
14-
}
15-
16-
window.addEventListener("scroll", () => {
17-
const progress = document.getElementById("progress");
18-
const value = document.getElementById("progress-value");
19-
const pos = document.documentElement.scrollTop;
20-
const calcHeight = document.documentElement.scrollHeight - document.documentElement.clientHeight;
21-
const scrollValue = Math.round((pos * 100) / calcHeight);
22-
progress.style.background = `conic-gradient(#A61414 ${scrollValue}%, #3D3D3D ${scrollValue}%)`;
23-
});
24-
25-
window.dispatchEvent(new Event("scroll"));
26-
27-
filterSelection("all");
1+
const getById = (id) => document.getElementById(id);
2+
const querySelectorAll = (selector) => document.querySelectorAll(selector);
283

29-
const buttons = document.getElementsByClassName("selectable");
30-
const games = document.getElementsByClassName("gameDiv");
31-
32-
function filterSelection(c) {
33-
const x = document.getElementsByClassName("column");
34-
const category = c === "all" ? "" : c;
35-
for (let i = 0; i < x.length; i++) {
36-
w3RemoveClass(x[i], "show");
37-
if (x[i].className.indexOf(category) > -1) w3AddClass(x[i], "show");
38-
}
39-
}
40-
41-
function w3AddClass(element, name) {
42-
const arr1 = element.className.split(" ");
43-
const arr2 = name.split(" ");
44-
for (let i = 0; i < arr2.length; i++) {
45-
if (!arr1.includes(arr2[i])) {
46-
element.className += " " + arr2[i];
47-
}
48-
}
49-
}
50-
51-
function w3RemoveClass(element, name) {
52-
let arr1 = element.className.split(" ");
53-
const arr2 = name.split(" ");
54-
arr1 = arr1.filter((cls) => !arr2.includes(cls));
55-
element.className = arr1.join(" ");
4+
document.addEventListener("DOMContentLoaded", () => {
5+
const loadingBar = getById("loading-bar");
6+
if (loadingBar) {
7+
loadingBar.style.width = "100%";
8+
setTimeout(() => {
9+
loadingBar.style.opacity = 0;
10+
setTimeout(() => (loadingBar.style.display = "none"), 500);
11+
}, 500);
5612
}
5713

58-
let selectedTopic = "all";
14+
getById("go-to-top-button")?.addEventListener("click", () => window.scroll({ top: 0, behavior: "smooth" }));
5915

60-
window.switchGame = function (x) {
61-
selectedTopic = x;
62-
for (let i = 0; i < buttons.length; i++) {
63-
const buttonName = buttons[i].getAttribute("name");
64-
if (selectedTopic === buttonName) {
65-
buttons[i].classList.add("selectedButton");
66-
buttons[i].classList.remove("selectButton");
67-
} else {
68-
buttons[i].classList.remove("selectedButton");
69-
buttons[i].classList.add("selectButton");
70-
}
71-
}
72-
73-
for (let i = 0; i < games.length; i++) {
74-
games[i].style.display = games[i].classList.contains(selectedTopic) ? "" : "none";
75-
}
16+
const progressIndicator = getById("progress");
17+
const updateProgress = () => {
18+
if (!progressIndicator) return;
19+
const { scrollTop, scrollHeight, clientHeight } = document.documentElement;
20+
const scrollPercentage = Math.round((scrollTop * 100) / (scrollHeight - clientHeight)) || 0;
21+
progressIndicator.style.background = `conic-gradient(#A61414 ${scrollPercentage}%, #3D3D3D ${scrollPercentage}%)`;
7622
};
77-
78-
window.searchFunction = function () {
79-
const input = document.getElementById("myinput");
80-
const filter = input.value.toUpperCase();
81-
const li = document.getElementsByClassName("gameDiv");
82-
for (let i = 0; i < li.length; i++) {
83-
const gameName = li[i].getAttribute("name").toUpperCase();
84-
if (gameName.includes(filter) && li[i].classList.contains(selectedTopic)) {
85-
li[i].style.display = "";
86-
} else {
87-
li[i].style.display = "none";
88-
}
89-
}
23+
window.addEventListener("scroll", updateProgress);
24+
updateProgress();
25+
26+
const categoryButtons = querySelectorAll(".selectable");
27+
const gameElements = querySelectorAll(".gameDiv");
28+
let selectedCategory = "all";
29+
30+
window.switchGame = (category) => {
31+
selectedCategory = category;
32+
categoryButtons.forEach((button) => {
33+
const isMatch = button.getAttribute("name") === selectedCategory;
34+
button.classList.toggle("selectedButton", isMatch);
35+
button.classList.toggle("selectButton", !isMatch);
36+
});
37+
gameElements.forEach((game) => (game.style.display = selectedCategory === "all" || game.classList.contains(selectedCategory) ? "" : "none"));
9038
};
9139

92-
const mySong = document.getElementById("mySong");
93-
const icon = document.getElementById("icon");
40+
window.searchFunction = () => {
41+
const searchFilter = (getById("myinput")?.value || "").trim().toUpperCase();
42+
gameElements.forEach((game) => {
43+
const gameName = (game.getAttribute("name") || "").toUpperCase();
44+
game.style.display = gameName.includes(searchFilter) && (selectedCategory === "all" || game.classList.contains(selectedCategory)) ? "" : "none";
45+
});
46+
};
9447

95-
if (mySong && icon) {
96-
icon.addEventListener("click", () => {
97-
if (mySong.paused) {
98-
mySong.play();
99-
icon.src = "img/pause.png";
100-
} else {
101-
mySong.pause();
102-
icon.src = "img/play.png";
103-
}
48+
const [audioPlayer, playPauseIcon] = [getById("mySong"), getById("icon")];
49+
if (audioPlayer && playPauseIcon) {
50+
playPauseIcon.addEventListener("click", () => {
51+
audioPlayer.paused ? audioPlayer.play() : audioPlayer.pause();
52+
playPauseIcon.src = `img/${audioPlayer.paused ? "play" : "pause"}.png`;
10453
});
10554
}
55+
56+
window.switchGame("all");
10657
});
10758

10859
async function fetchQuotes() {
60+
const quoteElement = getById("random-quote");
61+
if (!quoteElement) return;
10962
try {
110-
const response = await fetch("../media/quotes.json");
111-
if (!response.ok) {
112-
throw new Error(`HTTP error! status: ${response.status}`);
113-
}
114-
115-
const quotes = await response.json();
116-
const randomQuoteObj = quotes[Math.floor(Math.random() * quotes.length)];
117-
const fullQuote = `"${randomQuoteObj.quote}" - ${randomQuoteObj.author}`;
118-
typeEffect(fullQuote, "random-quote", 50);
119-
} catch (error) {
120-
console.error("Error fetching quotes:", error);
121-
document.getElementById("random-quote").innerHTML = `"Error loading quote."`;
122-
}
123-
}
124-
125-
function typeEffect(text, elementId, delay) {
126-
const element = document.getElementById(elementId);
127-
element.innerHTML = "";
128-
let i = 0;
129-
130-
function type() {
131-
if (i < text.length) {
132-
element.innerHTML += text.charAt(i);
133-
i++;
134-
setTimeout(type, delay);
135-
}
63+
const quotes = await (await fetch("../media/quotes.json")).json();
64+
const { quote, author } = quotes[Math.floor(Math.random() * quotes.length)] || {};
65+
const quoteText = quote ? `"${quote}" - ${author || "Unknown"}` : "No quotes found.";
66+
quoteElement.textContent = "";
67+
let charIndex = 0;
68+
const typewriterTimer = setInterval(() => {
69+
quoteElement.textContent += quoteText[charIndex++];
70+
if (charIndex >= quoteText.length) clearInterval(typewriterTimer);
71+
}, 50);
72+
} catch {
73+
quoteElement.textContent = "Error loading quote.";
13674
}
137-
138-
type();
13975
}
14076

14177
fetchQuotes();

pages/player.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8" />
@@ -52,10 +52,10 @@
5252
<div class="sidebar">
5353
<h2>Jet Yeh's</h2>
5454
<ul>
55-
<li onclick="location.href='/index.html'" class="selectedButton"><i class="fa-solid fa-house"></i> Home</li>
56-
<li onclick="location.href='//github.com/dngaa/dngaa.github.io/issues/new?labels=bug&title=Bug%20Report&body=-%20**Describe%20the%20bug**%20A%20clear%20and%20concise%20description%20of%20what%20the%20bug%20is.%0A-%20**To%20Reproduce**%20Steps%20to%20reproduce%20the%20behavior%3A%0A%20%20%201.%20Go%20to%20...%0A%20%20%202.%20Click%20on%20...%0A%20%20%203.%20Scroll%20down%20to%20...%0A%20%20%204.%20See%20error%0A-%20**Expected%20behavior**%20A%20clear%20and%20concise%20description%20of%20what%20you%20expected%20to%20happen.%0A-%20**Screenshots**%20If%20applicable%2C%20add%20screenshots%20to%20help%20explain%20your%20problem.%0A-%20**Environment**%20(please%20complete%20the%20following%20information)%3A%0A%20%20%20-%20OS%3A%20%0A%20%20%20-%20Browser%3A%20%0A%20%20%20-%20Version%3A%20%0A-%20**Additional%20context**%20Add%20any%20other%20context%20about%20the%20problem%20here.'"><i class="fa-solid fa-bug"></i> Bug Report</li>
57-
<li onclick="location.href='//github.com/dngaa/dngaa.github.io/issues/new?labels=game%20request&title=Game%20Request&body=-%20**Game%20Title**%3A%20The%20name%20of%20the%20game%20you%20would%20like%20to%20request.%0A-%20**Description**%3A%20Why%20do%20you%20want%20this%20game%3F%20What%20features%20or%20gameplay%20elements%20are%20important%3F%0A-%20**Source%20Code**%3A%20If%20available%2C%20please%20provide%20a%20link%20to%20the%20original%20game%20source%20code.%0A-%20**Additional%20Notes**%3A%20Any%20extra%20details%20or%20context%20about%20the%20request.'"><i class="fa-solid fa-ghost"></i> Game Request</li>
58-
<li onclick="location.href='/pages/settings.html'"><i class="fa-solid fa-gear"></i> Settings</li>
55+
<li onclick="location.href = '/index.html'" class="selectedButton"><i class="fa-solid fa-house"></i> Home</li>
56+
<li onclick="location.href = '//github.com/dngaa/dngaa.github.io/issues/new?labels=bug&title=Bug%20Report&body=-%20**Describe%20the%20bug**%20A%20clear%20and%20concise%20description%20of%20what%20the%20bug%20is.%0A-%20**To%20Reproduce**%20Steps%20to%20reproduce%20the%20behavior%3A%0A%20%20%201.%20Go%20to%20...%0A%20%20%202.%20Click%20on%20...%0A%20%20%203.%20Scroll%20down%20to%20...%0A%20%20%204.%20See%20error%0A-%20**Expected%20behavior**%20A%20clear%20and%20concise%20description%20of%20what%20you%20expected%20to%20happen.%0A-%20**Screenshots**%20If%20applicable%2C%20add%20screenshots%20to%20help%20explain%20your%20problem.%0A-%20**Environment**%20(please%20complete%20the%20following%20information)%3A%0A%20%20%20-%20OS%3A%20%0A%20%20%20-%20Browser%3A%20%0A%20%20%20-%20Version%3A%20%0A-%20**Additional%20context**%20Add%20any%20other%20context%20about%20the%20problem%20here.'"><i class="fa-solid fa-bug"></i> Bug Report</li>
57+
<li onclick="location.href = '//github.com/dngaa/dngaa.github.io/issues/new?labels=game%20request&title=Game%20Request&body=-%20**Game%20Title**%3A%20The%20name%20of%20the%20game%20you%20would%20like%20to%20request.%0A-%20**Description**%3A%20Why%20do%20you%20want%20this%20game%3F%20What%20features%20or%20gameplay%20elements%20are%20important%3F%0A-%20**Source%20Code**%3A%20If%20available%2C%20please%20provide%20a%20link%20to%20the%20original%20game%20source%20code.%0A-%20**Additional%20Notes**%3A%20Any%20extra%20details%20or%20context%20about%20the%20request.'"><i class="fa-solid fa-ghost"></i> Game Request</li>
58+
<li onclick="location.href = '/pages/settings.html'"><i class="fa-solid fa-gear"></i> Settings</li>
5959
<li id="go-to-top-button"><i class="fa-solid fa-up-long"></i> Top</li>
6060
</ul>
6161

0 commit comments

Comments
 (0)