mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +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;
|
||||
};
|
||||
|
||||
let url = themeStyle.dataset.href;
|
||||
let url = themeStyle.dataset.href.replace(/(Admin|User)\/-\/[^/]+\//, '$1/-/' + value + '/')
|
||||
+ 'Json/';
|
||||
|
||||
if (url) {
|
||||
url = url.toString()
|
||||
.replace(/\/-\/[^/]+\/-\//, '/-/' + value + '/-/')
|
||||
.replace(/\/Css\/[^/]+\/User\//, '/Css/0/User/')
|
||||
.replace(/\/Hash\/[^/]+\//, '/Hash/-/');
|
||||
clearTimeout(__themeTimer);
|
||||
|
||||
if ('Json/' !== url.substr(-5)) {
|
||||
url += 'Json/';
|
||||
}
|
||||
themeTrigger(SaveSettingsStep.Animate);
|
||||
|
||||
clearTimeout(__themeTimer);
|
||||
|
||||
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);
|
||||
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];
|
||||
themeTrigger(SaveSettingsStep.TrueResult);
|
||||
}
|
||||
})
|
||||
.then(clearTimer, clearTimer);
|
||||
},
|
||||
|
||||
getKeyByValue = (o, v) => Object.keys(o).find(key => o[key] === v);
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ const
|
|||
doc = document,
|
||||
eId = id => doc.getElementById('rl-'+id),
|
||||
app = eId('app'),
|
||||
css = eId('css'),
|
||||
admin = app && '1' == app.dataset.admin,
|
||||
|
||||
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)}/`)
|
||||
.then(() => 0);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue