mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-06 16:07:03 +03:00
Cleanup theme switcher
This commit is contained in:
parent
0f14e235b4
commit
4250dcf3f0
3 changed files with 20 additions and 35 deletions
|
|
@ -55,41 +55,29 @@ export const
|
||||||
__themeJson = null;
|
__themeJson = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
let url = themeStyle.dataset.href;
|
let url = themeStyle.dataset.href.replace(/(Admin|User)\/-\/[^/]+\//, '$1/-/' + value + '/')
|
||||||
|
+ 'Json/';
|
||||||
|
|
||||||
if (url) {
|
clearTimeout(__themeTimer);
|
||||||
url = url.toString()
|
|
||||||
.replace(/\/-\/[^/]+\/-\//, '/-/' + value + '/-/')
|
|
||||||
.replace(/\/Css\/[^/]+\/User\//, '/Css/0/User/')
|
|
||||||
.replace(/\/Hash\/[^/]+\//, '/Hash/-/');
|
|
||||||
|
|
||||||
if ('Json/' !== url.substr(-5)) {
|
themeTrigger(SaveSettingsStep.Animate);
|
||||||
url += 'Json/';
|
|
||||||
}
|
|
||||||
|
|
||||||
clearTimeout(__themeTimer);
|
if (__themeJson) {
|
||||||
|
__themeJson.abort();
|
||||||
themeTrigger(SaveSettingsStep.Animate);
|
|
||||||
|
|
||||||
if (__themeJson) {
|
|
||||||
__themeJson.abort();
|
|
||||||
}
|
|
||||||
let init = {};
|
|
||||||
if (window.AbortController) {
|
|
||||||
__themeJson = new AbortController();
|
|
||||||
init.signal = __themeJson.signal;
|
|
||||||
}
|
|
||||||
rl.fetchJSON(url, init)
|
|
||||||
.then(data => {
|
|
||||||
if (2 === arrayLength(data)) {
|
|
||||||
themeStyle.textContent = data[1];
|
|
||||||
themeStyle.dataset.href = url;
|
|
||||||
themeStyle.dataset.theme = data[0];
|
|
||||||
themeTrigger(SaveSettingsStep.TrueResult);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.then(clearTimer, clearTimer);
|
|
||||||
}
|
}
|
||||||
|
let init = {};
|
||||||
|
if (window.AbortController) {
|
||||||
|
__themeJson = new AbortController();
|
||||||
|
init.signal = __themeJson.signal;
|
||||||
|
}
|
||||||
|
rl.fetchJSON(url, init)
|
||||||
|
.then(data => {
|
||||||
|
if (2 === arrayLength(data)) {
|
||||||
|
themeStyle.textContent = data[1];
|
||||||
|
themeTrigger(SaveSettingsStep.TrueResult);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(clearTimer, clearTimer);
|
||||||
},
|
},
|
||||||
|
|
||||||
getKeyByValue = (o, v) => Object.keys(o).find(key => o[key] === v);
|
getKeyByValue = (o, v) => Object.keys(o).find(key => o[key] === v);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ const
|
||||||
doc = document,
|
doc = document,
|
||||||
eId = id => doc.getElementById('rl-'+id),
|
eId = id => doc.getElementById('rl-'+id),
|
||||||
app = eId('app'),
|
app = eId('app'),
|
||||||
css = eId('css'),
|
|
||||||
admin = app && '1' == app.dataset.admin,
|
admin = app && '1' == app.dataset.admin,
|
||||||
|
|
||||||
cb = () => rl.app.bootstart(),
|
cb = () => rl.app.bootstart(),
|
||||||
|
|
@ -70,8 +69,6 @@ win.rl = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
css.href = css.dataset.href;
|
|
||||||
|
|
||||||
loadScript(`./?/${admin ? 'Admin' : ''}AppData/0/${Math.random().toString().slice(2)}/`)
|
loadScript(`./?/${admin ? 'Admin' : ''}AppData/0/${Math.random().toString().slice(2)}/`)
|
||||||
.then(() => 0);
|
.then(() => 0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
<meta name="robots" content="noindex,nofollow,noodp">
|
<meta name="robots" content="noindex,nofollow,noodp">
|
||||||
<title></title>
|
<title></title>
|
||||||
<style id="app-boot-css">{{BaseAppBootCss}}</style>
|
<style id="app-boot-css">{{BaseAppBootCss}}</style>
|
||||||
<link type="text/css" rel="stylesheet" data-href="{{BaseAppMainCssLink}}" id="rl-css" rel="preload">
|
<link type="text/css" rel="stylesheet" href="{{BaseAppMainCssLink}}">
|
||||||
<link rel="manifest" href="{{BaseAppManifestLink}}">
|
<link rel="manifest" href="{{BaseAppManifestLink}}">
|
||||||
<style id="app-theme-style" data-href="{{BaseAppThemeCssLink}}">{{BaseAppThemeCss}}</style>
|
<style id="app-theme-style" data-href="{{BaseAppThemeCssLink}}">{{BaseAppThemeCss}}</style>
|
||||||
{{BaseAppFaviconPngLinkTag}}
|
{{BaseAppFaviconPngLinkTag}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue