Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions web-app/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,24 @@ function syncThemeColor(theme) {

document.addEventListener('DOMContentLoaded', function () {

// Sort project cards lexicographically (alphabetically) by title
var projectsGrid = document.querySelector('.projects-grid');
var rawCards = projectsGrid ? Array.from(projectsGrid.querySelectorAll('.project-card')) : [];
if (rawCards.length > 0) {
rawCards.sort(function (a, b) {
var h3A = a.querySelector('h3');
var h3B = b.querySelector('h3');
var titleA = h3A ? h3A.textContent.trim() : '';
var titleB = h3B ? h3B.textContent.trim() : '';
return titleA.localeCompare(titleB);
});
var reorderedCards = document.createDocumentFragment();
rawCards.forEach(function (card) {
reorderedCards.appendChild(card);
});
Comment thread
nishtha-agarwal-211 marked this conversation as resolved.
Comment on lines +53 to +63
projectsGrid.appendChild(reorderedCards);
}

// ── DOM references ──────────────────────────────────────────────
var html = document.documentElement;
var themeToggle = document.getElementById('themeToggle');
Expand Down
Loading