MediaWiki:Common.js: различия между версиями
Перейти к навигации
Перейти к поиску
Glamyr (обсуждение | вклад) Нет описания правки |
Glamyr (обсуждение | вклад) Нет описания правки |
||
| Строка 1: | Строка 1: | ||
$(function () { | |||
const | const classes = ['theme-stddark', 'theme-nanotrasen', 'theme-syndicate', 'theme-plasmafire', 'theme-clockcult', 'theme-bloodcult', 'theme-heretic', 'theme-default']; | ||
function applyTheme(themeId) { | function applyTheme(themeId) { | ||
classes.forEach(id => document.body.classList.remove(id)); | |||
document.body.classList.remove('theme-active-dark'); | document.body.classList.remove('theme-active-dark'); | ||
if (themeId && | if (themeId && classes.includes(themeId)) { | ||
document.body.classList.add(themeId); | document.body.classList.add(themeId); | ||
if (themeId !== 'theme-default') { | if (themeId !== 'theme-default') { | ||
| Строка 21: | Строка 12: | ||
} | } | ||
localStorage.setItem('mw-tg-theme', themeId); | localStorage.setItem('mw-tg-theme', themeId); | ||
} | } | ||
} | } | ||
| Строка 44: | Строка 29: | ||
const names = { 'theme-stddark': 'Standard Dark', 'theme-nanotrasen': 'Nanotrasen TGUI', 'theme-syndicate': 'Syndicate TGUI', 'theme-plasmafire': 'Plasmafire', 'theme-clockcult': 'Clock Cult', 'theme-bloodcult': 'Blood Cult', 'theme-heretic': 'Heretic', 'theme-default': 'Standard Light' }; | const names = { 'theme-stddark': 'Standard Dark', 'theme-nanotrasen': 'Nanotrasen TGUI', 'theme-syndicate': 'Syndicate TGUI', 'theme-plasmafire': 'Plasmafire', 'theme-clockcult': 'Clock Cult', 'theme-bloodcult': 'Blood Cult', 'theme-heretic': 'Heretic', 'theme-default': 'Standard Light' }; | ||
classes.forEach(id => { | |||
selectHtml += `<li style="margin: 4px 0;"><a href="#" class="tg-theme-item" data-theme="${id}" style="display: block; padding: 6px 8px; border-radius: 4px; text-decoration: none;">${names[id]}</a></li>`; | selectHtml += `<li style="margin: 4px 0;"><a href="#" class="tg-theme-item" data-theme="${id}" style="display: block; padding: 6px 8px; border-radius: 4px; text-decoration: none;">${names[id]}</a></li>`; | ||
}); | }); | ||