@@ -3,110 +3,48 @@ const GRID = document.getElementById('projectGrid');
33const THEME_BTN = document . getElementById ( 'themeBtn' ) ;
44const HTML_TAG = document . documentElement ;
55
6- // --- Dark/Light Mode Logic ---
6+ // Theme Logic
77const savedTheme = localStorage . getItem ( 'theme' ) || 'dark' ;
88HTML_TAG . setAttribute ( 'data-theme' , savedTheme ) ;
9- updateIcon ( savedTheme ) ;
109
1110THEME_BTN . addEventListener ( 'click' , ( ) => {
1211 const currentTheme = HTML_TAG . getAttribute ( 'data-theme' ) ;
1312 const newTheme = currentTheme === 'dark' ? 'light' : 'dark' ;
14-
1513 HTML_TAG . setAttribute ( 'data-theme' , newTheme ) ;
1614 localStorage . setItem ( 'theme' , newTheme ) ;
17- updateIcon ( newTheme ) ;
1815} ) ;
1916
20- function updateIcon ( theme ) {
21- const icon = THEME_BTN . querySelector ( 'i' ) ;
22- if ( theme === 'dark' ) {
23- icon . className = 'fas fa-sun' ; // Dark mode -> Show Sun
24- } else {
25- icon . className = 'fas fa-moon' ; // Light mode -> Show Moon
26- }
27- }
28-
29- // --- Fetch Projects Logic ---
17+ // Fetch Logic
3018async function fetchProjects ( ) {
3119 try {
32- // Fetch repos
3320 const res = await fetch ( `https://api.github.com/users/${ ORG_NAME } /repos?sort=pushed&per_page=100` ) ;
34-
35- if ( ! res . ok ) throw new Error ( 'GitHub API Limit or Error' ) ;
36-
21+ if ( ! res . ok ) throw new Error ( 'API Error' ) ;
3722 const repos = await res . json ( ) ;
23+
3824 GRID . innerHTML = '' ;
3925
40- // Filter logic: Remove .github and the website itself
4126 const filteredRepos = repos . filter ( repo =>
4227 repo . name !== '.github' &&
4328 repo . name !== 'Syntiox.github.io' &&
4429 repo . visibility === 'public'
4530 ) ;
4631
47- // If no projects found
4832 if ( filteredRepos . length === 0 ) {
4933 GRID . innerHTML = `
5034 <div class="empty-state">
51- <i class="fas fa-code-branch"></i>
35+ <i class="fas fa-code-branch" style="font-size: 3rem; margin-bottom: 20px;" ></i>
5236 <h3>No Public Projects Yet</h3>
5337 <p>Our repositories are currently private or under development.</p>
54- <a href="https://github.com/Syntiox" target="_blank" style="color:var(--primary); margin-top:10px; display:inline-block; text-decoration:none;">Check GitHub Profile directly →</a>
5538 </div>
5639 ` ;
5740 return ;
5841 }
5942
60- // Render Cards
61- const repoCards = await Promise . all ( filteredRepos . map ( async ( repo ) => {
62- let aboutText = repo . description || "Research & Development in progress." ;
63-
64- // Try to fetch about.md
65- try {
66- const aboutRes = await fetch ( `https://raw.githubusercontent.com/${ ORG_NAME } /${ repo . name } /main/about.md` ) ;
67- if ( aboutRes . ok ) {
68- aboutText = await aboutRes . text ( ) ;
69- // Limit text length
70- if ( aboutText . length > 200 ) aboutText = aboutText . substring ( 0 , 200 ) + "..." ;
71- }
72- } catch ( e ) { }
73-
74- return `
75- <div class="card">
76- <div>
77- <div class="card-header">
78- <div class="project-name">${ repo . name } </div>
79- <div class="repo-stats">
80- <i class="fas fa-star" style="color:#eab308"></i> ${ repo . stargazers_count }
81- </div>
82- </div>
83- <div class="description">${ escapeHtml ( aboutText ) } </div>
84- </div>
85- <a href="${ repo . html_url } " target="_blank" class="btn">
86- View Project <i class="fas fa-arrow-right"></i>
87- </a>
88- </div>
89- ` ;
90- } ) ) ;
91-
92- GRID . innerHTML = repoCards . join ( '' ) ;
43+ // Render Cards logic here... (If projects exist)
9344
9445 } catch ( error ) {
95- console . error ( error ) ;
96- GRID . innerHTML = `
97- <div class="empty-state">
98- <i class="fas fa-exclamation-triangle" style="color:red"></i>
99- <h3>System Status: Offline</h3>
100- <p>Unable to fetch repositories from GitHub API.</p>
101- </div>` ;
46+ GRID . innerHTML = `<div class="empty-state"><p>System Status: No public repositories available right now.</p></div>` ;
10247 }
10348}
10449
105- // Security: Prevent HTML injection
106- function escapeHtml ( text ) {
107- if ( ! text ) return text ;
108- return text . replace ( / & / g, "&" ) . replace ( / < / g, "<" ) . replace ( / > / g, ">" ) ;
109- }
110-
111- // Start
11250fetchProjects ( ) ;
0 commit comments