Skip to content

Commit 76da1d1

Browse files
committed
Added the Feature of removing the Dark Mode State whenever the user Logs out or closes the window/tab. Fixed a bug where Light Mode turns on then back off whenever a Submit Button is pressed. Changed the redirection of the Login Button to the Customer Login Portal.
1 parent 490e89d commit 76da1d1

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

WebApplication2/Customer/Pages/CustomerComponent.aspx

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@
460460
<a href="#" onclick="showSection('unresolvedTickets')">Unresolved Tickets</a>
461461
<a href="#" onclick="showSection('remainingExtraAmount')">Remaining & Extra Amounts</a>
462462
<a href="mailto:yehiarasheed@gmail.com"> Support</a>
463-
<a href="login.aspx" onclick="logout()">Log Out</a>
463+
<a href="/Customer/Pages/login.aspx" class="back-button" onclick="clearDarkModeState(); logout();">Log Out</a>
464464

465465
</div>
466466
<!-- Dark Mode Toggle Button -->
@@ -664,22 +664,21 @@
664664
function toggleDarkMode() {
665665
const body = document.body;
666666
body.classList.toggle('dark-mode');
667-
body.classList.toggle('light-mode');
668667
669668
// Change the mode icon
670669
const icon = document.getElementById('modeIcon');
671670
if (body.classList.contains('dark-mode')) {
672671
icon.src = "https://img.icons8.com/?size=100&id=83221&format=png&color=FAB005"; // Sun for light mode
673-
localStorage.setItem('darkMode', 'true'); // Save dark mode state
672+
sessionStorage.setItem('darkMode', 'true'); // Save dark mode state
674673
} else {
675674
icon.src = "https://img.icons8.com/?size=100&id=59841&format=png&color=FFFFFF"; // Half Moon for dark mode
676-
localStorage.removeItem('darkMode'); // Remove dark mode state
675+
sessionStorage.removeItem('darkMode'); // Remove dark mode state
677676
}
678677
}
679678
680679
document.addEventListener("DOMContentLoaded", function () {
681-
// Check if dark mode is enabled in localStorage
682-
if (localStorage.getItem("darkMode") === "true") {
680+
// Check if dark mode is enabled in sessionStorage
681+
if (sessionStorage.getItem("darkMode") === "true") {
683682
document.body.classList.add("dark-mode");
684683
document.body.classList.remove("light-mode");
685684
document.getElementById('modeIcon').src = "https://img.icons8.com/?size=100&id=83221&format=png&color=FAB005"; // Sun for light mode
@@ -689,6 +688,18 @@
689688
document.getElementById('modeIcon').src = "https://img.icons8.com/?size=100&id=59841&format=png&color=FFFFFF"; // Half Moon for dark mode
690689
}
691690
});
691+
692+
// Function to clear dark-mode state
693+
function clearDarkModeState() {
694+
sessionStorage.removeItem('darkMode');
695+
}
696+
697+
window.addEventListener('load', function () {
698+
if (sessionStorage.getItem('darkMode') === 'enabled') {
699+
document.body.classList.add('dark-mode');
700+
}
701+
});
702+
692703
// Sortable Table Functionality
693704
document.addEventListener('DOMContentLoaded', function () {
694705
document.querySelectorAll('.styled-table th').forEach(function (th) {
@@ -726,11 +737,7 @@
726737
727738
function logout() {
728739
// Clear the active section
729-
localStorage.removeItem('activeSection');
730-
731-
// Proceed with your existing logout logic
732-
// Example: Redirect to login page
733-
window.location.href = 'login.aspx';
740+
sessionStorage.removeItem('activeSection');
734741
}
735742
736743
// Function to show the pop-up

0 commit comments

Comments
 (0)