Немає опису редагування
мНемає опису редагування
 
(Не показано 16 проміжних версій цього користувача)
Рядок 19: Рядок 19:
     }
     }


     function createButton(text, bottom, onClick, title) {
    // Розмір шрифту
         var $btn = $('<button>').text(text).attr('title', title).css({
    var fontSize = parseInt(localStorage.getItem('fontSize')) || parseInt($('body').css('font-size')) || 16;
            position: 'fixed',
 
            bottom: bottom + 'px',
    function applyFontSize() {
            right: '10px',
        var content = document.querySelector('.mw-parser-output');
            padding: '10px 16px',
        if (content) {
            border: 'none',
            content.style.fontSize = fontSize + 'px';
            borderRadius: '25px',
        }
            background: '#1a73e8',
    }
            color: '#ffffff',
 
            fontWeight: 'bold',
    // Масив для збереження позицій кнопок
            fontSize: '14px',
    var buttonCount = 0;
            cursor: 'pointer',
 
            zIndex: 9999,
    // Функція створення кнопки праворуч з автоматичним вертикальним розташуванням
            textAlign: 'center',
     function createButtonRight(text, onClick, title) {
            boxShadow: '0 2px 6px rgba(0,0,0,0.3)',
         var btn = document.createElement('button');
            whiteSpace: 'nowrap'
        btn.innerText = text;
         }).click(onClick);
        btn.title = title;
         $('body').append($btn);
        btn.style.position = 'fixed';
         return $btn;
        btn.style.right = '10px';
        btn.style.bottom = (10 + buttonCount * 60) + 'px'; // вертикальний відступ між кнопками
        btn.style.padding = '10px 16px';
        btn.style.border = 'none';
        btn.style.borderRadius = '25px';
        btn.style.background = '#1a73e8';
        btn.style.color = '#fff';
        btn.style.fontWeight = 'bold';
        btn.style.fontSize = '14px';
        btn.style.cursor = 'pointer';
        btn.style.zIndex = 9999;
        btn.style.textAlign = 'center';
        btn.style.boxShadow = '0 2px 6px rgba(0,0,0,0.3)';
        btn.style.whiteSpace = 'nowrap';
 
         btn.onclick = onClick;
         document.body.appendChild(btn);
 
        buttonCount++; // збільшуємо лічильник кнопок для наступного bottom
         return btn;
     }
     }


     // Кнопка Темна/Світла тема
     // Кнопка Темна/Світла тема
     var $themeBtn = createButton(
     createButtonRight(
         theme === 'dark' ? 'Світла тема ☀️' : 'Темна тема 🌙',
         theme === 'dark' ? 'Світла тема ☀️' : 'Темна тема 🌙',
        10,
         function () {
         function () {
             var newTheme = theme === 'dark' ? 'light' : 'dark';
             var newTheme = theme === 'dark' ? 'light' : 'dark';
Рядок 52: Рядок 70:
         'Змінити тему'
         'Змінити тему'
     );
     );
    // Змінна для зберігання розміру шрифту
    var fontSize = parseInt(localStorage.getItem('fontSize')) || parseInt($('body').css('font-size')) || 16;
   
    // Функція для застосування розміру шрифту
    function applyFontSize() {
        $('body').css('font-size', fontSize + 'px');
    }


     // Кнопка доступності
     // Кнопка доступності
     var $accessBtn = createButton(
     createButtonRight(
         localStorage.getItem('accessibilityMode') === 'on' ? 'Доступність ON' : 'Доступність OFF',
         localStorage.getItem('accessibilityMode') === 'on' ? 'Доступність' : 'Доступність',
        70,
         function () {
         function () {
             if (!$('body').hasClass('accessibility-mode')) {
             if (!$('body').hasClass('accessibility-mode')) {
                 $('body').addClass('accessibility-mode');
                 $('body').addClass('accessibility-mode');
                 localStorage.setItem('accessibilityMode', 'on');
                 localStorage.setItem('accessibilityMode', 'on');
                $accessBtn.css('background', '#ff6600');
                $accessBtn.text('Доступність ON');
             } else {
             } else {
                 $('body').removeClass('accessibility-mode');
                 $('body').removeClass('accessibility-mode');
                 localStorage.setItem('accessibilityMode', 'off');
                 localStorage.setItem('accessibilityMode', 'off');
                $accessBtn.css('background', '#1a73e8');
                $accessBtn.text('Доступність OFF');
             }
             }
         },
         },
Рядок 81: Рядок 86:
     );
     );


     // Відновлення стану доступності
     // Кнопки лупи
     if (localStorage.getItem('accessibilityMode') === 'on') {
     createButtonRight('🔍 +', function () {
        $('body').addClass('accessibility-mode');
        $accessBtn.css('background', '#ff6600');
        $accessBtn.text('Доступність ON');
    }
 
    // Лупа
    createButton('🔍 +', 130, function () {
         fontSize += 2;
         fontSize += 2;
         if (fontSize > 30) fontSize = 30;
         if (fontSize > 30) fontSize = 30;
Рядок 96: Рядок 94:
     }, 'Збільшити шрифт');
     }, 'Збільшити шрифт');


     createButton('🔍 -', 170, function () {
     createButtonRight('🔍 -', function () {
         fontSize -= 2;
         fontSize -= 2;
         if (fontSize < 12) fontSize = 12;
         if (fontSize < 12) fontSize = 12;
Рядок 103: Рядок 101:
     }, 'Зменшити шрифт');
     }, 'Зменшити шрифт');


     // Застосовуємо розмір шрифту
     // Застосовуємо шрифт при завантаженні
     applyFontSize();
     applyFontSize();
    // Відновлення стану доступності при завантаженні
    if (localStorage.getItem('accessibilityMode') === 'on') {
        $('body').addClass('accessibility-mode');
    }
});
});


// =========================
// =========================
Рядок 837: Рядок 841:


// =========================
// =========================
// КНОПКА ВИПАДКОВА СТОРІНКА (спрощена версія)
// КНОПКА ВИПАДКОВА СТОРІНКА (вище)
// =========================
// =========================
function createRandomButton() {
function createRandomButton() {
    // Перевіряємо чи кнопка вже існує
     if (document.getElementById('float-random-btn')) return;
     if (document.getElementById('float-random-btn')) {
     if (!document.body.classList.contains('skin-minerva')) return;
        return;
    }
   
    // Перевіряємо чи це мобільна версія
     if (!document.body.classList.contains('skin-minerva')) {
        return;
    }
      
      
     const btn = document.createElement('button');
     const btn = document.createElement('button');
Рядок 856: Рядок 853:
     btn.style.cssText = `
     btn.style.cssText = `
         position: fixed;
         position: fixed;
         bottom: 100px;
         bottom: 240px;
         right: 15px;
         left: 15px;
         z-index: 9998;
         z-index: 9998;
         background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
         background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
Рядок 872: Рядок 869:
         gap: 8px;
         gap: 8px;
         transition: all 0.3s ease;
         transition: all 0.3s ease;
        white-space: nowrap;
     `;
     `;
      
      
    // ПОКРАЩЕНИЙ ОБРОБНИК КЛІКУ
     btn.addEventListener('click', function(e) {
     btn.addEventListener('click', function(e) {
         e.preventDefault();
         e.preventDefault();
         e.stopPropagation();
         e.stopPropagation();
       
        // Додаємо індикатор завантаження
         btn.innerHTML = '⏳ Завантаження...';
         btn.innerHTML = '⏳ Завантаження...';
         btn.style.opacity = '0.7';
         btn.style.opacity = '0.7';
         btn.disabled = true;
         btn.disabled = true;
       
        // Використовуємо window.location.replace для чистого переходу
         setTimeout(() => {
         setTimeout(() => {
             window.location.replace('/w/index.php/Спеціальна:Випадкова_сторінка');
             window.location.href = '/w/index.php/Спеціальна:Випадкова_сторінка';
         }, 100);
         }, 100);
     });
     });
Рядок 903: Рядок 896:
      
      
     document.body.appendChild(btn);
     document.body.appendChild(btn);
    console.log('Кнопка Випадкова створена');
}
// АВТОМАТИЧНЕ ВІДНОВЛЕННЯ КНОПКИ ПІСЛЯ ПЕРЕХОДУ
// =========================
function restoreRandomButton() {
    // Перевіряємо чи ми на випадковій сторінці
    const isRandomPage = window.location.href.includes('Випадкова_сторінка') ||
                        window.location.href.includes('Special:Random');
   
    if (isRandomPage && document.body.classList.contains('skin-minerva')) {
        // Чекаємо повного завантаження сторінки
        setTimeout(() => {
            if (!document.getElementById('float-random-btn')) {
                createRandomButton();
            }
        }, 500);
    }
}
}


