1document.addEventListener('DOMContentLoaded', function() { 2 moveEasyLanguageLink(); 3}); 4 5/** 6 * Move the easy language link into the readspeaker element if both elements exist 7 */ 8function moveEasyLanguageLink() { 9 // get element with class "easy-language-link" 10 const easyLanguageLink = document.querySelector('.easy-language-link'); 11 12 // get element with class "readspeaker_outer_wrapper" 13 const readspeakerOuterWrapper = document.querySelector('.readspeaker_outer_wrapper'); 14 15 // if both elements exist, prepend the easy language link inside the readspeaker element 16 if (easyLanguageLink && readspeakerOuterWrapper) { 17 readspeakerOuterWrapper.prepend(easyLanguageLink); 18 19 // adjust the margin of the easy language link to match the readspeaker element 20 easyLanguageLink.style.marginRight = '1.5rem'; 21 easyLanguageLink.style.marginBottom = '0.55rem'; 22 } 23} 24 25/** 26 * Download ICS file for a single event 27 * 28 * @param {HTMLElement} button The button element 29 * @param {number} eventId The event ID 30 * @returns void 31 */ 32function downloadSingleEventIcs(button, eventId) { 33 // Get the REST API url 34 var baseUrl = window.location.protocol + '//' + window.location.host; 35 var apiUrl = baseUrl + '/wp-json/flib/v1/events'; 36 37 // Show loading state 38 button.disabled = true; 39 // Store original content before changing it 40 if (!button.getAttribute('data-original-content')) { 41 button.setAttribute('data-original-content', button.innerHTML); 42 } 43 button.innerHTML = '<span>Wird erstellt...</span>'; 44 45 try { 46 // Build POST data for REST API with event_id 47 var postData = { 48 format: 'ics', 49 event_id: eventId.toString() 50 }; 51 52 // Create a temporary form for file download 53 var tempForm = document.createElement('form'); 54 tempForm.method = 'POST'; 55 tempForm.action = apiUrl; 56 tempForm.style.display = 'none'; 57 58 // Convert POST data to form fields 59 for (var key in postData) { 60 if (postData[key] !== null && postData[key] !== '') { 61 var input = document.createElement('input'); 62 input.type = 'hidden'; 63 input.name = key; 64 input.value = postData[key]; 65 tempForm.appendChild(input); 66 } 67 } 68 69 // Add form to DOM, submit, and remove 70 document.body.appendChild(tempForm); 71 tempForm.submit(); 72 document.body.removeChild(tempForm); 73 } catch (error) { 74 console.error('Fehler beim Erstellen der ICS-Datei:', error); 75 } 76 77 // Reset button state 78 setTimeout(function() { 79 button.disabled = false; 80 // Restore original button content 81 var originalContent = button.getAttribute('data-original-content'); 82 if (originalContent) { 83 button.innerHTML = originalContent; 84 } else { 85 button.innerHTML = '<span>Zum Kalender hinzufügen</span>'; 86 } 87 }, 2000); 88}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.