@@ -621,8 +621,14 @@ function applyTheme(theme, notify = false) {
621621
622622function initThemeSwitcher ( ) {
623623 let savedTheme = "neo" ;
624+ let urlTheme = null ;
624625 try {
625- savedTheme = getThemeFromUrl ( ) || window . localStorage . getItem ( THEME_STORAGE_KEY ) || "neo" ;
626+ urlTheme = getThemeFromUrl ( ) ;
627+ const storedTheme = window . localStorage . getItem ( THEME_STORAGE_KEY ) ;
628+ savedTheme = urlTheme || storedTheme || "neo" ;
629+ if ( urlTheme && storedTheme !== urlTheme ) {
630+ window . localStorage . setItem ( THEME_STORAGE_KEY , urlTheme ) ;
631+ }
626632 } catch ( error ) {
627633 savedTheme = "neo" ;
628634 }
@@ -631,14 +637,21 @@ function initThemeSwitcher() {
631637 window . addEventListener ( "pageshow" , ( ) => {
632638 let latestTheme = "neo" ;
633639 try {
634- latestTheme = window . localStorage . getItem ( THEME_STORAGE_KEY ) || "neo" ;
640+ latestTheme = getThemeFromUrl ( ) || window . localStorage . getItem ( THEME_STORAGE_KEY ) || "neo" ;
635641 } catch ( error ) {
636642 latestTheme = "neo" ;
637643 }
638644 if ( latestTheme !== currentTheme ) {
639645 applyTheme ( latestTheme , false ) ;
640646 }
641647 } ) ;
648+ window . addEventListener ( "storage" , ( event ) => {
649+ if ( event . key !== THEME_STORAGE_KEY || ! event . newValue ) return ;
650+ if ( ! THEME_OPTIONS . includes ( event . newValue ) ) return ;
651+ if ( event . newValue !== currentTheme ) {
652+ applyTheme ( event . newValue , false ) ;
653+ }
654+ } ) ;
642655 headerThemeSelect ?. addEventListener ( "change" , ( event ) => {
643656 applyTheme ( event . target . value , true ) ;
644657 } ) ;
@@ -914,9 +927,9 @@ function runTerminalCommand(rawCommand) {
914927 scrollToSection ( "hero-zone" ) ;
915928 appendTerminalLine ( "Jumped to home." ) ;
916929 } else if ( action === "about" ) {
917- window . location . href = "about.html" ;
930+ navigateToPage ( "about.html" ) ;
918931 } else if ( action === "contact" ) {
919- window . location . href = "contact.html" ;
932+ navigateToPage ( "contact.html" ) ;
920933 } else if ( action === "github" ) {
921934 window . open ( "https://github.com/DevXtechnic" , "_blank" , "noopener,noreferrer" ) ;
922935 appendTerminalLine ( "Opened GitHub profile." ) ;
@@ -1227,6 +1240,11 @@ function runOrNavigate(sectionId, actionKey = "") {
12271240 window . location . href = targetUrl ;
12281241}
12291242
1243+ function navigateToPage ( path ) {
1244+ const nextUrl = applyThemeToUrl ( path , currentTheme ) ;
1245+ window . location . href = nextUrl ;
1246+ }
1247+
12301248function initAiConstellationTagline ( ) {
12311249 if ( page !== "home" ) return ;
12321250 const tagEl = document . querySelector ( "#ai-constellation .chaos-card.c4 p" ) ;
@@ -1297,8 +1315,8 @@ function initCommandPalette() {
12971315 { label : "Mode: Toggle Chill Music" , keywords : "music chill funk mode" , run : ( ) => toggleFunkAudio ( ) } ,
12981316 { label : "Mode: Toggle Elon Warp" , keywords : "elon warp mode" , run : ( ) => toggleElonMode ( ) } ,
12991317 { label : "Open: GitHub Profile" , keywords : "github profile devxtechnic" , run : ( ) => window . open ( "https://github.com/DevXtechnic" , "_blank" , "noopener,noreferrer" ) } ,
1300- { label : "Open: About Page" , keywords : "about page profile" , run : ( ) => { window . location . href = "about.html" ; } } ,
1301- { label : "Open: Contact Page" , keywords : "contact email" , run : ( ) => { window . location . href = "contact.html" ; } } ,
1318+ { label : "Open: About Page" , keywords : "about page profile" , run : ( ) => navigateToPage ( "about.html" ) } ,
1319+ { label : "Open: Contact Page" , keywords : "contact email" , run : ( ) => navigateToPage ( "contact.html" ) } ,
13021320 ] ;
13031321
13041322 let visibleCommands = commands . slice ( ) ;
0 commit comments