18 lines
632 B
JavaScript
18 lines
632 B
JavaScript
// Back-to-hub button with active-task confirmation
|
|
(function () {
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
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')
|
|
}
|
|
})
|
|
})
|
|
})()
|