// =========================
// =========================
// ПРИХОВАННЯ ЕЛЕМЕНТІВ У МОБІЛЬНІЙ ВЕРСІЇ
// КНОПКА "ЯК ЦЕ ПРАЦЮЄ?" (виправлена версія)
// =========================
// =========================
function hideMobileElements() {
function createHowItWorksButton() {
     if (!document.body.classList.contains('skin-minerva')) return;
     if (document.getElementById('how-it-works-btn')) return;
   
    const btn = document.createElement('button');
    btn.id = 'how-it-works-btn';
    btn.innerHTML = '?';
    btn.title = 'Як це працює?';
    btn.style.cssText = `
        position: fixed;
        bottom: 140px;
        left: 15px;
        z-index: 9998;
        background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
        color: white;
        border: none;
        width: 60px;
        height: 60px;
        border-radius: 50%;
        font-size: 24px;
        font-weight: bold;
        cursor: pointer;
        box-shadow: 0 4px 15px rgba(0,0,0,0.3);
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s ease;
        line-height: 1;
    `;
   
    btn.addEventListener('click', function(e) {
        e.preventDefault();
        e.stopPropagation();
        window.location.href = '/w/index.php/FAQ';
    });
   
    btn.addEventListener('mouseenter', function() {
        this.style.transform = 'scale(1.05)';
        this.style.boxShadow = '0 6px 20px rgba(0,0,0,0.4)';
    });
   
    btn.addEventListener('mouseleave', function() {
        this.style.transform = 'scale(1)';
        this.style.boxShadow = '0 4px 15px rgba(0,0,0,0.3)';
    });
      
      
     setTimeout(() => {
     document.body.appendChild(btn);
        const elements = document.querySelectorAll('*');
        elements.forEach(element => {
            if (element.textContent && element.textContent.includes('Відмова')) {
                element.style.display = 'none';
                const parentLi = element.closest('li');
                if (parentLi) parentLi.style.display = 'none';
            }
        });
       
        const links = document.querySelectorAll('a[href*="%D0%92%D1%96%D0%B4%D0%BC%D0%BE%D0%B2%D0%B0"]');
        links.forEach(link => {
            link.style.display = 'none';
            const parentLi = link.closest('li');
            if (parentLi) parentLi.style.display = 'none';
        });
    }, 1000);
}
}


// =========================
// =========================
// ЗАГАЛЬНИЙ ІНІЦІАЛІЗАТОР
// ВИПРАВЛЕНА ІНІЦІАЛІЗАЦІЯ (замінити тільки цю частину)
// =========================
// =========================
document.addEventListener('DOMContentLoaded', function() {
 
     // Для мобільної версії
// Видаляємо всі старі ініціалізатори і замінюємо на цей простий код:
 
let buttonsInitialized = false;
 
function initializeLeftButtons() {
    if (buttonsInitialized) return;
    buttonsInitialized = true;
   
    // Кнопка "Як це працює?" для всіх тем
    createHowItWorksButton();
   
     // Кнопка "Випадкова сторінка" тільки для Minerva
     if (document.body.classList.contains('skin-minerva')) {
     if (document.body.classList.contains('skin-minerva')) {
        hideMobileElements();
         createRandomButton();
         createRandomButton();
       
        setTimeout(() => {
            if (!document.getElementById('float-random-btn')) {
                createRandomButton();
            }
            hideMobileElements();
        }, 2000);
     }
     }
});
}


window.addEventListener('load', function() {
// Тільки один спосіб ініціалізації
     if (document.body.classList.contains('skin-minerva')) {
if (document.readyState === 'loading') {
        setTimeout(createRandomButton, 500);
     document.addEventListener('DOMContentLoaded', initializeLeftButtons);
    }
} else {
});
    setTimeout(initializeLeftButtons, 100);
}


setTimeout(function() {
// Тільки один резервний таймер
    if (document.body.classList.contains('skin-minerva') && !document.getElementById('float-random-btn')) {
setTimeout(initializeLeftButtons, 1000);
        createRandomButton();
    }
}, 3000);