MediaWiki:Common.js: відмінності між версіями
Wiki (обговорення | внесок) мНемає опису редагування |
Wiki (обговорення | внесок) мНемає опису редагування |
||
| (Не показано 5 проміжних версій цього користувача) | |||
| Рядок 841: | Рядок 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; | ||
if (!document.body.classList.contains('skin-minerva')) | |||
const btn = document.createElement('button'); | const btn = document.createElement('button'); | ||
| Рядок 860: | Рядок 853: | ||
btn.style.cssText = ` | btn.style.cssText = ` | ||
position: fixed; | position: fixed; | ||
bottom: | bottom: 240px; | ||
left: 15px; | left: 15px; | ||
z-index: 9998; | z-index: 9998; | ||
| Рядок 879: | Рядок 872: | ||
`; | `; | ||
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; | ||
setTimeout(() => { | setTimeout(() => { | ||
window.location. | window.location.href = '/w/index.php/Спеціальна:Випадкова_сторінка'; | ||
}, 100); | }, 100); | ||
}); | }); | ||
| Рядок 908: | Рядок 896: | ||
document.body.appendChild(btn); | document.body.appendChild(btn); | ||
} | } | ||
// ========================= | // ========================= | ||
// КНОПКА "ЯК ЦЕ ПРАЦЮЄ?" ( | // КНОПКА "ЯК ЦЕ ПРАЦЮЄ?" (виправлена версія) | ||
// ========================= | // ========================= | ||
function createHowItWorksButton() { | function createHowItWorksButton() { | ||
if (document.getElementById('how-it-works-btn')) return; | |||
if (document.getElementById('how-it-works-btn')) | |||
const btn = document.createElement('button'); | const btn = document.createElement('button'); | ||
| Рядок 946: | Рядок 930: | ||
`; | `; | ||
btn.addEventListener('click', function(e) { | btn.addEventListener('click', function(e) { | ||
e.preventDefault(); | e.preventDefault(); | ||
e.stopPropagation(); | e.stopPropagation(); | ||
window.location.href = '/w/index.php/FAQ'; | window.location.href = '/w/index.php/FAQ'; | ||
}); | }); | ||
| Рядок 969: | Рядок 950: | ||
// ========================= | // ========================= | ||
// | // ВИПРАВЛЕНА ІНІЦІАЛІЗАЦІЯ (замінити тільки цю частину) | ||
// ========================= | // ========================= | ||
// | // Видаляємо всі старі ініціалізатори і замінюємо на цей простий код: | ||
let buttonsInitialized = false; | |||
function initializeLeftButtons() { | |||
if (buttonsInitialized) return; | |||
buttonsInitialized = true; | |||
function | |||
if ( | |||
// Кнопка "Як це працює?" для всіх тем | |||
createHowItWorksButton(); | createHowItWorksButton(); | ||
// | // Кнопка "Випадкова сторінка" тільки для Minerva | ||
if (document.body.classList.contains('skin-minerva')) { | if (document.body.classList.contains('skin-minerva')) { | ||
createRandomButton(); | createRandomButton(); | ||
} | } | ||
} | |||
// Тільки один спосіб ініціалізації | |||
if (document.readyState === 'loading') { | |||
document.addEventListener('DOMContentLoaded', initializeLeftButtons); | |||
} else { | |||
setTimeout(initializeLeftButtons, 100); | |||
} | |||
} | |||
// | // Тільки один резервний таймер | ||
setTimeout(initializeLeftButtons, 1000); | |||