Skip to content

Fix: Resolve SyntaxError in main.js breaking all website buttons and … - #170

Merged
steam-bell-92 merged 1 commit into
steam-bell-92:mainfrom
ssuyashhhh:fix/main-js-syntax-errors
May 16, 2026
Merged

Fix: Resolve SyntaxError in main.js breaking all website buttons and …#170
steam-bell-92 merged 1 commit into
steam-bell-92:mainfrom
ssuyashhhh:fix/main-js-syntax-errors

Conversation

@ssuyashhhh

@ssuyashhhh ssuyashhhh commented May 15, 2026

Copy link
Copy Markdown

fixes #168

Screen.Recording.2026-05-16.020316.mp4

What

Fixed a critical SyntaxError: missing ) after argument list at line 443 in main.js that prevented the entire JavaScript file from executing. Also removed a stray </section> tag in index.html.

Why

The syntax error caused all interactive functionality on the website to be completely broken — category filter tabs, "Try It" buttons, Random Project button, modal open/close, theme toggle, and every game/project was non-functional because the browser halted JS parsing before any event listeners could be attached.

How

The root cause was a broken merge of two separate implementations in main.js:

  • Code running at top-level scope referenced DOM elements (themeColorMeta, themeToggle, html) that were never declared, crashing before DOMContentLoaded
  • The openProjectSafe function body (lines 428–443) was pasted without its function declaration header, leaving a stray } that caused the SyntaxError
  • Duplicate variable declarations (lastFocusedElement, tabs, projectCards, modal) conflicted between the two implementations
  • Duplicate event listeners were attached to the same elements both inside and outside DOMContentLoaded

Fix: Consolidated the entire file into a single, clean DOMContentLoaded handler with:

  • Proper function declarations for openProjectSafe and closeProjectSafe
  • All DOM queries safely inside DOMContentLoaded
  • Null-safety guards on all element references
  • No duplicate bindings or variable declarations

Additionally removed an orphaned </section> closing tag in index.html (line 62).

Testing

  • node -c main.js — zero syntax errors
  • ✅ Category filter tabs (All / Games / Math / Utilities) correctly show/hide cards
  • ✅ "Try It" buttons open project modals with correct content
  • ✅ Random Project button opens a random project modal
  • ✅ Modal close (× button, clicking backdrop, Escape key) all work
  • ✅ Theme toggle (dark/light mode) works
  • ✅ Sound toggle works
  • ✅ Back-to-top button works
  • ✅ Focus trap and keyboard accessibility in modals preserved
  • ✅ Intersection observer animations preserved
  • ✅ No console errors on page load or during interaction
  • ✅ UI/design completely unchanged

Files Changed

File Change
web-app/js/main.js Restructured into single coherent DOMContentLoaded handler, fixed all syntax errors
web-app/index.html Removed orphaned </section> tag

@vercel

vercel Bot commented May 15, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Anuj's projects Team on Vercel.

A member of the Team first needs to authorize it.

@ssuyashhhh

Copy link
Copy Markdown
Author

@steam-bell-92 i had fixed this issue and checked it from end.

@steam-bell-92
steam-bell-92 merged commit 1270069 into steam-bell-92:main May 16, 2026
4 of 5 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🎉 Thank you for your contribution!

Your Pull Request has been merged successfully.

We appreciate the time and effort you put into improving this project. Contributions like yours help the repository grow and stay useful for everyone.

If you'd like to contribute again, please check the open issues and make sure you are assigned before opening another Pull Request.

Thanks again for your support! 🙌

@github-actions

Copy link
Copy Markdown
Contributor

Thanks @ssuyashhhh! I've added you to the contributors list.

@ssuyashhhh
ssuyashhhh deleted the fix/main-js-syntax-errors branch May 16, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC 2026 approving tag level:intermediate type:bug Something isn't working type:refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix JavaScript Syntax Error Preventing Buttons and Projects from Working

2 participants