Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Plik: script.js
- document.addEventListener('DOMContentLoaded', () => {
- const ICON_BASE_URL = 'IconChamp/';
- const champions = [
- { name: "[Event] Polowanie na Lempo", minTime: 0, maxTime: 0, category: 'event', iconPath: "Lempo.png" },
- { name: "[Event] Obrona Mostu", minTime: 240, maxTime: 241, category: 'event', iconPath: "Hvar.png" },
- { name: "[Event] Sana", minTime: 120, maxTime: 121, category: 'event', iconPath: "Sana.png" },
- { name: "[Event] Orki", minTime: 480, maxTime: 481, category: 'event', iconPath: "Orki.png" },
- { name: "[BOSS] Bibliotekarz", minTime: 17, maxTime: 29, iconPath: "Bibliotekarz.png", category: 'boss' },
- { name: "[BOSS] Wendigo", minTime: 120, maxTime: 150, iconPath: "Wendigo.png", category: 'boss' },
- { name: "[BOSS] Jastrzębior", minTime: 300, maxTime: 420, iconPath: "Jastrzębior.png", category: 'boss' },
- { name: "Kosior", minTime: 25, maxTime: 30, iconPath: "Kosior.png", category: 'champion' },
- { name: "Kruczy", minTime: 25, maxTime: 30, iconPath: "Kruczy.png", category: 'champion' },
- { name: "Ogruch", minTime: 20, maxTime: 30, iconPath: "Ogruch.png", category: 'champion' },
- { name: "Treven", minTime: 60, maxTime: 80, iconPath: "Treven.png", category: 'champion' },
- { name: "Cybulski", minTime: 35, maxTime: 50, iconPath: "Cybulski.png", category: 'champion' },
- { name: "Nielichy", minTime: 20, maxTime: 28, iconPath: "Nielichy.png", category: 'champion' },
- { name: "Popiel", minTime: 30, maxTime: 40, iconPath: "Popiel.png", category: 'champion' },
- { name: "Acerodon", minTime: 60, maxTime: 70, iconPath: "Acerodon.png", category: 'champion' },
- { name: "Harilar", minTime: 60, maxTime: 75, iconPath: "Harilar.png", category: 'champion' },
- { name: "Król Szczurów", minTime: 90, maxTime: 120, iconPath: "Król_Szczurów.png", category: 'champion' },
- { name: "Orthal", minTime: 40, maxTime: 60, iconPath: "Orthal.png", category: 'champion' },
- { name: "Wilhelm Tell", minTime: 45, maxTime: 65, iconPath: "Wilhelm_Tell.png", category: 'champion' },
- { name: "Wilczur", minTime: 60, maxTime: 70, iconPath: "Wilczur.png", category: 'champion' },
- { name: "Przybysz", minTime: 90, maxTime: 120, iconPath: "Przybysz.png", category: 'champion' },
- { name: "Zębacz", minTime: 40, maxTime: 48, iconPath: "Zębacz.png", category: 'champion' },
- { name: "Brachyura", minTime: 30, maxTime: 45, iconPath: "Brachyura.png", category: 'champion' },
- { name: "Tilsal Wędrowny", minTime: 60, maxTime: 70, iconPath: "Tilsai_wędrowny.png", category: 'champion' },
- { name: "Karol Kold", minTime: 45, maxTime: 57, iconPath: "Karol_kold.png", category: 'champion' },
- { name: "Psychopata", minTime: 50, maxTime: 65, iconPath: "Psychopata.png", category: 'champion' },
- { name: "Krwiopijca", minTime: 90, maxTime: 100, iconPath: "Krwiopijca.png", category: 'champion' },
- { name: "Zaklinacz Kruków", minTime: 25, maxTime: 33, iconPath: "Zaklinacz_Kruków.png", category: 'champion' },
- { name: "Wściekły Grizzly", minTime: 35, maxTime: 55, iconPath: "Wściekły_Grizzly.png", category: 'champion' },
- { name: "Telek", minTime: 60, maxTime: 66, iconPath: "Telek.png", category: 'champion' },
- { name: "Rizurul", minTime: 40, maxTime: 45, iconPath: "Rizurul.png", category: 'champion' },
- { name: "Żaimm", minTime: 20, maxTime: 24, iconPath: "Zaimm.png", category: 'champion' },
- { name: "Wściekły Burkan", minTime: 20, maxTime: 30, iconPath: "Wściekły_Burkan.png", category: 'champion' },
- { name: "Jesienica", minTime: 35, maxTime: 47, iconPath: "Jesienica.png", category: 'champion' },
- { name: "Dritan Żarliwy", minTime: 90, maxTime: 110, iconPath: "Dritan_Żarliwy.png", category: 'champion' },
- { name: "Zimowy Szaman", minTime: 60, maxTime: 70, iconPath: "Zimowy_Szaman.png", category: 'champion' },
- { name: "Tygrys Górski", minTime: 25, maxTime: 40, iconPath: "Tygrys_Górski.png", category: 'champion' },
- { name: "Obłąkana Harpia", minTime: 35, maxTime: 47, iconPath: "Obłąkana_harpia.png", category: 'champion' },
- { name: "Zawieja", minTime: 45, maxTime: 65, iconPath: "Zawieja.png", category: 'champion' },
- { name: "Ragak Maruder", minTime: 120, maxTime: 150, iconPath: "Ragak_Maruder.png", category: 'champion' },
- { name: "Yoko", minTime: 15, maxTime: 19, iconPath: "Yoko.png", category: 'champion' },
- { name: "Kapłan Śmierci", minTime: 0, maxTime: 0, iconPath: "Kapłan_Śmierci.png", category: 'champion' },
- { name: "Halmengir", minTime: 60, maxTime: 75, iconPath: "Halmengir.png", category: 'champion' },
- { name: "Olm", minTime: 120, maxTime: 140, iconPath: "Olm.png", category: 'champion' },
- { name: "Troll Zimowy 1", minTime: 30, maxTime: 40, iconPath: "Troll_Zimowy_1.png", category: 'champion' },
- { name: "Troll Zimowy 2", minTime: 30, maxTime: 40, iconPath: "Troll_Zimowy_2.png", category: 'champion' },
- { name: "Podróżnik", minTime: 20, maxTime: 25, iconPath: "Podróżnik.png", category: 'champion' },
- { name: "Koszmar", minTime: 60, maxTime: 75, iconPath: "Koszmar.png", category: 'champion' },
- { name: "Pacynkarz", minTime: 30, maxTime: 40, iconPath: "Pacynkarz.png", category: 'champion' },
- { name: "Wykwit 1", minTime: 25, maxTime: 35, iconPath: "Wykwit.png", category: 'champion' },
- { name: "Wykwit 2", minTime: 25, maxTime: 35, iconPath: "Wykwit.png", category: 'champion' },
- { name: "Grobnica", minTime: 45, maxTime: 60, iconPath: "Grobnica.png", category: 'champion' },
- { name: "Krwiopij", minTime: 60, maxTime: 100, iconPath: "Krwiopij.png", category: 'champion' },
- { name: "Wisp", minTime: 120, maxTime: 180, iconPath: "Wisp.png", category: 'champion' },
- { name: "Żywiciel Jak", minTime: 60, maxTime: 105, iconPath: "Żywiciel_jak.png", category: 'champion' },
- { name: "Żerca", minTime: 45, maxTime: 75, iconPath: "Żerca.png", category: 'champion' },
- { name: "Żywiciel Jeti", minTime: 60, maxTime: 105, iconPath: "Żywiciel_jeti.png", category: 'champion' },
- { name: "Gnawk", minTime: 120, maxTime: 180, iconPath: "Gnawk.png", category: 'champion' },
- { name: "Mamut", minTime: 120, maxTime: 180, iconPath: "Mamut.png", category: 'champion' },
- { name: "Astronom", minTime: 360, maxTime: 420, iconPath: "Astronom.png", category: 'champion' },
- { name: "Kowal Lugas", minTime: 331, maxTime: 331, iconPath: "Kowal_Lugas.png", category: 'champion' },
- { name: "Straż Lugas", minTime: 331, maxTime: 331, iconPath: "Straż_Lugas.png", category: 'champion' }
- ];
- let timers = []; // Globalna tablica aktywnych timerów (lokalnych lub z grupy)
- const timerListUI = document.getElementById("timerList");
- const championSelect = document.getElementById("championSelect");
- const addButton = document.getElementById("addButton");
- const useCustomTimeCheckbox = document.getElementById("useCustomTime");
- const customTimeInput = document.getElementById("customTime");
- const resetButton = document.getElementById("resetButton");
- window.respawnSound = document.getElementById("respawnSound"); // Udostępnienie globalne dla firebase.js
- // --- FUNKCJE ZARZĄDZANIA TIMERAMI ---
- window.saveCurrentTimers = function() {
- if (window.currentUser && window.activeGroupId) {
- const groupTimersRef = db.collection("groups").doc(window.activeGroupId);
- const timersToSaveForGroup = timers.map(t => ({
- name: t.name,
- minRespawnTime: new Date(t.minRespawnTime).toISOString(),
- maxRespawnTime: new Date(t.maxRespawnTime).toISOString(),
- alertPlayed: t.alertPlayed,
- addedBy: window.currentUser.uid,
- addedByName: window.currentUser.email.split('@')[0]
- }));
- groupTimersRef.update({ activeTimers: timersToSaveForGroup })
- .catch(error => console.error("Błąd zapisu timerów grupy:", error));
- } else {
- const timersToSaveLocal = timers.map(t => ({
- name: t.name,
- minRespawnTime: new Date(t.minRespawnTime).toISOString(),
- maxRespawnTime: new Date(t.maxRespawnTime).toISOString(),
- alertPlayed: t.alertPlayed
- }));
- localStorage.setItem("timers", JSON.stringify(timersToSaveLocal));
- }
- }
- window.loadTimers = function() { // Ładuje z localStorage
- const stored = localStorage.getItem("timers");
- timers = [];
- if (stored) {
- const parsed = JSON.parse(stored);
- parsed.forEach(t => {
- timers.push({
- name: t.name,
- minRespawnTime: new Date(t.minRespawnTime),
- maxRespawnTime: new Date(t.maxRespawnTime),
- alertPlayed: t.alertPlayed,
- element: null,
- timeSpan: null
- });
- });
- }
- renderFullTimerList();
- }
- window.loadTimersFromArray = function(timersData) { // Ładuje z danych ( z Firebase)
- timers = [];
- if (timersData && timersData.length > 0) {
- timersData.forEach(t => {
- timers.push({
- name: t.name,
- minRespawnTime: new Date(t.minRespawnTime),
- maxRespawnTime: new Date(t.maxRespawnTime),
- alertPlayed: t.alertPlayed,
- element: null,
- timeSpan: null
- });
- });
- }
- renderFullTimerList();
- }
- window.clearLocalTimers = function() {
- timers = [];
- renderFullTimerList();
- }
- function renderFullTimerList() {
- if (!timerListUI) return;
- timerListUI.innerHTML = "";
- timers.sort((a, b) => new Date(a.minRespawnTime) - new Date(b.minRespawnTime));
- if (timers.length === 0) {
- timerListUI.innerHTML = "<p>Brak aktywnych timerów.</p>";
- } else {
- timers.forEach(timerData => {
- createAndAppendTimerElement(timerData);
- });
- }
- updateTimersTimeDisplayOnly();
- }
- function createAndAppendTimerElement(timerData) {
- const champion = champions.find(c => c.name === timerData.name);
- if (!champion) return;
- const iconUrl = champion.iconPath ? ICON_BASE_URL + champion.iconPath : "";
- const timerElement = document.createElement("div");
- timerElement.className = "timer-item";
- timerElement.dataset.timerName = timerData.name;
- if (iconUrl) timerElement.classList.add("with-icon");
- const timerContentDiv = document.createElement("div");
- timerContentDiv.className = "timer-item-content";
- if (iconUrl) {
- const icon = document.createElement("img");
- icon.src = iconUrl;
- icon.alt = name;
- icon.className = "timer-icon";
- icon.onerror = function() { this.style.display = 'none'; };
- timerElement.appendChild(icon);
- }
- const nameSpan = document.createElement("strong");
- nameSpan.textContent = timerData.name;
- timerContentDiv.appendChild(nameSpan);
- timerContentDiv.appendChild(document.createElement("br"));
- const timeSpan = document.createElement("span");
- timerContentDiv.appendChild(timeSpan);
- timerElement.appendChild(timerContentDiv);
- const deleteButton = document.createElement("button");
- deleteButton.textContent = "Usuń";
- deleteButton.className = "delete-btn";
- deleteButton.onclick = (e) => {
- e.stopPropagation();
- const indexToRemove = timers.findIndex(t => t.name === timerData.name);
- if (indexToRemove > -1) {
- timers.splice(indexToRemove, 1); // Usuń z tablicy
- }
- timerElement.remove(); // Usuń z DOM
- if (timers.length === 0 && timerListUI) {
- timerListUI.innerHTML = "<p>Brak aktywnych timerów.</p>";
- }
- window.saveCurrentTimers(); // Zapisz zmiany
- };
- timerElement.appendChild(deleteButton);
- timerData.element = timerElement;
- timerData.timeSpan = timeSpan;
- timerListUI.appendChild(timerElement);
- }
- function addTimerInternal(name, respawnTimes, alertPlayed = false) {
- if (timers.some(t => t.name === name)) return; // Już istnieje, nie dodawaj
- const newTimerData = {
- name: name,
- minRespawnTime: respawnTimes.min,
- maxRespawnTime: respawnTimes.max,
- alertPlayed: alertPlayed,
- element: null,
- timeSpan: null
- };
- timers.push(newTimerData);
- if (timerListUI && timerListUI.querySelector('p')) { // Usuń "Brak timerów" jeśli było
- timerListUI.innerHTML = "";
- }
- createAndAppendTimerElement(newTimerData); // Stwórz i dodaj do DOM
- // Utrzymaj posortowaną listę w DOM
- sortAndReorderDOMList();
- updateTimersTimeDisplayOnly(); // Tylko aktualizuj czasy
- }
- function sortAndReorderDOMList() {
- if (!timerListUI || timers.length === 0) return;
- timers.sort((a, b) => new Date(a.minRespawnTime) - new Date(b.minRespawnTime));
- const fragment = document.createDocumentFragment();
- timers.forEach(timer => {
- if (timer.element) { // Upewnij się, że element istnieje
- fragment.appendChild(timer.element);
- }
- });
- timerListUI.innerHTML = ''; // Wyczyść kontener przed dodaniem posortowanych
- timerListUI.appendChild(fragment);
- }
- function addTimerFromUI() {
- const selectedChampionName = championSelect.value;
- if (!selectedChampionName) return alert("Proszę wybrać championa.");
- if (timers.some(t => t.name === selectedChampionName)) return alert("Ten champion jest już na liście!");
- const champion = champions.find(c => c.name === selectedChampionName);
- if (!champion) return;
- let startTime = new Date();
- if (useCustomTimeCheckbox.checked && customTimeInput.value) {
- const [hours, minutes] = customTimeInput.value.split(":").map(Number);
- if (isNaN(hours) || isNaN(minutes) || hours < 0 || hours > 23 || minutes < 0 || minutes > 59) {
- return alert("Niepoprawny format własnej godziny. Użyj HH:MM (00:00 - 23:59).");
- }
- startTime.setHours(hours, minutes, 0, 0);
- }
- let minRespawnDate, maxRespawnDate;
- if (champion.name === 'Kapłan Śmierci') {
- minRespawnDate = new Date(startTime.getFullYear(), startTime.getMonth(), startTime.getDate(), 16, 0, 0);
- maxRespawnDate = new Date(startTime.getFullYear(), startTime.getMonth(), startTime.getDate(), 22, 0, 0);
- if (startTime > maxRespawnDate) {
- minRespawnDate.setDate(minRespawnDate.getDate() + 1);
- maxRespawnDate.setDate(maxRespawnDate.getDate() + 1);
- }
- } else {
- minRespawnDate = new Date(startTime.getTime() + champion.minTime * 60000);
- maxRespawnDate = new Date(startTime.getTime() + champion.maxTime * 60000);
- }
- addTimerInternal(champion.name, { min: minRespawnDate, max: maxRespawnDate });
- window.saveCurrentTimers(); // Zapisz stan po dodaniu
- }
- function updateTimersTimeDisplayOnly() {
- let stateChanged = false;
- timers.forEach(timer => {
- if (!timer.element || !timer.timeSpan) return;
- const now = new Date();
- const minRespawn = new Date(timer.minRespawnTime);
- const maxRespawn = new Date(timer.maxRespawnTime);
- const timeLeftMin = Math.floor((minRespawn - now) / 1000);
- const timeLeftMax = Math.floor((maxRespawn - now) / 1000);
- let previousAlertState = timer.alertPlayed;
- timer.element.classList.remove('window-open');
- let contentHTML;
- if (timeLeftMin > 0) {
- contentHTML = `Okno za: <strong>${Math.floor(timeLeftMin / 60)}:${(timeLeftMin % 60).toString().padStart(2, "0")}</strong>`;
- } else if (timeLeftMax > 0) {
- contentHTML = `<strong style="color: #6eff7a;">OKNO OTWARTE</strong><br>Koniec za: ${Math.floor(timeLeftMax / 60)}:${(timeLeftMax % 60).toString().padStart(2, "0")}`;
- timer.element.classList.add('window-open');
- if (!timer.alertPlayed && window.respawnSound && window.respawnSound.src && window.respawnSound.readyState >= 2) {
- timer.alertPlayed = true;
- window.respawnSound.play().catch(err => console.warn("Audio play error:", err));
- }
- } else {
- contentHTML = `<span style="color: #ff8c8c;">Okno minęło!</span>`;
- }
- if (timer.timeSpan.innerHTML !== contentHTML) {
- timer.timeSpan.innerHTML = contentHTML;
- }
- if (timer.alertPlayed !== previousAlertState) {
- stateChanged = true;
- }
- });
- const initialLength = timers.length;
- timers = timers.filter(timer => {
- const isOutdated = (new Date(timer.maxRespawnTime) - new Date()) / 1000 < -180; // 3 minuty po końcu okna
- if (isOutdated && timer.element) {
- timer.element.remove();
- }
- return !isOutdated;
- });
- if (timers.length !== initialLength) { // Jeśli jakieś timery zostały usunięte
- stateChanged = true;
- if (timers.length === 0 && timerListUI && !timerListUI.querySelector('p')) {
- timerListUI.innerHTML = "<p>Brak aktywnych timerów.</p>";
- }
- }
- if (stateChanged) {
- window.saveCurrentTimers(); // Zapisz tylko jeśli stan alertu lub liczba timerów się zmieniła
- }
- }
- function populateChampionSelect() {
- if(!championSelect) return;
- championSelect.innerHTML = '<option value="">-- Wybierz Championa --</option>';
- const categories = {
- 'event': '--- Eventy Cykliczne ---',
- 'boss': '--- Bosy Lotne ---',
- 'champion': '--- Chempioni ---'
- };
- for (const category in categories) {
- const optgroup = document.createElement('optgroup');
- optgroup.label = categories[category];
- champions.filter(c => c.category === category)
- .forEach(c => {
- const option = document.createElement('option');
- option.value = c.name;
- option.textContent = `${c.name} ${formatWindowText(c)}`;
- optgroup.appendChild(option);
- });
- championSelect.appendChild(optgroup);
- }
- }
- function formatWindowText(champ) {
- if (champ.name === 'Kapłan Śmierci') return '(16:00-22:00)';
- if (champ.name === '[Event] Polowanie na Lempo') return '(Aktywny)';
- if (champ.minTime === 0 && champ.maxTime === 0) return '(Brak Timera)';
- if (champ.minTime === champ.maxTime && champ.minTime !==0) return `(${champ.minTime}m)`;
- return `(${champ.minTime}-${champ.maxTime}m)`;
- }
- // --- OBSŁUGA USTAWIEŃ DŹWIĘKU ---
- const soundSettingsBtn = document.getElementById("soundSettingsBtn");
- const soundModal = document.getElementById("soundModal");
- const soundSelect = document.getElementById("soundSelect");
- const customSoundContainer = document.getElementById("customSoundContainer");
- const customSoundInput = document.getElementById("customSoundInput");
- const saveSoundBtn = document.getElementById("saveSound");
- const cancelSoundBtn = document.getElementById("cancelSound");
- if(soundSettingsBtn && soundModal) soundSettingsBtn.addEventListener("click", () => soundModal.style.display = "block");
- if(cancelSoundBtn && soundModal) cancelSoundBtn.addEventListener("click", () => soundModal.style.display = "none");
- if(soundSelect && customSoundContainer) soundSelect.addEventListener("change", () => {
- customSoundContainer.style.display = (soundSelect.value === "custom") ? "block" : "none";
- });
- if(saveSoundBtn && soundModal && soundSelect && customSoundInput && window.respawnSound) saveSoundBtn.addEventListener("click", () => {
- let soundToSave;
- if (soundSelect.value === "custom" && customSoundInput.files[0]) {
- const file = customSoundInput.files[0];
- if (file.size > 500000) {
- alert("Plik dźwiękowy jest za duży (max 0.5MB)."); return;
- }
- const reader = new FileReader();
- reader.onload = function(event) {
- soundToSave = event.target.result;
- window.respawnSound.src = soundToSave;
- if (typeof saveUserSetting === 'function' && window.currentUser) saveUserSetting('sound', soundToSave);
- else localStorage.setItem("notificationSound", soundToSave);
- };
- reader.readAsDataURL(file);
- } else if (soundSelect.value !== "custom") {
- soundToSave = soundSelect.value;
- window.respawnSound.src = soundToSave;
- if (typeof saveUserSetting === 'function' && window.currentUser) saveUserSetting('sound', soundToSave);
- else localStorage.setItem("notificationSound", soundToSave);
- }
- soundModal.style.display = "none";
- });
- window.loadNotificationSound = function() {
- const defaultSound = "/Sound/ding-36029.mp3";
- if (!window.currentUser) {
- const savedSound = localStorage.getItem("notificationSound") || defaultSound;
- if (window.respawnSound) window.respawnSound.src = savedSound;
- if (soundSelect) {
- soundSelect.value = savedSound.startsWith('data:') ? 'custom' : savedSound;
- if (soundSelect.value === 'custom' && customSoundContainer) customSoundContainer.style.display = 'block';
- }
- }
- }
- // --- OBSŁUGA USTAWIEŃ TŁA ---
- const backgroundSettingsBtn = document.getElementById('backgroundSettingsBtn');
- const backgroundModal = document.getElementById('backgroundModal');
- const backgroundOptionsContainer = document.getElementById('background-options-container');
- const saveBackgroundBtn = document.getElementById('saveBackground');
- const cancelBackgroundBtn = document.getElementById('cancelBackground');
- let UIAselectedBackgroundPath = '';
- const backgrounds = {
- 'Zgliszcza Taernu': 'Grafiki/tlo666.png',
- 'Mglista Przełęcz': 'Grafiki/tlo2.png',
- 'Deszczowy Rynek': 'Grafiki/tlo3.png',
- 'Wejście do Ruin': 'Grafiki/tlo4.png'
- };
- const defaultBackground = backgrounds['Zgliszcza Taernu'];
- window.applyBackground = function(path) {
- document.body.style.backgroundImage = `url('${path}')`;
- }
- function populateBackgroundOptions() {
- if(!backgroundOptionsContainer) return;
- backgroundOptionsContainer.innerHTML = '';
- let currentEffectiveBackground = defaultBackground;
- if(window.currentUser) {
- const bodyBg = document.body.style.backgroundImage;
- if (bodyBg && bodyBg.includes('url("')) {
- currentEffectiveBackground = bodyBg.split('url("')[1].split('")')[0];
- }
- } else {
- currentEffectiveBackground = localStorage.getItem('appBackground') || defaultBackground;
- }
- UIAselectedBackgroundPath = currentEffectiveBackground;
- for (const name in backgrounds) {
- const path = backgrounds[name];
- const thumb = document.createElement('div');
- thumb.className = 'background-thumbnail';
- thumb.style.backgroundImage = `url('${path}')`;
- thumb.dataset.path = path;
- thumb.title = name;
- if (path === currentEffectiveBackground) thumb.classList.add('selected');
- thumb.addEventListener('click', () => {
- backgroundOptionsContainer.querySelectorAll('.background-thumbnail.selected').forEach(s => s.classList.remove('selected'));
- thumb.classList.add('selected');
- UIAselectedBackgroundPath = path;
- });
- backgroundOptionsContainer.appendChild(thumb);
- }
- }
- if(backgroundSettingsBtn && backgroundModal) backgroundSettingsBtn.addEventListener('click', () => {
- populateBackgroundOptions();
- backgroundModal.style.display = 'block';
- });
- if(cancelBackgroundBtn && backgroundModal) cancelBackgroundBtn.addEventListener('click', () => backgroundModal.style.display = 'none');
- if(saveBackgroundBtn && backgroundModal) saveBackgroundBtn.addEventListener('click', () => {
- if (UIAselectedBackgroundPath) {
- applyBackground(UIAselectedBackgroundPath);
- if (typeof saveUserSetting === 'function' && window.currentUser) saveUserSetting('background', UIAselectedBackgroundPath);
- else localStorage.setItem('appBackground', UIAselectedBackgroundPath);
- }
- backgroundModal.style.display = 'none';
- });
- window.loadSavedBackground = function() {
- if (!window.currentUser) {
- const savedPath = localStorage.getItem('appBackground') || defaultBackground;
- applyBackground(savedPath);
- }
- }
- // --- LISTENERY I INICJALIZACJA ---
- if(addButton) addButton.addEventListener("click", addTimerFromUI);
- if(resetButton) resetButton.addEventListener("click", () => {
- if (confirm("Czy na pewno chcesz zresetować WSZYSTKIE timery dla obecnego kontekstu (" + (document.getElementById('currentTimerContext')?.textContent || 'Lokalne') + ")?")) {
- timers = [];
- renderFullTimerList(); // Wyrenderuje pustą listę i wywoła save
- }
- });
- if(useCustomTimeCheckbox && customTimeInput) useCustomTimeCheckbox.addEventListener("change", () => {
- customTimeInput.disabled = !useCustomTimeCheckbox.checked;
- if (!useCustomTimeCheckbox.checked) customTimeInput.value = "";
- });
- populateChampionSelect();
- // Główna pętla aktualizacji TYLKO CZASU w timerach
- setInterval(updateTimersTimeDisplayOnly, 1000);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement