|
Метки: очистка ручная отмена |
| (не показаны 34 промежуточные версии 2 участников) |
| Строка 1: |
Строка 1: |
| (function () {
| |
| const themes = {
| |
| 'theme-nanotrasen': { name: 'Nanotrasen TGUI', logo: '/images/nanotrasen_logo.png' },
| |
| 'theme-syndicate': { name: 'Syndicate TGUI', logo: '/images/syndicate_logo.png' },
| |
| 'theme-plasmafire': { name: 'Plasmafire' },
| |
| 'theme-clockcult': { name: 'Clock Cult' },
| |
| 'theme-bloodcult': { name: 'Blood Cult' },
| |
| 'theme-heretic': { name: 'Heretic' },
| |
| 'theme-stddark': { name: 'Standard Dark' },
| |
| 'theme-default': { name: 'Standard Light' }
| |
| };
| |
|
| |
|
| function applyTheme(themeId) {
| |
| Object.keys(themes).forEach(id => document.body.classList.remove(id));
| |
|
| |
| if (themeId && themes[themeId]) {
| |
| document.body.classList.add(themeId);
| |
| localStorage.setItem('mw-tg-theme', themeId);
| |
|
| |
| const logoImg = document.querySelector('.mw-wiki-logo, .vector-header-container .mw-logo-img, .vector-logo-img');
| |
| if (logoImg) {
| |
| if (logoImg.tagName === 'IMG') {
| |
| logoImg.src = themes[themeId].logo;
| |
| } else {
| |
| logoImg.style.backgroundImage = `url(${themes[themeId].logo})`;
| |
| }
| |
| }
| |
| }
| |
| }
| |
|
| |
| $(document).ready(function () {
| |
| const activeTheme = localStorage.getItem('mw-tg-theme') || 'theme-default';
| |
| applyTheme(activeTheme);
| |
|
| |
| let selectHtml = '<div id="tg-theme-selector-container" style="margin: 0 10px; display: inline-block; vertical-align: middle;">';
| |
| selectHtml += '<select id="tg-theme-selector" style="background:#222; color:#fff; border:1px solid #444; padding:4px; border-radius:4px; font-size:12px; cursor:pointer;">';
| |
|
| |
| Object.keys(themes).forEach(id => {
| |
| const selected = (id === activeTheme) ? 'selected' : '';
| |
| selectHtml += `<option value="${id}" ${selected}> ${themes[id].name}</option>`;
| |
| });
| |
|
| |
| selectHtml += '</select></div>';
| |
|
| |
| const personalTools = document.getElementById('p-personal') || document.querySelector('.vector-user-links');
| |
| if (personalTools) {
| |
| $(personalTools).prepend(selectHtml);
| |
| }
| |
|
| |
| $('#tg-theme-selector').on('change', function () {
| |
| applyTheme($(this).val());
| |
| });
| |
| });
| |
| })();
| |