/g, '>').replace(/"/g, '"').replace(/'/g, ''');}function submitSearch(query){const q = query.trim();window.location.href = 'https://www.kritische-anleger.de/suche/?q=' + encodeURIComponent(q);}async function runSearch(){var iconLoading= '';var apiURL= 'https://www.kritische-anleger.de/api/apiSearch.php';const urlParams= new URLSearchParams(window.location.search);const queryRaw= urlParams.get('q');if(queryRaw !== null){const query = queryRaw.trim();document.getElementById('ka_search_input').value = escapeHTML(query);if(query !== '' && query !== 'Suchbegriff' && query !== 'Thema suchen'){const searchButton = document.querySelector('.search_button');const originalLabel = searchButton.textContent;searchButton.classList.add('disabled');searchButton.style.pointerEvents = 'none';searchButton.style.opacity = '0.5';searchButton.textContent = 'Bitte warten ...';document.getElementById('search_result_loading').innerHTML = iconLoading;try{let params= {mode: 'runSearch', searchString: query};let response= await fetch(apiURL, {method: 'POST',headers: {'Content-Type': 'application/json'},body: JSON.stringify(params)});let text= await response.text();let result= JSON.parse(text);showResults(result);}catch(err){showError('Fehler bei der Suche: ' + err.message);}searchButton.classList.remove('disabled');searchButton.style.pointerEvents = 'auto';searchButton.style.opacity = '1';searchButton.textContent = originalLabel;}else{showError('Bitte geben Sie einen aussagekräftigen Suchbegriff ein.');}}else{document.getElementById('ka_search_input').value = '';}}function showError(errorMessage){document.getElementById('search_error').style.display = 'block';document.getElementById('search_error').innerHTML = errorMessage;}function showResults(result){document.getElementById('search_result_loading').innerHTML = '';if(result['errorMessage'] != ''){showError(result['errorMessage']);}else{document.getElementById('search_result_list').innerHTML = result['resultHTML'];}}document.querySelectorAll('.search_form_wrapper').forEach(box => {const input= box.querySelector('.search_text_input');const button = box.querySelector('.search_button');button.addEventListener('click', () => { submitSearch(input.value); });input.addEventListener('keydown', e => { if (e.key === 'Enter') { submitSearch(input.value); } });});runSearch();