Changed around line 1
+ document.addEventListener('DOMContentLoaded', function() {
+ // Add smooth scrolling
+ document.querySelectorAll('a[href^="#"]').forEach(anchor => {
+ anchor.addEventListener('click', function (e) {
+ e.preventDefault();
+ document.querySelector(this.getAttribute('href')).scrollIntoView({
+ behavior: 'smooth'
+ });
+ });
+ });
+
+ // Add table sorting functionality
+ const tables = document.querySelectorAll('table');
+ tables.forEach(table => {
+ const headers = table.querySelectorAll('th');
+ headers.forEach((header, index) => {
+ header.addEventListener('click', () => {
+ sortTable(table, index);
+ });
+ header.style.cursor = 'pointer';
+ });
+ });
+ });
+
+ function sortTable(table, column) {
+ const tbody = table.querySelector('tbody');
+ const rows = Array.from(tbody.querySelectorAll('tr'));
+ const sortedRows = rows.sort((a, b) => {
+ const aCol = a.querySelector(`td:nth-child(${column + 1})`).textContent;
+ const bCol = b.querySelector(`td:nth-child(${column + 1})`).textContent;
+ return aCol.localeCompare(bCol, undefined, {numeric: true});
+ });
+
+ tbody.innerHTML = '';
+ sortedRows.forEach(row => tbody.appendChild(row));
+ }