Skip to content

Commit 4208b01

Browse files
committed
assets update
1 parent a080260 commit 4208b01

File tree

2 files changed

+145
-1
lines changed

2 files changed

+145
-1
lines changed

assets/css/style.css

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,55 @@ a {
398398
transform: translateY(1px);
399399
box-shadow: inset 0 -20px 25px -5px rgb(244 39 116 / 18%);
400400
}
401+
.pop-page-header {
402+
margin-bottom: 30px;
403+
text-align: center;
404+
}
405+
.pop-page-header h1 {
406+
margin-bottom: 10px;
407+
}
408+
#repo-list {
409+
display: flex;
410+
flex-direction: column;
411+
gap: 10px;
412+
margin-bottom: 20px;
413+
}
414+
.repo-entry {
415+
background: #f8fafd;
416+
border: 1px solid #e1e4e8;
417+
border-radius: 5px;
418+
padding: 12px 16px;
419+
font-size: 1.05em;
420+
display: flex;
421+
align-items: center;
422+
gap: 10px;
423+
transition: box-shadow 0.2s;
424+
}
425+
.repo-entry:hover {
426+
box-shadow: 0 2px 8px rgba(3,102,214,0.08);
427+
background: #f0f6ff;
428+
}
429+
.repo-entry i {
430+
font-size: 1.2em;
431+
color: #0366d6;
432+
min-width: 22px;
433+
text-align: center;
434+
}
435+
#load-more-btn {
436+
display: block;
437+
margin: 0 auto 10px auto;
438+
padding: 8px 24px;
439+
background: #0366d6;
440+
color: #fff;
441+
border: none;
442+
border-radius: 4px;
443+
font-size: 1em;
444+
cursor: pointer;
445+
transition: background 0.2s;
446+
}
447+
#load-more-btn:hover {
448+
background: #024fa2;
449+
}
401450
.footer {
402451
text-align: center;
403452
padding: .5em 1em;

assets/js/script.js

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,15 @@ function parseURL() {
144144
}
145145

146146
// Skip URL parsing for specific pages we want to preserve
147-
const specialPages = ['/popular-repos/', '/popular-repos', '/popular-repos.html'];
147+
const specialPages = ['/popular-repos', '/popular-repos.html'];
148148
if (specialPages.includes(window.location.pathname)) {
149149
// Special page identified, ensure visibility of container if needed
150150
if (window.location.pathname.includes('popular-repos')) {
151151
const popularRepoContainer = document.getElementById('popular-repos-container');
152152
if (popularRepoContainer) {
153153
popularRepoContainer.style.display = 'block';
154+
// Initialize popular repos pagination if needed
155+
initializePopularRepos();
154156
}
155157
}
156158
return; // Don't process URLs for special pages
@@ -861,3 +863,96 @@ themeToggle.addEventListener('click', () => {
861863
trackEvent('UI', 'ThemeToggle', isDarkMode ? 'dark' : 'light');
862864
}
863865
});
866+
867+
// --- Popular Repos Page Functions ---
868+
function initializePopularRepos() {
869+
const categoryButtons = document.querySelectorAll('.category-btn');
870+
const categoryOptions = document.querySelectorAll('.category-option');
871+
const repoEntries = document.querySelectorAll('.repo-entry');
872+
const loadMoreBtn = document.getElementById('load-more-btn');
873+
874+
// Skip if elements aren't found (not on popular repos page)
875+
if (!categoryButtons.length || !repoEntries.length || !loadMoreBtn) return;
876+
877+
let visibleCount = 0;
878+
const PAGE_SIZE = 15;
879+
let currentCategory = 'all';
880+
881+
function showReposByCategory(category) {
882+
let shown = 0;
883+
repoEntries.forEach(entry => {
884+
if (category === 'all' || entry.classList.contains(category)) {
885+
if (shown < PAGE_SIZE) {
886+
entry.style.display = '';
887+
shown++;
888+
} else {
889+
entry.style.display = 'none';
890+
}
891+
} else {
892+
entry.style.display = 'none';
893+
}
894+
});
895+
visibleCount = shown;
896+
// Show load more button if there are more to show
897+
let totalInCategory = Array.from(repoEntries).filter(entry =>
898+
category === 'all' || entry.classList.contains(category)).length;
899+
loadMoreBtn.style.display = (visibleCount < totalInCategory) ? '' : 'none';
900+
}
901+
902+
function loadMoreRepos() {
903+
let shown = 0;
904+
let loaded = 0;
905+
repoEntries.forEach(entry => {
906+
if ((currentCategory === 'all' || entry.classList.contains(currentCategory))) {
907+
if (entry.style.display !== 'none') {
908+
shown++;
909+
}
910+
}
911+
});
912+
repoEntries.forEach(entry => {
913+
if ((currentCategory === 'all' || entry.classList.contains(currentCategory))) {
914+
if (entry.style.display === 'none' && loaded < PAGE_SIZE) {
915+
entry.style.display = '';
916+
loaded++;
917+
}
918+
}
919+
});
920+
visibleCount += loaded;
921+
let totalInCategory = Array.from(repoEntries).filter(entry =>
922+
currentCategory === 'all' || entry.classList.contains(currentCategory)).length;
923+
loadMoreBtn.style.display = (visibleCount < totalInCategory) ? '' : 'none';
924+
}
925+
926+
// Initial show
927+
showReposByCategory('all');
928+
929+
// Category button click
930+
categoryButtons.forEach(button => {
931+
button.addEventListener('click', function() {
932+
categoryButtons.forEach(btn => btn.classList.remove('active'));
933+
this.classList.add('active');
934+
currentCategory = this.getAttribute('data-category');
935+
showReposByCategory(currentCategory);
936+
});
937+
});
938+
939+
categoryOptions.forEach(option => {
940+
option.addEventListener('click', function(e) {
941+
e.preventDefault();
942+
categoryButtons.forEach(btn => btn.classList.remove('active'));
943+
document.querySelector(`[data-category="${this.getAttribute('data-category')}"]`).classList.add('active');
944+
currentCategory = this.getAttribute('data-category');
945+
showReposByCategory(currentCategory);
946+
});
947+
});
948+
949+
loadMoreBtn.addEventListener('click', loadMoreRepos);
950+
}
951+
952+
// Call initialize on DOMContentLoaded (in case we navigate directly to the page)
953+
document.addEventListener('DOMContentLoaded', function() {
954+
// If we're on the popular repos page, initialize it
955+
if (window.location.pathname.includes('popular-repos')) {
956+
initializePopularRepos();
957+
}
958+
});

0 commit comments

Comments
 (0)