theme name change bug fixed

#334
This commit is contained in:
zzossig 2020-10-26 11:17:37 +09:00
parent ed920bdd6d
commit bdcf6190fb
1 changed files with 26 additions and 1 deletions

View File

@ -452,6 +452,17 @@
var selectThemeElem = document.querySelectorAll('.select-theme');
var selectThemeItemElem = document.querySelectorAll('.select-theme__item');
{{ $skinDarkCode := (i18n "skin-dark") }}
var skinDarkCode = JSON.parse({{ $skinDarkCode | jsonify }});
{{ $skinLightCode := (i18n "skin-light") }}
var skinLightCode = JSON.parse({{ $skinLightCode | jsonify }});
{{ $skinHackerCode := (i18n "skin-hacker") }}
var skinHackerCode = JSON.parse({{ $skinHackerCode | jsonify }});
{{ $skinSolarizedCode := (i18n "skin-solarized") }}
var skinSolarizedCode = JSON.parse({{ $skinSolarizedCode | jsonify }});
{{ $skinKimbieCode := (i18n "skin-kimbie") }}
var skinKimbieCode = JSON.parse({{ $skinKimbieCode | jsonify }});
var setMetaColor = function(themeColor) {
var metaMsapplicationTileColor = document.getElementsByName('msapplication-TileColor')[0];
var metaThemeColor = document.getElementsByName('theme-color')[0];
@ -486,6 +497,20 @@
}
}
var parseSkinCode = function(themeText) {
if (themeText === skinDarkCode) {
return 'dark';
} else if (themeText === skinLightCode) {
return 'light';
} else if (themeText === skinHackerCode) {
return 'hacker';
} else if (themeText === skinSolarizedCode) {
return 'solarized';
} else if (themeText === skinKimbieCode) {
return 'kimbie';
}
}
if (localTheme) {
selectThemeItemElem ?
selectThemeItemElem.forEach(function (elem) {
@ -504,7 +529,7 @@
selectThemeItemElem ?
selectThemeItemElem.forEach(function (v, i) {
v.addEventListener('click', function (e) {
var selectedThemeVariant = e.target.text.trim();
var selectedThemeVariant = parseSkinCode(e.target.text.trim());
localStorage.setItem('theme', selectedThemeVariant);
setMetaColor(selectedThemeVariant);