PageSourceSearch

https://www.freital-magazin.de/wp-content/cache/autoptimize/js/aut…_single_ab997b81aff0a914ca32f70c4c029ffc.js

js freital-magazin.de collected 2026-10-09 21:50:46 UTC 3,532 bytes, 21 lines download raw bytes

1(function(){'use strict';const l10n=window.wpPollsL10n||{};const FADE_DURATION=400;function prefersReducedMotion(){return(typeof window.matchMedia==='function'&&window.matchMedia('(prefers-reduced-motion: reduce)').matches);}
2function pollContainer(currentPollId){return document.getElementById('polls-'+currentPollId);}
3function setLoading(currentPollId,visible){const loading=document.getElementById('polls-'+currentPollId+'-loading',);if(loading){loading.style.display=visible?'block':'none';}}
4function fadeTo(element,opacity){if(!element){return;}
5element.style.transition=prefersReducedMotion()?'':'opacity '+FADE_DURATION+'ms';element.style.opacity=opacity;}
6function show(element){if(element){element.style.transition='';element.style.opacity='';}}
7function pollVote(currentPollId){const form=document.getElementById('polls_form_'+currentPollId);if(!form){return;}
8const multipleField=document.getElementById('poll_multiple_ans_'+currentPollId,);const pollMultipleAns=multipleField?parseInt(multipleField.value,10):0;const selected=[];const choices=form.querySelectorAll('input[type="checkbox"], input[type="radio"], option',);Array.prototype.forEach.call(choices,function(choice){if(choice.checked||choice.selected){selected.push(choice.value);}});if(pollMultipleAns>0){if(selected.length===0){alert(l10n.text_valid);}else if(selected.length>pollMultipleAns){alert(l10n.text_multiple+' '+pollMultipleAns);}else{pollProcess(currentPollId,selected.join(','));}
9return;}
10const pollAnswerId=selected.length?parseInt(selected[selected.length-1],10):0;if(pollAnswerId>0){pollProcess(currentPollId,pollAnswerId);}else{alert(l10n.text_valid);}}
11function pollRequest(currentPollId,view,extraFields){const nonceField=document.getElementById('poll_'+currentPollId+'_nonce',);const body=new URLSearchParams();body.append('action','polls');body.append('view',view);body.append('poll_id',currentPollId);body.append('poll_'+currentPollId+'_nonce',nonceField?nonceField.value:'',);if(extraFields){Object.keys(extraFields).forEach(function(name){body.append(name,extraFields[name]);});}
12fadeTo(pollContainer(currentPollId),0);setLoading(currentPollId,true);fetch(l10n.ajax_url,{method:'POST',credentials:'include',cache:'no-cache',body,}).then(function(response){return response.text();}).then(function(data){pollProcessSuccess(currentPollId,data);}).catch(function(){setLoading(currentPollId,false);show(pollContainer(currentPollId));});}
13function pollProcess(currentPollId,pollAnswerId){const fields={};fields['poll_'+currentPollId]=pollAnswerId;pollRequest(currentPollId,'process',fields);}
14function pollResult(currentPollId){pollRequest(currentPollId,'result');}
15function pollBooth(currentPollId){pollRequest(currentPollId,'booth');}
16function pollProcessSuccess(currentPollId,data){const container=pollContainer(currentPollId);if(container){const parsed=document.createElement('div');parsed.innerHTML=data;container.replaceWith.apply(container,Array.prototype.slice.call(parsed.childNodes),);}
17setLoading(currentPollId,false);show(pollContainer(currentPollId));}
18document.addEventListener('click',function(event){const target=event.target;if(!target||typeof target.closest!=='function'){return;}
19const trigger=target.closest('[data-poll-action]');if(!trigger){return;}
20const pollId=trigger.getAttribute('data-poll-id');if(trigger.tagName==='A'){event.preventDefault();}
21switch(trigger.getAttribute('data-poll-action')){case'vote':pollVote(pollId);break;case'result':pollResult(pollId);break;case'booth':pollBooth(pollId);break;}});}());

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.