mirror of
https://github.com/zyqunix/tools.git
synced 2025-07-06 06:20:30 +02:00
lil update
This commit is contained in:
parent
149db42518
commit
c6a234489d
2 changed files with 221 additions and 219 deletions
|
@ -24,23 +24,29 @@ const ageElem = document.getElementById('age');
|
|||
let birthday = new Date('2008-12-13');
|
||||
let age = 0;
|
||||
|
||||
const updateAge = () => {
|
||||
function updateAge(elem, fix, text) {
|
||||
const now = new Date();
|
||||
const diff = now.getTime() - birthday.getTime();
|
||||
age = diff / (1000 * 60 * 60 * 24 * 365.25);
|
||||
ageElem.innerHTML = `${age.toFixed(10)} years old`;
|
||||
}
|
||||
const age = diff / (1000 * 60 * 60 * 24 * 365.25);
|
||||
const str = `${age.toFixed(fix)} ${text}`;
|
||||
if (elem) elem.innerHTML = str;
|
||||
|
||||
updateAge();
|
||||
return str;
|
||||
};
|
||||
|
||||
updateAge(ageElem, 2, "years old");
|
||||
|
||||
setInterval(() => {
|
||||
updateAge(ageElem, 2, "years old");
|
||||
}, 3600 * 1000);
|
||||
|
||||
setInterval(() => {
|
||||
ageElem.setAttribute("data-tooltip", updateAge(null, 10, "years old"));
|
||||
}, 10);
|
||||
|
||||
const timeInterval = setInterval(() => {
|
||||
updateAge();
|
||||
}, 100);
|
||||
|
||||
function lan() {
|
||||
lanyard({
|
||||
userId: "1201415921802170388",
|
||||
}).then(data => {
|
||||
lanyard({userId: "1201415921802170388"}).then(data => {
|
||||
const statusElem = document.getElementById('status');
|
||||
const pfpElem = document.getElementById('profile-picture');
|
||||
const activity = document.querySelector('.activity');
|
||||
|
@ -60,7 +66,9 @@ function lan() {
|
|||
pfpElem.style.borderColor = borderColor;
|
||||
|
||||
if (status) {
|
||||
statusElem.innerHTML = `<strong class="quote">"${status.state}"</strong> - zyqunix`;
|
||||
statusElem.innerHTML = `<strong class="quote">"${
|
||||
status.state
|
||||
}"</strong> - zyqunix`;
|
||||
} else {
|
||||
statusElem.innerHTML = `<strong class="quote">Empty void. Nothingness.</strong>`;
|
||||
}
|
||||
|
@ -68,22 +76,38 @@ function lan() {
|
|||
if (gameActivity) {
|
||||
|
||||
const parts = [];
|
||||
if (gameActivity.name) parts.push(`<strong>Playing</strong> ${gameActivity.name}`);
|
||||
if (gameActivity.details) parts.push(gameActivity.details);
|
||||
if (gameActivity.state) parts.push(gameActivity.state);
|
||||
if (gameActivity.name)
|
||||
parts.push(`<strong>Playing</strong> ${
|
||||
gameActivity.name
|
||||
}`);
|
||||
|
||||
|
||||
if (gameActivity.details)
|
||||
parts.push(gameActivity.details);
|
||||
|
||||
|
||||
if (gameActivity.state)
|
||||
parts.push(gameActivity.state);
|
||||
|
||||
|
||||
activityNameElem.innerHTML = parts.join(': ');
|
||||
|
||||
if (gameActivity.assets && gameActivity.assets.large_image) {
|
||||
const imgId = gameActivity.assets.large_image;
|
||||
const imageUrl = imgId.startsWith("mp:external/")
|
||||
? `https://media.discordapp.net/${imgId.replace("mp:", "")}`
|
||||
: `https://cdn.discordapp.com/app-assets/${gameActivity.application_id}/${imgId}.png`;
|
||||
const imageUrl = imgId.startsWith("mp:external/") ? `https://media.discordapp.net/${
|
||||
imgId.replace("mp:", "")
|
||||
}` : `https://cdn.discordapp.com/app-assets/${
|
||||
gameActivity.application_id
|
||||
}/${imgId}.png`;
|
||||
activityImageElem.src = imageUrl;
|
||||
activityImageElem.style.display = "block";
|
||||
} else {
|
||||
activityImageElem.style.display = "none";
|
||||
}
|
||||
} else activity.style.display = "none";
|
||||
} else
|
||||
activity.style.display = "none";
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -117,7 +141,9 @@ function generateLanguageCards(languagesData) {
|
|||
|
||||
const languagePercentage = document.createElement('span');
|
||||
languagePercentage.classList.add('percent');
|
||||
languagePercentage.textContent = `${language.percentage}%`;
|
||||
languagePercentage.textContent = `${
|
||||
language.percentage
|
||||
}%`;
|
||||
|
||||
namePercentContainer.appendChild(languageImage);
|
||||
namePercentContainer.appendChild(languageName);
|
||||
|
@ -127,7 +153,9 @@ function generateLanguageCards(languagesData) {
|
|||
percentageBar.classList.add('percentage-bar');
|
||||
const barAfter = document.createElement('div');
|
||||
barAfter.classList.add('bar-after');
|
||||
barAfter.style.width = `${language.percentage}%`;
|
||||
barAfter.style.width = `${
|
||||
language.percentage
|
||||
}%`;
|
||||
percentageBar.appendChild(barAfter);
|
||||
|
||||
languageItem.appendChild(namePercentContainer);
|
||||
|
@ -162,47 +190,9 @@ function generateSkillCards(skillData) {
|
|||
});
|
||||
}
|
||||
|
||||
fetch('assets/js/lang.json')
|
||||
.then(response => response.json())
|
||||
.then(generateLanguageCards)
|
||||
.catch(error => console.error('Error fetching lang.json:', error));
|
||||
|
||||
fetch('assets/js/skills.json')
|
||||
.then(response => response.json())
|
||||
.then(generateSkillCards)
|
||||
.catch(error => console.error('Error fetching skills.json', error));
|
||||
|
||||
document.querySelectorAll('.tooltip').forEach(elem => {
|
||||
elem.addEventListener('mouseenter', () => {
|
||||
const tooltipText = elem.getAttribute('data-tooltip');
|
||||
if (!tooltipText) return;
|
||||
|
||||
const dummy = document.createElement('div');
|
||||
dummy.style.position = 'absolute';
|
||||
dummy.style.visibility = 'hidden';
|
||||
dummy.style.whiteSpace = 'nowrap';
|
||||
dummy.style.padding = '5px 10px';
|
||||
dummy.style.fontSize = '14px';
|
||||
dummy.innerText = tooltipText;
|
||||
document.body.appendChild(dummy);
|
||||
|
||||
const elemRect = elem.getBoundingClientRect();
|
||||
const tipRect = dummy.getBoundingClientRect();
|
||||
const leftEdge = elemRect.left + (elemRect.width / 2) - (tipRect.width / 2);
|
||||
const rightEdge = elemRect.left + (elemRect.width / 2) + (tipRect.width / 2);
|
||||
|
||||
elem.classList.remove('slide-left', 'slide-right');
|
||||
|
||||
if (rightEdge > window.innerWidth) {
|
||||
elem.classList.add('slide-left');
|
||||
} else if (leftEdge < 0) {
|
||||
elem.classList.add('slide-right');
|
||||
}
|
||||
|
||||
dummy.remove();
|
||||
});
|
||||
});
|
||||
fetch('assets/js/lang.json').then(response => response.json()).then(generateLanguageCards).catch(error => console.error('Error fetching lang.json:', error));
|
||||
|
||||
fetch('assets/js/skills.json').then(response => response.json()).then(generateSkillCards).catch(error => console.error('Error fetching skills.json', error));
|
||||
|
||||
const LASTFM_API_KEY = "04f747e38bebf69efbbfab7b20612bac";
|
||||
const LASTFM_USERNAME = "zyqunix";
|
||||
|
@ -215,14 +205,17 @@ const params = new URLSearchParams({
|
|||
limit: "1"
|
||||
});
|
||||
|
||||
const url = `https://ws.audioscrobbler.com/2.0/?${params.toString()}`;
|
||||
const url = `https://ws.audioscrobbler.com/2.0/?${
|
||||
params.toString()
|
||||
}`;
|
||||
|
||||
function fetchSong() {
|
||||
fetch(url)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
fetch(url).then(response => response.json()).then(data => {
|
||||
const track = data ?. recenttracks ?. track ?. [0];
|
||||
if (!track) return;
|
||||
if (! track)
|
||||
return;
|
||||
|
||||
|
||||
const artist = track.artist["#text"];
|
||||
const title = track.name;
|
||||
const image = track.image.find(img => img.size === "extralarge") ?. ["#text"] || "";
|
||||
|
@ -232,21 +225,17 @@ function fetchSong() {
|
|||
document.getElementById("song-name").innerText = title;
|
||||
document.getElementById("song-cover").src = ! image ? "https://lastfm.freetls.fastly.net/i/u/64s/4128a6eb29f94943c9d206c08e625904.jpg" : image;
|
||||
document.getElementById("song-url").href = track.url;
|
||||
})
|
||||
.catch(error => {
|
||||
}).catch(error => {
|
||||
console.error("Error:", error);
|
||||
});
|
||||
}
|
||||
|
||||
function fetchWeather(location) {
|
||||
const target = document.getElementById('weather');
|
||||
const query = location ? location : "muc";
|
||||
fetch(`https://wttr.in/${query}?format=%t | %C`)
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
const query = location ? location : "munich";
|
||||
fetch(`https://wttr.in/${query}?format=%t | %C`).then(response => response.text()).then(data => {
|
||||
target.innerText = data;
|
||||
})
|
||||
.catch(() => {
|
||||
}).catch(() => {
|
||||
target.innerText = "Weather unavailable";
|
||||
});
|
||||
}
|
||||
|
@ -257,8 +246,7 @@ const messages = [
|
|||
"Reverse Engineering",
|
||||
"Playing Counter-Strike",
|
||||
"Visual Artistry",
|
||||
"swagman",
|
||||
|
||||
"swagman"
|
||||
];
|
||||
|
||||
let currentMessageIndex = 0;
|
||||
|
@ -275,9 +263,7 @@ function typeWriter() {
|
|||
} else {
|
||||
displayText = currentMessage.substring(0, currentCharIndex + 1);
|
||||
currentCharIndex++;
|
||||
}
|
||||
|
||||
displayText += "<span id='typewriter-line'>|</span>";
|
||||
} displayText += "<span id='typewriter-line'>|</span>";
|
||||
document.getElementById('hobbies').innerHTML = displayText;
|
||||
|
||||
if (! isDeleting && currentCharIndex === currentMessage.length + 1) {
|
||||
|
@ -321,7 +307,10 @@ setInterval(() => {
|
|||
fetchSong();
|
||||
}
|
||||
const refreshElem = document.getElementById('refresh');
|
||||
if (refreshElem) refreshElem.dataset.tooltip = `Refresh in ${countdown}`;
|
||||
if (refreshElem)
|
||||
refreshElem.dataset.tooltip = `Refresh in ${countdown}`;
|
||||
|
||||
|
||||
}, 1000);
|
||||
|
||||
function closeOverlay(popupId, overlayId) {
|
||||
|
@ -341,7 +330,20 @@ function openOverlay(popupId, overlayId) {
|
|||
overlay.style.opacity = '1';
|
||||
}
|
||||
|
||||
document.getElementById('banan').addEventListener('click', () => { openOverlay("music-pop", "overlay")});
|
||||
document.getElementById('close').addEventListener('click', () => { closeOverlay("music-pop", "overlay")});
|
||||
document.getElementById('overlay').addEventListener('click', () => { closeOverlay("music-pop", "overlay")});
|
||||
document.getElementById('banan').addEventListener('click', () => {
|
||||
openOverlay("music-pop", "overlay")
|
||||
});
|
||||
|
||||
document.getElementById('close').addEventListener('click', () => {
|
||||
closeOverlay("music-pop", "overlay")
|
||||
});
|
||||
|
||||
document.getElementById('overlay').addEventListener('click', () => {
|
||||
closeOverlay("music-pop", "overlay")
|
||||
});
|
||||
|
||||
document.addEventListener("keydown", function (e) {
|
||||
if (e.key === "Escape") closeOverlay("music-pop", "overlay");
|
||||
});
|
||||
|
||||
document.getElementById('refresh').addEventListener('click', fetchSong);
|
||||
|
|
|
@ -125,7 +125,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="overlay"></div>
|
||||
<div id="overlay" tabindex="0"></div>
|
||||
|
||||
<footer class="cards">
|
||||
<p id="copyright">© 2025 zyqunix - all rights reserved</p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue