(function($) { 'use strict'; // OAuth-Redirect-Handler (function() { try { // Prüfe ob wir von OAuth kommen (über Startseite) if (window.location.search.indexOf('wg_auth_redirect=1') !== -1) { var targetUrl = sessionStorage.getItem('wg_login_redirect'); sessionStorage.removeItem('wg_login_redirect'); sessionStorage.removeItem('wg_login_success'); if (targetUrl) { window.location.replace(targetUrl); return; } } } catch(e) {} })(); // Suche nach Login wiederherstellen (function() { try { var isLoggedIn = document.body && document.body.classList.contains('logged-in'); if (isLoggedIn) { var savedSearch = localStorage.getItem('wg_pending_search'); if (savedSearch) { localStorage.removeItem('wg_pending_search'); // Parse gespeicherte Suche var searchData = JSON.parse(savedSearch); var searchUrl = searchData.url; // Prüfe ob Suche noch gültig (max 30 Min alt) if (searchData.timestamp && (Date.now() - searchData.timestamp) < 30 * 60 * 1000) { // Redirect zur Suchseite mit Parametern (nur wenn nicht bereits dort) var currentPath = window.location.pathname; if (searchUrl && currentPath.indexOf('/entdecken/') === -1 && currentPath.indexOf('/suche/') === -1) { window.location.replace(searchUrl); return; } } } } } catch(e) { console.log('WG Search restore error:', e); } })(); // Markiere dass User eingeloggt ist - für spätere Prüfung (function() { try { if (document.body.classList.contains('logged-in')) { sessionStorage.setItem('wg_was_logged_in', '1'); } } catch(e) {} })(); // Reset Loading States bei Browser-Back (pageshow/bfcache) $(window).on('pageshow', function(event) { // Prüfe ob Seite aus dem bfcache geladen wurde if (event.originalEvent && event.originalEvent.persisted) { // Reset alle Loading-States $('.loading').removeClass('loading').prop('disabled', false); $('.wg-loading').removeClass('wg-loading'); // Reset Select-Dropdowns $('.wg-status-select').each(function() { $(this).prop('disabled', false); }); // Schließe alle offenen Modals $('.wg-modal').remove(); } // Immer bei pageshow: Reset Loading States (auch ohne bfcache) setTimeout(function() { $('.loading').removeClass('loading').prop('disabled', false); $('.wg-loading').removeClass('wg-loading'); }, 100); }); // Auch bei normalem Page Load: Stelle sicher dass keine Loading-States hängen $(document).ready(function() { $('.loading').removeClass('loading').prop('disabled', false); $('.wg-loading').removeClass('wg-loading'); }); // Toast-Benachrichtigungen function showToast(message, type = 'success') { const toast = $('