Skip to content
Draft
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ <h1>Course Registration System</h1>
<i class="fas fa-user-check"></i>
Registrations
</a>
<button id="theme-toggle" class="theme-toggle" onclick="toggleTheme()" aria-label="Toggle theme" title="Toggle dark/light mode">
<i class="fas fa-moon"></i>
<i class="fas fa-sun"></i>
</button>
</nav>
</div>
</header>
Expand Down
23 changes: 23 additions & 0 deletions frontend/script.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
// Configuration
const API_BASE_URL = 'http://localhost:5210/api';

// Theme Management
function initializeTheme() {
// Get saved theme from localStorage or default to 'light'
const savedTheme = localStorage.getItem('theme') || 'light';
applyTheme(savedTheme);
}

function toggleTheme() {
const currentTheme = document.documentElement.getAttribute('data-theme') || 'light';
const newTheme = currentTheme === 'light' ? 'dark' : 'light';
applyTheme(newTheme);
localStorage.setItem('theme', newTheme);
}

function applyTheme(theme) {
document.documentElement.setAttribute('data-theme', theme);
// The CSS handles the icon visibility through the data-theme attribute
}

// Export theme functions
window.toggleTheme = toggleTheme;

// DOM Elements
const addCourseForm = document.getElementById('add-course-form');
const submitBtn = document.getElementById('submit-btn');
Expand All @@ -9,6 +31,7 @@ const loadingOverlay = document.getElementById('loading-overlay');

// Initialize the application
document.addEventListener('DOMContentLoaded', function() {
initializeTheme();
initializeForm();
loadCourses();
updateNavigation();
Expand Down
Loading
Loading