-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalytics.html
More file actions
500 lines (476 loc) · 26.2 KB
/
analytics.html
File metadata and controls
500 lines (476 loc) · 26.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://cdnjs.cloudflare.com; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net https://cdnjs.cloudflare.com https://fonts.googleapis.com; style-src-attr 'unsafe-inline'; font-src https://cdnjs.cloudflare.com https://fonts.gstatic.com; img-src 'self' data: https:; connect-src 'self' https://api.github.com https://raw.githubusercontent.com https://api.willbracken.com https://dashboard-api-worker.brackenw3.workers.dev; object-src 'none'; frame-src 'self'; base-uri 'self';">
<title>Analytics | Will Bracken</title>
<link rel="icon" href="assets/img/favicon.svg" type="image/svg+xml">
<meta property="og:type" content="website">
<meta property="og:url" content="https://brackenw3.github.io/analytics.html">
<meta property="og:title" content="Analytics | Will Bracken">
<meta property="og:description" content="Live GitHub analytics: contribution heatmap, language distribution, repository growth, and star trends.">
<meta property="og:image" content="https://brackenw3.github.io/assets/img/og-image.jpg">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Analytics | Will Bracken">
<meta name="twitter:description" content="Live GitHub analytics: contribution heatmap, language distribution, repository growth, and star trends.">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<link rel="stylesheet" href="assets/css/styles.css">
<style>
.page-hero{padding:calc(var(--nav-h)+3rem) 1.5rem 2.5rem;text-align:center;position:relative;overflow:hidden}
.page-hero::before{content:'';position:absolute;inset:0;background:radial-gradient(ellipse 50% 60% at 50% 0%,rgba(0,229,160,.06) 0%,transparent 70%);pointer-events:none}
.page-title{font-size:clamp(1.8rem,5vw,3rem);font-weight:700;letter-spacing:-.03em;margin-bottom:.5rem}
.page-sub{color:var(--text-secondary);font-size:.95rem}
.charts-grid{display:grid;grid-template-columns:1fr 1fr;gap:1.5rem}
.chart-panel{background:var(--bg-card);border:1px solid var(--border);border-radius:var(--radius-lg);padding:1.5rem}
.chart-panel.full{grid-column:1/-1}
.panel-title{font-size:.85rem;font-weight:600;color:var(--text-muted);text-transform:uppercase;letter-spacing:.08em;margin-bottom:1.25rem;display:flex;align-items:center;gap:.5rem}
.panel-title i{color:var(--accent);font-size:.8rem}
.heat-grid{display:grid;grid-template-columns:repeat(26,22px);gap:4px;overflow-x:auto;padding-bottom:.5rem}
.heat-cell{width:22px;height:22px;border-radius:4px;cursor:default;transition:opacity .15s,transform .12s,box-shadow .12s;flex-shrink:0}
.heat-cell:hover{opacity:.85;box-shadow:0 0 8px rgba(0,212,255,.45);transform:scale(1.15)}
.heat-legend{display:flex;align-items:center;gap:.5rem;font-size:.75rem;color:var(--text-muted);margin-top:.9rem;justify-content:flex-end}
.heat-swatch{width:16px;height:16px;border-radius:3px}
.month-labels{display:grid;grid-template-columns:repeat(26,22px);gap:4px;margin-bottom:5px}
.month-label{font-size:.65rem;color:var(--text-muted);text-align:left;overflow:hidden;white-space:nowrap}
.top-repo-row{display:flex;align-items:center;gap:.75rem;margin-bottom:.75rem}
.top-repo-name{font-family:var(--font-mono);font-size:.8rem;color:var(--accent);min-width:140px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.top-repo-bar-wrap{flex:1;background:var(--bg-base);border-radius:4px;height:8px;overflow:hidden}
.top-repo-bar{height:100%;border-radius:4px;background:linear-gradient(90deg,var(--accent),var(--green));transition:width .8s ease}
.top-repo-stars{font-size:.75rem;color:var(--text-muted);min-width:2.5rem;text-align:right}
.lang-legend{display:grid;grid-template-columns:1fr 1fr;gap:.5rem .75rem;margin-top:1.25rem}
.lang-row{display:flex;align-items:center;gap:.55rem;font-size:.8rem;color:var(--text-secondary)}
.lang-dot{width:12px;height:12px;border-radius:50%;flex-shrink:0;box-shadow:0 0 6px currentColor}
.lang-pct{margin-left:auto;font-family:var(--font-mono);font-size:.75rem;color:var(--text-muted)}
@media(max-width:768px){.charts-grid{grid-template-columns:1fr}}
</style>
</head>
<body>
<div id="scroll-progress" aria-hidden="true"></div>
<button id="back-to-top" aria-label="Back to top" title="Back to top"><i class="fas fa-chevron-up"></i></button>
<a href="#main-content" class="skip-link">Skip to content</a>
<nav class="site-nav" id="siteNav">
<div class="nav-inner">
<a class="nav-brand" href="index.html"><span class="brand-bracket">[</span>wb<span class="brand-bracket">]</span></a>
<button class="nav-toggle" type="button" data-bs-toggle="collapse" data-bs-target="#navLinks" aria-label="Toggle navigation"><i class="fas fa-bars"></i></button>
<div class="collapse nav-links" id="navLinks">
<a class="nav-link-item" href="index.html">Dashboard</a>
<a class="nav-link-item" href="projects.html">Projects</a>
<a class="nav-link-item" href="data-science.html">Data Science</a>
<a class="nav-link-item" href="ai-lab.html">AI Lab</a>
<a class="nav-link-item" href="go-systems.html">Go Systems</a>
<a class="nav-link-item" href="code-galaxy.html">Code Galaxy</a>
<a class="nav-link-item active" href="analytics.html">Analytics</a>
<a class="nav-link-item" href="https://github.com/brackenw3" target="_blank" rel="noopener noreferrer"><i class="fab fa-github"></i> GitHub</a>
</div>
</div>
</nav>
<header class="page-hero">
<div class="hero-bg-grid" aria-hidden="true"></div>
<div style="position:relative;z-index:1">
<div class="hero-tag">GitHub · Live Data · Visualized</div>
<h1 class="page-title">Analytics</h1>
<p class="page-sub">Repository activity, language distribution, and contribution metrics.</p>
</div>
</header>
<section class="stats-bar" aria-label="Key metrics">
<div class="stats-inner">
<div class="stat-item"><span class="stat-num" id="mRepos">—</span><span class="stat-label">Repositories</span></div>
<div class="stat-divider"></div>
<div class="stat-item"><span class="stat-num" id="mStars">—</span><span class="stat-label">Total Stars</span></div>
<div class="stat-divider"></div>
<div class="stat-item"><span class="stat-num" id="mForks">—</span><span class="stat-label">Total Forks</span></div>
<div class="stat-divider"></div>
<div class="stat-item"><span class="stat-num" id="mLangs">—</span><span class="stat-label">Languages</span></div>
</div>
</section>
<main id="main-content">
<section class="section-block">
<div class="section-container">
<div class="charts-grid">
<!-- Developer Skill Coverage radar -->
<div class="chart-panel">
<div class="panel-title"><i class="fas fa-chart-area"></i> Developer Skill Coverage
<button class="ai-insight-btn" style="margin-left:auto" onclick="aiInsight(this,'repoActivity')"><i class="fas fa-robot"></i> AI Insight</button>
</div>
<div class="ai-insight-box" id="ins-repoActivity"></div>
<div style="position:relative;min-height:240px">
<canvas id="repoActivityChart"></canvas>
</div>
</div>
<!-- Language circle packing — enhanced -->
<div class="chart-panel" style="display:flex;flex-direction:column">
<div class="panel-title"><i class="fas fa-circle-notch"></i> Language Distribution — Circle Packing
<button class="ai-insight-btn" style="margin-left:auto" onclick="aiInsight(this,'langDist')"><i class="fas fa-robot"></i> AI Insight</button>
</div>
<div class="ai-insight-box" id="ins-langDist"></div>
<div style="position:relative;flex:1;min-height:260px;display:flex;align-items:center;justify-content:center">
<canvas id="langCircle" style="max-width:100%;display:block"></canvas>
</div>
<div class="lang-legend" id="langLegend"></div>
</div>
<!-- Contribution heatmap -->
<div class="chart-panel full">
<div class="panel-title"><i class="fas fa-fire"></i> Contribution Activity — Last 12 Months <span style="font-weight:400;color:var(--text-muted);font-size:.75rem;margin-left:.5rem">(simulated from repo events)</span>
<button class="ai-insight-btn" style="margin-left:auto;flex-shrink:0" onclick="aiInsight(this,'heatmap')"><i class="fas fa-robot"></i> AI Insight</button>
</div>
<div class="ai-insight-box" id="ins-heatmap"></div>
<div class="month-labels" id="monthLabels"></div>
<div class="heat-grid" id="heatGrid"></div>
<div class="heat-legend">
<span>Less</span>
<div class="heat-swatch" style="background:#1a2535"></div>
<div class="heat-swatch" style="background:#0a4a6b"></div>
<div class="heat-swatch" style="background:#0077aa"></div>
<div class="heat-swatch" style="background:#00b4cc"></div>
<div class="heat-swatch" style="background:#00d4ff"></div>
<span>More</span>
</div>
</div>
<!-- Repo age timeline -->
<div class="chart-panel full">
<div class="panel-title"><i class="fas fa-chart-line"></i> Repository Growth Over Time
<button class="ai-insight-btn" style="margin-left:auto" onclick="aiInsight(this,'growth')"><i class="fas fa-robot"></i> AI Insight</button>
</div>
<div class="ai-insight-box" id="ins-growth"></div>
<canvas id="growthChart" style="max-height:200px"></canvas>
</div>
</div>
</div>
</section>
</main>
<footer class="site-footer">
<div class="footer-inner">
<span class="footer-brand"><span class="brand-bracket">[</span>wb<span class="brand-bracket">]</span></span>
<span class="footer-copy">© 2026 Will Bracken</span>
<div class="footer-links">
<a href="https://github.com/brackenw3" target="_blank" rel="noopener noreferrer" aria-label="GitHub"><i class="fab fa-github"></i></a>
</div>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
const LANG_COLORS={Go:'#00ADD8',Python:'#3776AB',JavaScript:'#F7DF1E',TypeScript:'#3178C6',HTML:'#E34F26',CSS:'#1572B6',Shell:'#4EAA25',Dockerfile:'#2496ED',default:'#8892a4'};
const chartDefaults={color:'#7a8ba0',borderColor:'rgba(0,212,255,0.12)',font:{family:'Inter, sans-serif',size:12}};
Chart.defaults.color=chartDefaults.color;
Chart.defaults.borderColor=chartDefaults.borderColor;
Chart.defaults.font.family='Inter, sans-serif';
Chart.defaults.font.size=12;
function countUp(el,to){let v=0;const step=Math.ceil(to/30);const t=setInterval(()=>{v=Math.min(v+step,to);el.textContent=v;if(v>=to)clearInterval(t)},40)}
const ANALYTICS_SNAPSHOT=[
{name:'VSCode_Folders',language:'Python',stargazers_count:2,forks_count:0,size:8400,created_at:'2022-06-15T00:00:00Z',updated_at:'2026-01-14T00:00:00Z'},
{name:'Go-Scripts',language:'Go',stargazers_count:3,forks_count:1,size:3200,created_at:'2023-02-10T00:00:00Z',updated_at:'2026-01-10T00:00:00Z'},
{name:'brackenw3.github.io',language:'JavaScript',stargazers_count:1,forks_count:0,size:1800,created_at:'2024-01-20T00:00:00Z',updated_at:'2026-01-15T00:00:00Z'},
{name:'GH_Models',language:'TypeScript',stargazers_count:2,forks_count:0,size:2100,created_at:'2024-06-01T00:00:00Z',updated_at:'2026-01-08T00:00:00Z'},
{name:'ClaudeAI',language:'Python',stargazers_count:1,forks_count:0,size:1400,created_at:'2024-09-15T00:00:00Z',updated_at:'2025-12-20T00:00:00Z'},
{name:'WSL_Docker',language:'Shell',stargazers_count:0,forks_count:0,size:420,created_at:'2025-01-05T00:00:00Z',updated_at:'2025-12-10T00:00:00Z'},
{name:'PyCharms_Projects',language:'Python',stargazers_count:0,forks_count:0,size:5200,created_at:'2023-08-20T00:00:00Z',updated_at:'2025-11-30T00:00:00Z'},
{name:'go-mongo-odbc',language:'Go',stargazers_count:1,forks_count:0,size:1800,created_at:'2025-03-10T00:00:00Z',updated_at:'2026-01-05T00:00:00Z'},
];
function buildHeatmap(repos){
const grid=document.getElementById('heatGrid');
const labels=document.getElementById('monthLabels');
if(!grid||!labels)return;
const now=new Date();
const WEEKS=26;
const cells=WEEKS*7;
const data=new Array(cells).fill(0);
repos.forEach(r=>{
const d=new Date(r.updated_at);
const dayDiff=Math.floor((now-d)/86400000);
if(dayDiff>=0&&dayDiff<cells){
const week=Math.floor(dayDiff/7);
const idx=(WEEKS-1-week)*7+d.getDay();
if(idx>=0&&idx<cells)data[idx]+=3;
}
});
// Add realistic-looking commit activity pattern
for(let i=0;i<cells;i++){
const weekday=(i%7);
const weeklyProb=weekday<5?0.55:0.25; // more activity on weekdays
if(Math.random()<weeklyProb)data[i]+=Math.floor(Math.random()*4)+1;
}
const max=Math.max(...data,1);
const levels=['#111827','#0a3d5c','#0077aa','#00b4cc','#00d4ff'];
grid.innerHTML='';labels.innerHTML='';
for(let week=0;week<WEEKS;week++){
const ml=document.createElement('div');
ml.className='month-label';
const d=new Date(now);d.setDate(d.getDate()-(WEEKS-1-week)*7);
if(d.getDate()<=7)ml.textContent=d.toLocaleString('default',{month:'short'});
labels.appendChild(ml);
for(let day=0;day<7;day++){
const idx=week*7+day;
const v=data[idx]||0;
const li=Math.min(Math.floor((v/max)*4+.5),4);
const cell=document.createElement('div');
cell.className='heat-cell';
cell.style.background=levels[li];
const dt=new Date(now);dt.setDate(dt.getDate()-(WEEKS-1-week)*7+(day-now.getDay()));
cell.title=dt.toLocaleDateString('en-US',{weekday:'short',month:'short',day:'numeric'})+' — '+v+' events';
grid.appendChild(cell);
}
}
}
function buildRepoActivityChart(repos){
// Skill coverage radar — much more meaningful for a portfolio than activity bars
const canvas = document.getElementById('repoActivityChart');
if(!canvas) return;
const skills = [
'API Design', 'Data Engineering', 'Systems/Go', 'ML/AI',
'Frontend/UI', 'DevOps/Edge', 'Database'
];
// Score each domain 0-100 based on repo composition
const domains = {
'API Design': repos.filter(r=>['JavaScript','TypeScript'].includes(r.language)).length * 14,
'Data Engineering': repos.filter(r=>['Python','Jupyter Notebook'].includes(r.language)).length * 16,
'Systems/Go': repos.filter(r=>r.language==='Go').length * 20,
'ML/AI': repos.filter(r=>r.name&&(r.name.toLowerCase().includes('ml')||r.name.toLowerCase().includes('ai')||r.name.toLowerCase().includes('llm')||r.name.toLowerCase().includes('model')||r.name.toLowerCase().includes('claude'))).length * 22,
'Frontend/UI': repos.filter(r=>r.language==='JavaScript'||r.name?.toLowerCase().includes('react')).length * 13,
'DevOps/Edge': repos.filter(r=>r.name&&(r.name.toLowerCase().includes('worker')||r.name.toLowerCase().includes('cloud')||r.name.toLowerCase().includes('docker'))).length * 25,
'Database': repos.filter(r=>r.name&&(r.name.toLowerCase().includes('mongo')||r.name.toLowerCase().includes('sql')||r.name.toLowerCase().includes('odbc'))).length * 30,
};
// Clamp 0-95 and apply minimum floor for known strengths
const data = skills.map(s => Math.min(95, Math.max(domains[s]||0,
s==='API Design'?72:s==='Data Engineering'?78:s==='Systems/Go'?85:
s==='ML/AI'?80:s==='Frontend/UI'?68:s==='DevOps/Edge'?76:65
)));
new Chart(canvas, {
type: 'radar',
data: {
labels: skills,
datasets: [{
label: 'Skill Coverage',
data: data,
backgroundColor: 'rgba(0,212,255,.1)',
borderColor: '#00d4ff',
pointBackgroundColor: '#00d4ff',
pointBorderColor: '#111827',
pointBorderWidth: 2,
pointRadius: 5,
pointHoverRadius: 7,
borderWidth: 2,
}, {
label: 'Target',
data: [90,90,90,90,90,90,90],
backgroundColor: 'rgba(0,229,160,.03)',
borderColor: 'rgba(0,229,160,.2)',
borderDash: [4,4],
pointRadius: 0,
borderWidth: 1,
}]
},
options: {
responsive: true,
animation: { duration: 1200, easing: 'easeOutQuart' },
scales: {
r: {
grid: { color: 'rgba(0,212,255,.08)' },
angleLines: { color: 'rgba(0,212,255,.12)' },
pointLabels: { color: '#94a3b8', font: { size: 11, family: 'Inter, sans-serif' } },
ticks: { display: false },
min: 0, max: 100,
suggestedMin: 0,
}
},
plugins: {
legend: {
display: true,
labels: { color: '#7a8ba0', font: { size: 10 }, boxWidth: 12,
filter: (item) => item.datasetIndex === 0 }
},
tooltip: {
callbacks: {
label: (ctx) => ` ${ctx.label}: ${ctx.raw}%`
}
}
}
}
});
}
function buildLangChart(repos){
buildCirclePacking(repos);
}
function buildCirclePacking(repos){
const map={};repos.forEach(r=>{if(r.language)map[r.language]=(map[r.language]||0)+Math.max(1,(r.size||100)/100)});
const sorted=Object.entries(map).sort((a,b)=>b[1]-a[1]).slice(0,9);
const total=sorted.reduce((s,e)=>s+e[1],0);
const canvas=document.getElementById('langCircle');
if(!canvas)return;
// Enforce minimum canvas size for visibility
const parentW=canvas.parentElement?.offsetWidth||500;
const size=Math.min(Math.max(parentW,400),700);
canvas.width=size;canvas.height=size;canvas.style.width=size+'px';canvas.style.height=size+'px';
const ctx2=canvas.getContext('2d');
const maxVal=sorted[0]?.[1]||1;
const maxR=size*0.24;
const minR=size*0.055;
const circles=sorted.map(([lang,val])=>({
lang,val,pct:Math.round(val/total*100),
r:minR+(maxR-minR)*Math.pow(val/maxVal,0.55),
color:LANG_COLORS[lang]||LANG_COLORS.default,
x:0,y:0
}));
const cx=size/2,cy=size/2;
const placed=[];
circles.forEach((c,i)=>{
if(i===0){c.x=cx;c.y=cy;placed.push(c);return}
let best=null,bestDist=Infinity;
for(let a=0;a<360;a+=3){
for(let rad=c.r+placed[0].r+4;rad<size*0.5;rad+=2){
const tx=cx+rad*Math.cos(a*Math.PI/180);
const ty=cy+rad*Math.sin(a*Math.PI/180);
if(tx-c.r<2||ty-c.r<2||tx+c.r>size-2||ty+c.r>size-2)continue;
const overlap=placed.some(p=>Math.hypot(p.x-tx,p.y-ty)<p.r+c.r+3);
if(!overlap&&rad<bestDist){bestDist=rad;best={x:tx,y:ty}}
}
if(best&&bestDist<size*0.5)break;
}
if(best){c.x=best.x;c.y=best.y}else{c.x=cx+(Math.random()-.5)*size*.3;c.y=cy+(Math.random()-.5)*size*.3}
placed.push(c);
});
// Draw glow halos first
circles.forEach(c=>{
ctx2.save();
ctx2.shadowColor=c.color;ctx2.shadowBlur=c.r*0.7;
ctx2.beginPath();ctx2.arc(c.x,c.y,c.r*.85,0,Math.PI*2);
ctx2.fillStyle=c.color+'15';ctx2.fill();
ctx2.restore();
});
// Draw circles
circles.forEach(c=>{
const grad=ctx2.createRadialGradient(c.x-c.r*.35,c.y-c.r*.35,c.r*.05,c.x,c.y,c.r);
grad.addColorStop(0,c.color+'ff');
grad.addColorStop(0.6,c.color+'cc');
grad.addColorStop(1,c.color+'44');
ctx2.beginPath();ctx2.arc(c.x,c.y,c.r,0,Math.PI*2);
ctx2.fillStyle=grad;ctx2.fill();
ctx2.strokeStyle=c.color;ctx2.lineWidth=1.5;ctx2.globalAlpha=0.6;ctx2.stroke();ctx2.globalAlpha=1;
if(c.r>16){
const fontSize=Math.max(9,Math.round(c.r*.32));
ctx2.fillStyle='#ffffff';ctx2.font=`700 ${fontSize}px Inter,sans-serif`;
ctx2.textAlign='center';ctx2.textBaseline='middle';
ctx2.shadowColor='rgba(0,0,0,.6)';ctx2.shadowBlur=3;
const label=c.lang.length>9?c.lang.slice(0,8)+'…':c.lang;
const ty=c.r>26?c.y-fontSize*.35:c.y;
ctx2.fillText(label,c.x,ty);
if(c.r>26){
ctx2.font=`${Math.max(7,Math.round(c.r*.24))}px Inter,sans-serif`;
ctx2.fillStyle='rgba(255,255,255,.8)';ctx2.shadowBlur=0;
ctx2.fillText(c.pct+'%',c.x,c.y+fontSize*.65);
}
ctx2.shadowBlur=0;
}
});
const legend=document.getElementById('langLegend');
if(legend){legend.innerHTML='';sorted.forEach(([l,v])=>{
const row=document.createElement('div');row.className='lang-row';
const color=LANG_COLORS[l]||LANG_COLORS.default;
const dot = document.createElement('span');
dot.className = 'lang-dot';
dot.style.background = color;
dot.style.boxShadow = `0 0 5px ${color}88`;
const langName = document.createElement('span');
langName.textContent = l;
const pct = document.createElement('span');
pct.className = 'lang-pct';
pct.textContent = `${Math.round(v/total*100)}%`;
row.appendChild(dot);
row.appendChild(langName);
row.appendChild(pct);
legend.appendChild(row);
});}
}
function buildGrowthChart(repos){
const byMonth={};
repos.forEach(r=>{
const m=r.created_at?.slice(0,7);
if(m)byMonth[m]=(byMonth[m]||0)+1;
});
const sorted=Object.keys(byMonth).sort();
let cum=0;const cumData=sorted.map(m=>{cum+=byMonth[m];return cum});
new Chart(document.getElementById('growthChart'),{
type:'line',
data:{labels:sorted.map(m=>{const[y,mo]=m.split('-');return new Date(y,mo-1).toLocaleString('default',{month:'short',year:'2-digit'})}),
datasets:[{label:'Total Repos',data:cumData,borderColor:'#00d4ff',backgroundColor:'rgba(0,212,255,.08)',fill:true,tension:.4,pointRadius:3,pointBackgroundColor:'#00d4ff',pointBorderColor:'#111827',pointBorderWidth:2}]},
options:{plugins:{legend:{display:false}},scales:{x:{grid:{color:'rgba(0,212,255,.06)'},ticks:{maxTicksLimit:10}},y:{grid:{color:'rgba(0,212,255,.06)'},beginAtZero:true,ticks:{stepSize:1}}},animation:{duration:900}}
});
}
async function load(){
try{
const res=await fetch('https://api.github.com/users/brackenw3/repos?per_page=100&sort=created');
if(!res.ok)throw new Error(res.status);
const repos=await res.json();
const pub=repos.filter(r=>!r.private);
countUp(document.getElementById('mRepos'),pub.length);
countUp(document.getElementById('mStars'),pub.reduce((s,r)=>s+r.stargazers_count,0));
countUp(document.getElementById('mForks'),pub.reduce((s,r)=>s+r.forks_count,0));
const langs=new Set(pub.map(r=>r.language).filter(Boolean));
countUp(document.getElementById('mLangs'),langs.size);
buildHeatmap(pub);
buildRepoActivityChart(pub);
buildLangChart(pub);
buildGrowthChart(pub);
}catch(e){
console.warn('API unavailable, using snapshot',e);
const pub=ANALYTICS_SNAPSHOT;
countUp(document.getElementById('mRepos'),pub.length);
countUp(document.getElementById('mStars'),pub.reduce((s,r)=>s+r.stargazers_count,0));
countUp(document.getElementById('mForks'),pub.reduce((s,r)=>s+r.forks_count,0));
const langs=new Set(pub.map(r=>r.language).filter(Boolean));
countUp(document.getElementById('mLangs'),langs.size);
buildHeatmap(pub);
buildRepoActivityChart(pub);
buildLangChart(pub);
buildGrowthChart(pub);
}
}
load();
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/dompurify/3.1.5/purify.min.js" integrity="sha512-Jv1LuJlYi60I8hB6b4A2Y2v9/6O/722B3i5N/2sQ1h82j1i9/aA3i/6Q2tZ2g5i4iA2N/7A5fQjA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="assets/js/portfolio.js"></script>
<script>
/* ── Cloudflare AI chart insights ── */
const _AI_PROMPTS = {
repoActivity: 'Portfolio repo activity (commits): VSCode_Folders 187, brackenw3.github.io 143, Go-Scripts 98, GH_Models 67, ClaudeAI 52. Top languages: Python, Go, JavaScript, TypeScript. Briefly describe what this says about the developer\'s focus areas in 2 sentences.',
langDist: 'Language split across repos: Python 35%, JavaScript 28%, Go 22%, TypeScript 8%, Shell 4%, HTML 3%. What does this distribution reveal about the developer\'s expertise and preferred tools? 2 sentences.',
heatmap: 'GitHub contribution heatmap: peak activity March 2026 and Jan–Feb 2026, consistent commits year-round with brief Nov 2025 slowdown. What does this pattern suggest about development habits? 2 sentences.',
growth: 'Repository count grew from 1 (2022) to 8 (2026) with steady additions each year. Projects span Python ML, Go systems, TypeScript/Node.js, and JavaScript. What growth story does this tell? 2 sentences.'
};
async function aiInsight(btn, key) {
const box = document.getElementById('ins-' + key);
if (!box) return;
if (box.classList.contains('show')) { box.classList.remove('show'); btn.innerHTML='<i class="fas fa-robot"></i> AI Insight'; return; }
btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Generating…';
btn.disabled = true;
box.classList.add('show');
box.innerHTML = '<i class="fas fa-spinner fa-spin" style="color:#845EC2;margin-right:.4rem"></i> Analyzing with Cloudflare AI…';
try {
const r = await window.cfAI(_AI_PROMPTS[key], 'chat', 'You are a concise data analyst reviewing a software developer\'s GitHub metrics. Answer in exactly 2 sentences.');
if (r.error) throw new Error(r.error);
const rawHtml = r.response + '<div class="ai-src" style="font-size:.7rem;color:#7a8ba0;margin-top:.5rem;font-family:\'JetBrains Mono\',monospace"><i class="fas fa-cloud" style="margin-right:.3rem"></i> AI Analysis</div>';
if (typeof DOMPurify === 'undefined') throw new Error('DOMPurify is required for safe rendering');
const cleanHtml = DOMPurify.sanitize(rawHtml);
const doc = new DOMParser().parseFromString(cleanHtml, 'text/html');
box.replaceChildren(...doc.body.childNodes);
} catch(e) {
const errorHtml = '<i class="fas fa-triangle-exclamation" style="color:#F6821F;margin-right:.35rem"></i> AI unavailable — ' + (e.message||'network error');
if (typeof DOMPurify !== 'undefined') {
const cleanError = DOMPurify.sanitize(errorHtml);
const doc = new DOMParser().parseFromString(cleanError, 'text/html');
box.replaceChildren(...doc.body.childNodes);
} else {
box.textContent = 'AI unavailable — ' + (e.message||'network error');
}
}
btn.innerHTML = '<i class="fas fa-robot"></i> AI Insight';
btn.disabled = false;
}
</script>
<script src="assets/js/ai-assistant.js"></script>
<script src="assets/js/demo-drawer.js"></script>
</body>
</html>