1(function () { 2 function getThemeMode() { 3 return parseInt(localStorage.getItem('dark_mode') || 2); 4 } 5 6 function canChangeTheme() { 7 // If var is set, then user is allowed to change the theme variation. 8 return Boolean(window.wcDarkLightEnabled); 9 } 10 11 function initThemeVariation() { 12 if (!canChangeTheme()) { 13 return; 14 } 15 16 let currentThemeMode = getThemeMode(); 17 let isDarkTheme; 18 switch (currentThemeMode) { 19 case 0: 20 isDarkTheme = false; 21 break; 22 case 1: 23 isDarkTheme = true; 24 break; 25 default: 26 if (window.matchMedia('(prefers-color-scheme: dark)').matches) { 27 // The visitor prefers dark themes and switching to the dark variation is allowed by admin. 28 isDarkTheme = true; 29 } else if (window.matchMedia('(prefers-color-scheme: light)').matches) { 30 // The visitor prefers light themes and switching to the dark variation is allowed by admin. 31 isDarkTheme = false; 32 } else { 33 // Use the site's default theme variation based on `light` in the theme file. 34 isDarkTheme = isSiteThemeDark; 35 } 36 break; 37 } 38 if (isDarkTheme) { 39 document.body.classList.add("dark"); 40 } else { 41 document.body.classList.remove("dark"); 42 } 43 } 44 45 // Initialize theme variation. 46 initThemeVariation(); 47})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.