mirror of
https://github.com/zyqunix/tools.git
synced 2025-07-05 14:00:31 +02:00
Compare commits
5 commits
34639c88b9
...
0db21de34d
Author | SHA1 | Date | |
---|---|---|---|
![]() |
0db21de34d | ||
![]() |
1d1e08eb63 | ||
![]() |
46a4644a4d | ||
![]() |
1e9cea0bdb | ||
![]() |
4336ce2972 |
4 changed files with 262 additions and 127 deletions
|
@ -23,7 +23,6 @@ setInterval(() => {
|
||||||
|
|
||||||
const ageElem = document.getElementById('age');
|
const ageElem = document.getElementById('age');
|
||||||
let birthday = new Date('2008-12-13');
|
let birthday = new Date('2008-12-13');
|
||||||
let age = 0;
|
|
||||||
|
|
||||||
function updateAge(elem, fix, text) {
|
function updateAge(elem, fix, text) {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
@ -112,7 +111,7 @@ function lan() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = (event) => {
|
window.onload = () => {
|
||||||
lan();
|
lan();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -241,7 +240,7 @@ function fetchWeather(location) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
wakatime.fetchWakatime("#wakapi", "zyqunix", "all_time");
|
wakatime.fetchWakatime("#wakapi");
|
||||||
|
|
||||||
const messages = [
|
const messages = [
|
||||||
"Coding",
|
"Coding",
|
||||||
|
@ -349,4 +348,4 @@ document.addEventListener("keydown", function (e) {
|
||||||
if (e.key === "Escape") closeOverlay("music-pop", "overlay");
|
if (e.key === "Escape") closeOverlay("music-pop", "overlay");
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('refresh').addEventListener('click', fetchSong);
|
document.getElementById('refresh').addEventListener('click', fetchSong);
|
||||||
|
|
|
@ -63,141 +63,277 @@ const categoryColors = {
|
||||||
coding: '#A8DADC',
|
coding: '#A8DADC',
|
||||||
building: '#F4A261',
|
building: '#F4A261',
|
||||||
debugging: '#E9C46A'
|
debugging: '#E9C46A'
|
||||||
|
};
|
||||||
|
|
||||||
|
export async function fetchWakaTimeStats(user, range) {
|
||||||
|
const response = await fetch(`https://wakapi.atums.world/api/v1/users/${user}/stats/${range}`);
|
||||||
|
if (!response.ok) throw new Error(`Error fetching WakaTime stats: ${response.statusText}`);
|
||||||
|
return await response.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fetchWakatime(targetId, user, range) {
|
export async function prepareChartData() {
|
||||||
|
const languages = await fetchWakaTimeStats("zyqunix", "all_time");
|
||||||
|
const sortedLanguages = [...languages.data.languages].sort((a, b) => b.percent - a.percent);
|
||||||
|
|
||||||
|
const totalSeconds = sortedLanguages.reduce((total, lang) => total + lang.total_seconds, 0);
|
||||||
|
let totalTime = '';
|
||||||
|
|
||||||
|
if (totalSeconds > 3600) {
|
||||||
|
totalTime = `${Math.floor(totalSeconds / 3600)}h ${Math.floor((totalSeconds % 3600) / 60)}m`;
|
||||||
|
} else {
|
||||||
|
totalTime = `${Math.floor(totalSeconds / 60)}m`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const limit = 10;
|
||||||
|
const topLanguages = sortedLanguages.slice(0, limit);
|
||||||
|
|
||||||
|
if (sortedLanguages.length > limit) {
|
||||||
|
const otherSeconds = sortedLanguages.slice(limit).reduce((total, lang) => total + lang.total_seconds, 0);
|
||||||
|
const otherPercent = sortedLanguages.slice(limit).reduce((total, lang) => total + lang.percent, 0);
|
||||||
|
|
||||||
|
let otherText = '';
|
||||||
|
if (otherSeconds > 3600) {
|
||||||
|
otherText = `${Math.floor(otherSeconds / 3600)}h ${Math.floor((otherSeconds % 3600) / 60)}m`;
|
||||||
|
} else {
|
||||||
|
otherText = `${Math.floor(otherSeconds / 60)}m`;
|
||||||
|
}
|
||||||
|
|
||||||
|
topLanguages.push({
|
||||||
|
name: 'Other',
|
||||||
|
total_seconds: otherSeconds,
|
||||||
|
percent: otherPercent,
|
||||||
|
text: otherText,
|
||||||
|
color: '#CCCCCC',
|
||||||
|
digital: '',
|
||||||
|
hours: Math.floor(otherSeconds / 3600),
|
||||||
|
minutes: Math.floor((otherSeconds % 3600) / 60),
|
||||||
|
seconds: otherSeconds % 60
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const segmentsWithColors = topLanguages.map(lang => ({
|
||||||
|
...lang,
|
||||||
|
color: lang.color || langColors[lang.name] || '#CCCCCC'
|
||||||
|
}));
|
||||||
|
|
||||||
|
return {
|
||||||
|
segments: segmentsWithColors,
|
||||||
|
totalTime
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function fetchWakatime(targetId) {
|
||||||
|
const data = await fetchWakaTimeStats("zyqunix", "all_time");
|
||||||
const target = document.querySelector(`${targetId}`);
|
const target = document.querySelector(`${targetId}`);
|
||||||
target.innerHTML = "";
|
target.innerHTML = "";
|
||||||
fetch(`https://wakapi.atums.world/api/v1/users/${user}/stats/${range}`).then(response => response.json()).then(data => {
|
|
||||||
|
|
||||||
const langDetails = document.createElement("details");
|
const langDetails = document.createElement("details");
|
||||||
const langSummary = document.createElement("summary");
|
const langSummary = document.createElement("summary");
|
||||||
langSummary.innerText = "Languages";
|
langSummary.innerText = "Languages";
|
||||||
langSummary.classList.add("tooltip");
|
langSummary.classList.add("tooltip");
|
||||||
langSummary.setAttribute("data-tooltip", "Most Used Languages");
|
langSummary.setAttribute("data-tooltip", "Most Used Languages");
|
||||||
langDetails.appendChild(langSummary);
|
langDetails.appendChild(langSummary);
|
||||||
langDetails.style.marginTop = "15px";
|
langDetails.style.marginTop = "15px";
|
||||||
target.appendChild(langDetails);
|
target.appendChild(langDetails);
|
||||||
|
|
||||||
const topLangs = data.data.languages.slice(0, 10);
|
const topLangs = data.data.languages.slice(0, 10);
|
||||||
topLangs.forEach(lang => {
|
topLangs.forEach(lang => {
|
||||||
const el = document.createElement("div");
|
const el = document.createElement("div");
|
||||||
el.innerText = `${lang.name}: ${lang.text}`;
|
el.innerText = `${lang.name}: ${lang.text}`;
|
||||||
el.id = lang.name.toLowerCase();
|
el.id = lang.name.toLowerCase();
|
||||||
el.classList.add("proglang");
|
el.classList.add("proglang");
|
||||||
el.style.margin = "5px";
|
el.style.margin = "5px";
|
||||||
el.style.padding = "10px";
|
el.style.padding = "10px";
|
||||||
el.style.borderRadius = "5px";
|
el.style.borderRadius = "5px";
|
||||||
el.style.backgroundColor = langColors[lang.name];
|
el.style.backgroundColor = langColors[lang.name];
|
||||||
el.style.color = "var(--base)";
|
el.style.color = "var(--base)";
|
||||||
langDetails.appendChild(el);
|
langDetails.appendChild(el);
|
||||||
});
|
});
|
||||||
|
|
||||||
const edDetails = document.createElement("details");
|
const edDetails = document.createElement("details");
|
||||||
const edSummary = document.createElement("summary");
|
const edSummary = document.createElement("summary");
|
||||||
edSummary.innerText = "Editors";
|
edSummary.innerText = "Editors";
|
||||||
edSummary.classList.add("tooltip");
|
edSummary.classList.add("tooltip");
|
||||||
edSummary.setAttribute("data-tooltip", "Most Used Editors");
|
edSummary.setAttribute("data-tooltip", "Most Used Editors");
|
||||||
edDetails.appendChild(edSummary);
|
edDetails.appendChild(edSummary);
|
||||||
edDetails.style.marginTop = "15px";
|
edDetails.style.marginTop = "15px";
|
||||||
target.appendChild(edDetails);
|
target.appendChild(edDetails);
|
||||||
|
|
||||||
const topEditors = data.data.editors.slice(0, 5);
|
const topEditors = data.data.editors.slice(0, 5);
|
||||||
topEditors.forEach(editor => {
|
topEditors.forEach(editor => {
|
||||||
const el = document.createElement("div");
|
const el = document.createElement("div");
|
||||||
el.innerText = `In ${editor.name} for ${editor.text} (${editor.percent}%)`;
|
el.innerText = `In ${editor.name} for ${editor.text} (${editor.percent}%)`;
|
||||||
el.style.margin = "5px";
|
el.style.margin = "5px";
|
||||||
el.style.padding = "10px";
|
el.style.padding = "10px";
|
||||||
el.style.borderRadius = "5px";
|
el.style.borderRadius = "5px";
|
||||||
el.style.color = "var(--base)";
|
el.style.color = "var(--base)";
|
||||||
el.style.backgroundColor = editorColors[editor.name.toLowerCase().replace(/\s+/g, '').replace(/[^a-zA-Z]/g, '')];
|
el.style.backgroundColor = editorColors[editor.name.toLowerCase().replace(/\s+/g, '').replace(/[^a-zA-Z]/g, '')];
|
||||||
edDetails.appendChild(el);
|
edDetails.appendChild(el);
|
||||||
});
|
});
|
||||||
|
|
||||||
const prDetails = document.createElement("details");
|
const prDetails = document.createElement("details");
|
||||||
const prSummary = document.createElement("summary");
|
const prSummary = document.createElement("summary");
|
||||||
prSummary.innerText = "Projects";
|
prSummary.innerText = "Projects";
|
||||||
prSummary.classList.add("tooltip");
|
prSummary.classList.add("tooltip");
|
||||||
prSummary.setAttribute("data-tooltip", "Most Used Projects");
|
prSummary.setAttribute("data-tooltip", "Most Used Projects");
|
||||||
prDetails.appendChild(prSummary);
|
prDetails.appendChild(prSummary);
|
||||||
prDetails.style.marginTop = "15px";
|
prDetails.style.marginTop = "15px";
|
||||||
target.appendChild(prDetails);
|
target.appendChild(prDetails);
|
||||||
|
|
||||||
const topProjects = data.data.projects.slice(0, 10);
|
const topProjects = data.data.projects.slice(0, 10);
|
||||||
topProjects.forEach(project => {
|
topProjects.forEach(project => {
|
||||||
const el = document.createElement("div");
|
const el = document.createElement("div");
|
||||||
el.innerText = `Coded ${project.name} for ${project.text}`;
|
el.innerText = `Coded ${project.name} for ${project.text}`;
|
||||||
el.style.margin = "5px";
|
el.style.margin = "5px";
|
||||||
el.style.padding = "10px";
|
el.style.padding = "10px";
|
||||||
el.style.borderRadius = "5px";
|
el.style.borderRadius = "5px";
|
||||||
el.style.color = "var(--base)";
|
el.style.color = "var(--base)";
|
||||||
el.style.backgroundColor = projectColors[Math.floor(Math.random() * projectColors.length)];
|
el.style.backgroundColor = projectColors[Math.floor(Math.random() * projectColors.length)];
|
||||||
prDetails.appendChild(el);
|
prDetails.appendChild(el);
|
||||||
});
|
});
|
||||||
|
|
||||||
const osDetails = document.createElement("details");
|
const osDetails = document.createElement("details");
|
||||||
const osSummary = document.createElement("summary");
|
const osSummary = document.createElement("summary");
|
||||||
osSummary.innerText = "Operating Systems";
|
osSummary.innerText = "Operating Systems";
|
||||||
osSummary.classList.add("tooltip");
|
osSummary.classList.add("tooltip");
|
||||||
osSummary.setAttribute("data-tooltip", "Most Used Operating Systems");
|
osSummary.setAttribute("data-tooltip", "Most Used Operating Systems");
|
||||||
osDetails.appendChild(osSummary);
|
osDetails.appendChild(osSummary);
|
||||||
osDetails.style.marginTop = "15px";
|
osDetails.style.marginTop = "15px";
|
||||||
target.appendChild(osDetails);
|
target.appendChild(osDetails);
|
||||||
|
|
||||||
const topOS = data.data.operating_systems;
|
const topOS = data.data.operating_systems;
|
||||||
topOS.forEach(machine => {
|
topOS.forEach(machine => {
|
||||||
const el = document.createElement('div');
|
const el = document.createElement('div');
|
||||||
el.innerText = `Coded on ${machine.name} for ${machine.text}`;
|
el.innerText = `Coded on ${machine.name} for ${machine.text}`;
|
||||||
el.style.margin = "5px";
|
el.style.margin = "5px";
|
||||||
el.style.padding = "10px";
|
el.style.padding = "10px";
|
||||||
el.style.borderRadius = "5px";
|
el.style.borderRadius = "5px";
|
||||||
el.style.color = "var(--base)";
|
el.style.color = "var(--base)";
|
||||||
el.style.backgroundColor = osColors[machine.name.toLowerCase()];
|
el.style.backgroundColor = osColors[machine.name.toLowerCase()];
|
||||||
osDetails.appendChild(el);
|
osDetails.appendChild(el);
|
||||||
});
|
});
|
||||||
|
|
||||||
const caDetails = document.createElement("details");
|
const caDetails = document.createElement("details");
|
||||||
const caSummary = document.createElement("summary");
|
const caSummary = document.createElement("summary");
|
||||||
caSummary.innerText = "Categories";
|
caSummary.innerText = "Categories";
|
||||||
caSummary.classList.add("tooltip");
|
caSummary.classList.add("tooltip");
|
||||||
caSummary.setAttribute("data-tooltip", "Time Spent by Category");
|
caSummary.setAttribute("data-tooltip", "Time Spent by Category");
|
||||||
caDetails.appendChild(caSummary);
|
caDetails.appendChild(caSummary);
|
||||||
caDetails.style.marginTop = "15px";
|
caDetails.style.marginTop = "15px";
|
||||||
target.appendChild(caDetails);
|
target.appendChild(caDetails);
|
||||||
|
|
||||||
const categories = data.data.categories;
|
const categories = data.data.categories;
|
||||||
categories.forEach(category => {
|
categories.forEach(category => {
|
||||||
const el = document.createElement('div');
|
const el = document.createElement('div');
|
||||||
el.style.margin = "5px";
|
el.style.margin = "5px";
|
||||||
el.style.padding = "10px";
|
el.style.padding = "10px";
|
||||||
el.style.borderRadius = "5px";
|
el.style.borderRadius = "5px";
|
||||||
el.style.color = "var(--base)";
|
el.style.color = "var(--base)";
|
||||||
el.style.backgroundColor = categoryColors[category.name.toLowerCase()];
|
el.style.backgroundColor = categoryColors[category.name.toLowerCase()];
|
||||||
el.innerText = `Has done ${category.name} for ${category.text}`;
|
el.innerText = `Has done ${category.name} for ${category.text}`;
|
||||||
caDetails.appendChild(el);
|
caDetails.appendChild(el);
|
||||||
});
|
});
|
||||||
|
|
||||||
const miscDetails = document.createElement("details");
|
const miscDetails = document.createElement("details");
|
||||||
const miscSummary = document.createElement("summary");
|
const miscSummary = document.createElement("summary");
|
||||||
miscSummary.innerText = "Miscellaneous";
|
miscSummary.innerText = "Miscellaneous";
|
||||||
miscSummary.classList.add("tooltip");
|
miscSummary.classList.add("tooltip");
|
||||||
miscSummary.setAttribute("data-tooltip", "Miscellaneous Coding Info");
|
miscSummary.setAttribute("data-tooltip", "Miscellaneous Wakatime Info");
|
||||||
miscDetails.appendChild(miscSummary);
|
miscDetails.appendChild(miscSummary);
|
||||||
miscDetails.style.marginTop = "15px";
|
miscDetails.style.marginTop = "15px";
|
||||||
target.appendChild(miscDetails);
|
target.appendChild(miscDetails);
|
||||||
|
|
||||||
const el = document.createElement("div");
|
const el = document.createElement("div");
|
||||||
el.innerHTML = `
|
el.innerHTML = `
|
||||||
Total Coding Time: ${data.data.human_readable_total}
|
Total Coding Time: ${data.data.human_readable_total}
|
||||||
<br>
|
<br>
|
||||||
Daily Average: ${data.data.human_readable_daily_average}
|
Daily Average: ${data.data.human_readable_daily_average}
|
||||||
<br>
|
<br>
|
||||||
Days Since Register: ${data.data.days_including_holidays}
|
Days Since Register: ${data.data.days_including_holidays}
|
||||||
`;
|
`;
|
||||||
miscDetails.appendChild(el);
|
miscDetails.appendChild(el);
|
||||||
|
|
||||||
|
document.getElementById("stats_since").innerText = `Registered on ${data.data.start}`;
|
||||||
|
|
||||||
|
const chartDetails = document.createElement("details");
|
||||||
|
const chartSummary = document.createElement("summary");
|
||||||
|
chartSummary.innerText = "Chart";
|
||||||
|
chartSummary.classList.add("tooltip");
|
||||||
|
chartSummary.setAttribute("data-tooltip", "Miscellaneous Coding Info");
|
||||||
|
chartDetails.appendChild(chartSummary);
|
||||||
|
chartDetails.style.marginTop = "15px";
|
||||||
|
target.appendChild(chartDetails);
|
||||||
|
|
||||||
|
const chartData = await prepareChartData();
|
||||||
|
|
||||||
|
|
||||||
|
const svgNS = "http://www.w3.org/2000/svg";
|
||||||
|
const radius = 50;
|
||||||
|
const center = 60;
|
||||||
|
const strokeWidth = 20;
|
||||||
|
const circumference = 2 * Math.PI * radius;
|
||||||
|
|
||||||
|
const container = document.createElement("div");
|
||||||
|
|
||||||
|
const legend = document.createElement("div");
|
||||||
|
legend.style.display = 'flex';
|
||||||
|
legend.style.flexDirection = 'column';
|
||||||
|
legend.style.gap = '8px';
|
||||||
|
legend.id = 'legend';
|
||||||
|
|
||||||
|
chartData.segments.forEach(segment => {
|
||||||
|
const label = document.createElement('div');
|
||||||
|
label.style.display = 'flex';
|
||||||
|
label.style.alignItems = 'center';
|
||||||
|
label.style.gap = '8px';
|
||||||
|
|
||||||
|
const colorBox = document.createElement('span');
|
||||||
|
colorBox.style.width = '10px';
|
||||||
|
colorBox.style.height = '10px';
|
||||||
|
colorBox.style.backgroundColor = segment.color;
|
||||||
|
colorBox.style.borderRadius = '3px';
|
||||||
|
|
||||||
|
const text = document.createElement('span');
|
||||||
|
text.innerText = `${segment.name} (${segment.text})`;
|
||||||
|
|
||||||
|
label.appendChild(colorBox);
|
||||||
|
label.appendChild(text);
|
||||||
|
legend.appendChild(label);
|
||||||
|
});
|
||||||
|
|
||||||
|
const chart = document.createElementNS(svgNS, "svg");
|
||||||
|
chart.setAttribute("viewBox", "0 0 120 120");
|
||||||
|
chart.style.width = "120px";
|
||||||
|
chart.style.height = "120px";
|
||||||
|
|
||||||
|
let cumulativePercent = 0;
|
||||||
|
|
||||||
|
chartData.segments.forEach(segment => {
|
||||||
|
const circle = document.createElementNS(svgNS, "circle");
|
||||||
|
circle.setAttribute("cx", center);
|
||||||
|
circle.setAttribute("cy", center);
|
||||||
|
circle.setAttribute("r", radius);
|
||||||
|
circle.setAttribute("fill", "none");
|
||||||
|
circle.setAttribute("stroke", segment.color);
|
||||||
|
circle.setAttribute("stroke-width", strokeWidth);
|
||||||
|
circle.setAttribute("transform", `rotate(-90 ${center} ${center})`);
|
||||||
|
|
||||||
|
const segmentLength = (segment.percent / 100) * circumference;
|
||||||
|
const emptyLength = circumference - segmentLength;
|
||||||
|
|
||||||
|
circle.setAttribute("stroke-dasharray", `${segmentLength} ${emptyLength}`);
|
||||||
|
circle.setAttribute("stroke-dashoffset", circumference * (1 - cumulativePercent / 100));
|
||||||
|
|
||||||
|
cumulativePercent += segment.percent;
|
||||||
|
|
||||||
|
chart.appendChild(circle);
|
||||||
|
});
|
||||||
|
|
||||||
|
container.appendChild(legend);
|
||||||
|
container.appendChild(chart);
|
||||||
|
|
||||||
|
chartDetails.appendChild(container);
|
||||||
|
|
||||||
document.getElementById("stats_since").innerText = `Registered on ${data.data.start}`;
|
|
||||||
}).catch(() => {
|
|
||||||
target.innerHTML = `<img class="stat-img" src="https://github-readme-stats.vercel.app/api/wakatime?username=${user}&theme=transparent&hide_border=true&layout=compact">`;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(await fetchWakaTimeStats("zyqunix", "all_time"));
|
||||||
|
|
|
@ -12,12 +12,12 @@
|
||||||
<meta property="og:image" content="https://rimgo.pussthecat.org/RFbdMMB.png">
|
<meta property="og:image" content="https://rimgo.pussthecat.org/RFbdMMB.png">
|
||||||
|
|
||||||
<link rel="shortcut icon" href="https://easyfiles.cc/2024/4/e0482551-b6a6-4739-bf0a-758756e8c464/RFbdMMB.png" type="image/x-icon">
|
<link rel="shortcut icon" href="https://easyfiles.cc/2024/4/e0482551-b6a6-4739-bf0a-758756e8c464/RFbdMMB.png" type="image/x-icon">
|
||||||
|
<script src="https://app.rybbit.io/api/script.js" data-site-id="1005" defer ></script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<script src="https://cdn.jsdelivr.net/gh/0x5841524f4e/js-lanyard/lanyard.js"></script>
|
<script src="https://cdn.jsdelivr.net/gh/0x5841524f4e/js-lanyard/lanyard.js"></script>
|
||||||
<script disable-devtool-auto="" src="htps://cdn.jsdelivr.net/npm/disable-devtool@latest"></script>
|
<script disable-devtool-auto="" src="https://cdn.jsdelivr.net/npm/disable-devtool@latest"></script>
|
||||||
|
|
||||||
<div class="video-container">
|
<div class="video-container">
|
||||||
<video id="videoPlayer"></video>
|
<video id="videoPlayer"></video>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<link href="assets/css/style.css" rel="stylesheet" />
|
<link href="assets/css/style.css" rel="stylesheet" />
|
||||||
<link rel="shortcut icon" href="https://rimgo.pussthecat.org/RFbdMMB.png" type="image/x-icon">
|
<link rel="shortcut icon" href="https://rimgo.pussthecat.org/RFbdMMB.png" type="image/x-icon">
|
||||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||||
|
<script src="https://app.rybbit.io/api/script.js" data-site-id="1005" defer ></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="info" id="Info">
|
<div class="info" id="Info">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue