diff --git a/changelog.d/20250217_135531_abdul.rehman02_fix_dark_theme_legacy_pages.md b/changelog.d/20250217_135531_abdul.rehman02_fix_dark_theme_legacy_pages.md new file mode 100644 index 000000000..aae795022 --- /dev/null +++ b/changelog.d/20250217_135531_abdul.rehman02_fix_dark_theme_legacy_pages.md @@ -0,0 +1 @@ +- [Bugfix] Fixed breaking dark theme toggle not working in legacy pages. (by @rehmansheikh222) \ No newline at end of file diff --git a/tutorindigo/templates/indigo/lms/static/js/dark-theme.js b/tutorindigo/templates/indigo/lms/static/js/dark-theme.js index 93b4d47cc..99687b51c 100644 --- a/tutorindigo/templates/indigo/lms/static/js/dark-theme.js +++ b/tutorindigo/templates/indigo/lms/static/js/dark-theme.js @@ -1,3 +1,11 @@ +(function() { + if (window.INDIGO_DARK_THEME_INITIALIZED) { + console.log("dark-theme.js: script already initialized, skipping second run."); + return; + } + window.INDIGO_DARK_THEME_INITIALIZED = true; + // ========== END GUARD CHECK =============== + $(document).ready(function() { 'use strict'; @@ -36,3 +44,4 @@ $(document).ready(function() { $('#toggle-switch').on('change', toggleTheme); }); +})();