Skip to content

Commit b7d546e

Browse files
fix: resolve project content unavailable error and dashboard stats TypeError
1 parent 561e4fc commit b7d546e

2 files changed

Lines changed: 37 additions & 74 deletions

File tree

web-app/index.html

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -968,51 +968,52 @@ <h3>${proj.title}</h3>
968968

969969
// Update counts
970970
const total = projectsData.length;
971-
function animateCounter(id,value){
972-
973-
let start=0;
974-
975-
const element=document.getElementById(id);
976-
977-
const timer=setInterval(()=>{
978-
979-
start++;
980-
981-
element.textContent=start;
982-
983-
if(start>=value){
984-
985-
clearInterval(timer);
986-
987-
}
988-
989-
},25);
971+
function animateCounter(id, value) {
972+
const element = document.getElementById(id);
973+
if (!element) return;
974+
975+
let start = 0;
976+
// If target value is 0, set immediately and exit
977+
if (value <= 0) {
978+
element.textContent = "0";
979+
return;
980+
}
990981

991-
}
982+
const timer = setInterval(() => {
983+
start++;
984+
element.textContent = start;
985+
if (start >= value) {
986+
clearInterval(timer);
987+
}
988+
}, 25);
989+
}
992990
const games = projectsData.filter((p) => p.category === "games").length;
993991
const math = projectsData.filter((p) => p.category === "math").length;
994992
const utils = projectsData.filter(
995993
(p) => p.category === "utilities"
996994
).length;
997995

998-
const heroCount = document.getElementById("heroProjectCount");
999-
const heroGames = document.getElementById("heroGameCount");
1000-
const heroMath = document.getElementById("heroMathCount");
1001-
const heroUtils = document.getElementById("heroUtilityCount");
1002996
const projectBadge = document.getElementById("projectCountBadge");
1003-
1004-
if (heroCount) heroCount.textContent = total;
1005-
if (heroGames) heroGames.textContent = games;
1006-
if (heroMath) heroMath.textContent = math;
1007-
if (heroUtils) heroUtils.textContent = utils;
1008997
if (projectBadge) projectBadge.textContent = total + " projects";
1009-
animateCounter("statsTotal",total);
1010-
animateCounter("statsGames",games);
1011-
animateCounter("statsMath",math);
1012-
animateCounter("statsUtilities",utils);
1013-
document.getElementById("statsFavorites").textContent = favorites.length;
1014-
const viewed= JSON.parse(localStorage.getItem("recentlyViewed")||"[]");
1015-
animateCounter("statsViewed",viewed.length);
998+
999+
// Animate the actual hero counters that exist on the page
1000+
animateCounter("heroProjectCount", total);
1001+
animateCounter("heroGameCount", games);
1002+
animateCounter("heroMathCount", math);
1003+
animateCounter("heroUtilityCount", utils);
1004+
animateCounter("heroFavoriteCount", favorites.length);
1005+
1006+
const viewed = JSON.parse(localStorage.getItem("recentlyViewed") || "[]");
1007+
animateCounter("heroViewedCount", viewed.length);
1008+
1009+
// Safe updates for the statistics dashboard cards in case they exist
1010+
animateCounter("statsTotal", total);
1011+
animateCounter("statsGames", games);
1012+
animateCounter("statsMath", math);
1013+
animateCounter("statsUtilities", utils);
1014+
const statsFavoritesEl = document.getElementById("statsFavorites");
1015+
if (statsFavoritesEl) statsFavoritesEl.textContent = favorites.length;
1016+
animateCounter("statsViewed", viewed.length);
10161017

10171018
console.log(
10181019
`✅ Loaded ${total} projects: ${games} games, ${math} math, ${utils} utilities`

web-app/js/projects.js

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,7 @@
11
// Project Registry
22
// Each project's HTML and logic lives in its own file under js/projects/
33

4-
function getProjectHTML(projectName) {
5-
const projects = {
6-
"rock-paper-scissor": getRockPaperScissorHTML(),
7-
"dice-rolling": getDiceRollingHTML(),
8-
"coin-flip": getCoinFlipHTML(),
9-
"number-guessing": getNumberGuessingHTML(),
10-
hangman: getHangmanHTML(),
11-
flames: getFlamesHTML(),
12-
fibonacci: getFibonacciHTML(),
13-
"progression-recognizer": getProgressionRecognizerHTML(),
14-
"pascal-triangle": getPascalTriangleHTML(),
15-
armstrong: getArmstrongHTML(),
16-
calculator: getCalculatorHTML(),
17-
collatz: getCollatzHTML(),
18-
"prime-analyzer": getPrimeAnalyzerHTML(),
19-
"projectile-motion": getProjectileMotionHTML(),
20-
"coordinate-polar-transform": getCoordinatePolarTransformHTML(),
21-
"complete-calculus-engine": getCompleteCalculusEngineHTML(),
22-
"morse-code": getMorseCodeHTML(),
23-
"tower-of-hanoi": getTowerOfHanoiHTML(),
24-
nqueens: getNQueensHTML(),
25-
"matrix-calculator": () => getMatrixCalculatorHTML(),
26-
"sudoku-game": getSudokuGameHTML(),
27-
"unit-converter": getUnitConverterHTML(),
28-
"resume-analyzer": getResumeAnalyzerHTML(),
29-
"reverse-hangman": () => getReverseHangmanHTML(),
30-
"budget-tracker": getBudgetTrackerHTML(),
31-
"snake-game": getSnakeGameHTML(),
32-
"sorting-visualizer": getSortingVisualizerHTML(),
33-
"quick-sort": getQuickSortHTML(),
34-
"fourier-series": getFourierSeriesHTML(),
35-
"merge-sort": getMergeSortHTML(),
36-
"pathfinding-visualizer": getPathfindingVisualizerHTML(),
37-
"tsp-visualizer": getTspVisualizerHTML(),
38-
'minesweeper': getMinesweeperHTML()
39-
};
404

41-
return projects[projectName] || "<h2>Project Coming Soon!</h2>";
42-
}
435

446
function toPascalCase(str) {
457
if (str === "2048-game") return "2048Game";

0 commit comments

Comments
 (0)