site: add GitHub-like language bar (Java 49.4% Python 25.4% JS 12.7% CSS 7.3% HTML 3.5% Go 1.7% — 32k loc) + live fetch from GitHub/Gitea API
This commit is contained in:
@@ -417,6 +417,26 @@
|
|||||||
<a href="https://git.swe.zernmc.ru/sasheg/launcher" target="_blank" rel="noopener" class="btn btn-ghost" style="flex:1;justify-content:center"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"/></svg> Открыть в Gitea</a>
|
<a href="https://git.swe.zernmc.ru/sasheg/launcher" target="_blank" rel="noopener" class="btn btn-ghost" style="flex:1;justify-content:center"><svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"/></svg> Открыть в Gitea</a>
|
||||||
<a href="https://github.com/SashegDev/launcher" target="_blank" rel="noopener" class="btn btn-ghost" style="flex:1;justify-content:center">GitHub зеркало</a>
|
<a href="https://github.com/SashegDev/launcher" target="_blank" rel="noopener" class="btn btn-ghost" style="flex:1;justify-content:center">GitHub зеркало</a>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Languages bar like GitHub -->
|
||||||
|
<div style="margin-top:4px">
|
||||||
|
<div style="display:flex;height:8px;border-radius:4px;overflow:hidden;background:var(--border);gap:1px" id="lang-bar" title="Java 49.4% · Python 25.4% · JavaScript 12.7% · CSS 7.3% · HTML 3.5% · Go 1.7%">
|
||||||
|
<div style="flex:49.4;background:#b07219" title="Java 49.4%"></div>
|
||||||
|
<div style="flex:25.4;background:#3572A5" title="Python 25.4%"></div>
|
||||||
|
<div style="flex:12.7;background:#f1e05a" title="JavaScript 12.7%"></div>
|
||||||
|
<div style="flex:7.3;background:#563d7c" title="CSS 7.3%"></div>
|
||||||
|
<div style="flex:3.5;background:#e34c26" title="HTML 3.5%"></div>
|
||||||
|
<div style="flex:1.7;background:#00ADD8" title="Go 1.7%"></div>
|
||||||
|
</div>
|
||||||
|
<div style="display:flex;flex-wrap:wrap;gap:12px;margin-top:8px;font-size:12px;color:var(--text-secondary)" id="lang-legend">
|
||||||
|
<span style="display:flex;align-items:center;gap:6px"><i style="width:10px;height:10px;border-radius:50%;background:#b07219;display:inline-block"></i> Java 49.4%</span>
|
||||||
|
<span style="display:flex;align-items:center;gap:6px"><i style="width:10px;height:10px;border-radius:50%;background:#3572A5;display:inline-block"></i> Python 25.4%</span>
|
||||||
|
<span style="display:flex;align-items:center;gap:6px"><i style="width:10px;height:10px;border-radius:50%;background:#f1e05a;display:inline-block"></i> JavaScript 12.7%</span>
|
||||||
|
<span style="display:flex;align-items:center;gap:6px"><i style="width:10px;height:10px;border-radius:50%;background:#563d7c;display:inline-block"></i> CSS 7.3%</span>
|
||||||
|
<span style="display:flex;align-items:center;gap:6px"><i style="width:10px;height:10px;border-radius:50%;background:#e34c26;display:inline-block"></i> HTML 3.5%</span>
|
||||||
|
<span style="display:flex;align-items:center;gap:6px"><i style="width:10px;height:10px;border-radius:50%;background:#00ADD8;display:inline-block"></i> Go 1.7%</span>
|
||||||
|
</div>
|
||||||
|
<p style="font-size:11px;color:var(--text-muted);margin-top:6px">32 120 строк · Java 15 858 · Python 8 172 · JS 4 083 · CSS 2 345 · HTML 1 110 · Go 552</p>
|
||||||
|
</div>
|
||||||
<code style="font-size:12px;background:var(--bg-surface);border:1px solid var(--border);border-radius:8px;padding:8px 10px;color:var(--text-secondary);overflow:auto">git clone ssh://git@git.swe.zernmc.ru:2222/sasheg/launcher.git</code>
|
<code style="font-size:12px;background:var(--bg-surface);border:1px solid var(--border);border-radius:8px;padding:8px 10px;color:var(--text-secondary);overflow:auto">git clone ssh://git@git.swe.zernmc.ru:2222/sasheg/launcher.git</code>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -719,6 +719,43 @@
|
|||||||
if (el) el.textContent = new Date().getFullYear();
|
if (el) el.textContent = new Date().getFullYear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function loadGithubLanguages() {
|
||||||
|
const bar = document.getElementById('lang-bar');
|
||||||
|
const legend = document.getElementById('lang-legend');
|
||||||
|
if (!bar || !legend) return;
|
||||||
|
const colors = { Java:'#b07219', Python:'#3572A5', JavaScript:'#f1e05a', TypeScript:'#3178c6', CSS:'#563d7c', HTML:'#e34c26', Go:'#00ADD8', Rust:'#dea584', Shell:'#89e051', Dockerfile:'#384d54' };
|
||||||
|
const tryFetch = async (url) => {
|
||||||
|
const r = await fetch(url, {headers:{'Accept':'application/vnd.github.v3+json'}});
|
||||||
|
if (!r.ok) throw new Error(url);
|
||||||
|
return r.json();
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
let data = null;
|
||||||
|
try { data = await tryFetch('https://api.github.com/repos/SashegDev/launcher/languages'); } catch(e) {
|
||||||
|
try { data = await tryFetch('https://git.swe.zernmc.ru/api/v1/repos/sasheg/launcher/languages'); } catch(e2) {}
|
||||||
|
}
|
||||||
|
if (!data || typeof data !== 'object') return;
|
||||||
|
const total = Object.values(data).reduce((a,b)=>a+b,0);
|
||||||
|
if (!total) return;
|
||||||
|
const entries = Object.entries(data).map(([lang, bytes])=>({lang, bytes, pct: bytes/total*100})).sort((a,b)=>b.bytes-a.bytes).slice(0,6);
|
||||||
|
// update bar
|
||||||
|
bar.innerHTML = '';
|
||||||
|
bar.title = entries.map(e=>`${e.lang} ${e.pct.toFixed(1)}%`).join(' · ');
|
||||||
|
legend.innerHTML = '';
|
||||||
|
entries.forEach(e=>{
|
||||||
|
const seg = document.createElement('div');
|
||||||
|
seg.style.flex = String(e.pct);
|
||||||
|
seg.style.background = colors[e.lang] || 'var(--accent)';
|
||||||
|
seg.title = `${e.lang} ${e.pct.toFixed(1)}%`;
|
||||||
|
bar.appendChild(seg);
|
||||||
|
const item = document.createElement('span');
|
||||||
|
item.style.display='flex'; item.style.alignItems='center'; item.style.gap='6px';
|
||||||
|
item.innerHTML = `<i style="width:10px;height:10px;border-radius:50%;background:${colors[e.lang]||'var(--accent)'};display:inline-block"></i> ${e.lang} ${e.pct.toFixed(1)}%`;
|
||||||
|
legend.appendChild(item);
|
||||||
|
});
|
||||||
|
} catch(e) { /* keep static fallback */ }
|
||||||
|
}
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
applyI18n();
|
applyI18n();
|
||||||
|
|
||||||
@@ -730,6 +767,7 @@
|
|||||||
loadNews();
|
loadNews();
|
||||||
loadServerStatus();
|
loadServerStatus();
|
||||||
setInterval(loadServerStatus, 15000);
|
setInterval(loadServerStatus, 15000);
|
||||||
|
loadGithubLanguages();
|
||||||
initCarousel();
|
initCarousel();
|
||||||
initPreview();
|
initPreview();
|
||||||
initNav();
|
initNav();
|
||||||
|
|||||||
Reference in New Issue
Block a user