@@ -1,18 +1,17 @@
|
||||
// Shared hamburger menu toggle
|
||||
// Back-to-hub button with active-task confirmation
|
||||
(function () {
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const btn = document.getElementById('hamburger-btn')
|
||||
const menu = document.getElementById('hamburger-menu')
|
||||
if (!btn || !menu) return
|
||||
btn.addEventListener('click', (e) => {
|
||||
e.stopPropagation()
|
||||
menu.classList.toggle('open')
|
||||
})
|
||||
document.addEventListener('click', () => menu.classList.remove('open'))
|
||||
// mark active link
|
||||
const current = location.pathname.split('/').pop() || 'index.html'
|
||||
menu.querySelectorAll('a').forEach(a => {
|
||||
if (a.getAttribute('href') === current) a.classList.add('active')
|
||||
const backBtn = document.getElementById('back-to-hub')
|
||||
if (!backBtn) return
|
||||
|
||||
backBtn.addEventListener('click', (e) => {
|
||||
const playScreen = document.getElementById('play-screen')
|
||||
const taskActive = playScreen && !playScreen.classList.contains('hidden')
|
||||
if (taskActive) {
|
||||
e.preventDefault()
|
||||
const ok = confirm('Masz aktywne zadanie. Czy na pewno chcesz wyjść do menu?')
|
||||
if (ok) window.location.href = backBtn.getAttribute('href')
|
||||
}
|
||||
})
|
||||
})
|
||||
})()
|
||||
|
||||
Reference in New Issue
Block a user