MediaWiki:Common.js: відмінності між версіями
Wiki (обговорення | внесок) мНемає опису редагування |
Wiki (обговорення | внесок) мНемає опису редагування |
||
| (Не показано 11 проміжних версій цього користувача) | |||
| Рядок 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; | |||
z-index: 9998; | z-index: 9998; | ||
background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%); | background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%); | ||
| Рядок 876: | Рядок 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; | ||
setTimeout(() => { | setTimeout(() => { | ||
window.location. | window.location.href = '/w/index.php/Спеціальна:Випадкова_сторінка'; | ||
}, 100); | }, 100); | ||
}); | }); | ||
| Рядок 907: | Рядок 896: | ||
document.body.appendChild(btn); | document.body.appendChild(btn); | ||
} | } | ||
// ========================= | // ========================= | ||
// | // КНОПКА "ЯК ЦЕ ПРАЦЮЄ?" (виправлена версія) | ||
// ========================= | // ========================= | ||
function | function createHowItWorksButton() { | ||
if ( | 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)'; | |||
}); | |||
document.body.appendChild(btn); | |||
} | } | ||
// ========================= | // ========================= | ||
// | // ВИПРАВЛЕНА ІНІЦІАЛІЗАЦІЯ (замінити тільки цю частину) | ||
// ========================= | // ========================= | ||
// | // Видаляємо всі старі ініціалізатори і замінюємо на цей простий код: | ||
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')) { | ||
createRandomButton(); | createRandomButton(); | ||
} | } | ||
} | } | ||
// Тільки один спосіб ініціалізації | |||
if (document.readyState === 'loading') { | |||
document.addEventListener('DOMContentLoaded', initializeLeftButtons); | |||
} else { | |||
} | setTimeout(initializeLeftButtons, 100); | ||
} | |||
setTimeout( | // Тільки один резервний таймер | ||
setTimeout(initializeLeftButtons, 1000); | |||