PageSourceSearch

https://soziale-verteidigung.de/wp-content/plugins/petitioner/dist/main.js?ver=0.8.6

js soziale-verteidigung.de collected 2026-10-02 05:46:15 UTC 16,401 bytes, 10 lines download raw bytes

1var e=class{constructor(e){if(window.petitionerCaptcha!==void 0&&window.petitionerCaptcha.recaptchaSiteKey){let t=e.querySelector(`[name="petitioner-g-recaptcha-response"]`);t&&(t.value=``),e.addEventListener(`focusin`,function(){t&&t?.value||window.grecaptcha===void 0||window.grecaptcha?.ready===void 0||window.grecaptcha.ready(function(){window.grecaptcha?.execute(window.petitionerCaptcha?.recaptchaSiteKey||``,{}).then(e=>{t&&(t.value=e)}).catch(e=>{console.error(`petitioner - reCAPTCHA execution failed:`,e)})})},{once:!0})}else console.error(`petitioner - reCAPTCHA site key is missing or reCAPTCHA failed to load.`)}},t=class{constructor(e){this.widgetId=null,this.callbackFunction=null,this.form=e,this.hcaptchaField=this.form.querySelector(`[name="petitioner-h-captcha-response"]`),this.hcaptchaContainer=this.form.querySelector(`.petitioner-h-captcha-container`),this.isHCaptchaReady()&&this.initHCaptcha()}isHCaptchaReady(){return!!(typeof hcaptcha<`u`&&window.petitionerCaptcha?.enableHcaptcha&&window.petitionerCaptcha?.hcaptchaSiteKey&&this.hcaptchaContainer)}initHCaptcha(){!hcaptcha||!window.petitionerCaptcha?.hcaptchaSiteKey||!this.hcaptchaContainer||(this.widgetId=hcaptcha.render(this.hcaptchaContainer,{sitekey:window.petitionerCaptcha.hcaptchaSiteKey,size:`invisible`,callback:this.handleSuccess.bind(this)}))}handleSuccess(e){if(!e){console.warn(`❌ petitioner - hCaptcha token missing.`);return}if(!this.hcaptchaField){console.error(`❌ petitioner - hCaptcha input field not found.`);return}this.hcaptchaField.value=e,typeof this.callbackFunction==`function`&&this.callbackFunction()}validate(e){if(!this.hcaptchaField||this.hcaptchaField.value){e();return}this.callbackFunction=e,hcaptcha&&this.widgetId&&hcaptcha.execute(this.widgetId)}},n=class{constructor(e){this.widgetId=null,this.callbackFunction=null,this.form=e,this.turnstileField=this.form.querySelector(`[name="petitioner-turnstile-response"]`),this.turnstileContainer=this.form.querySelector(`.petitioner-turnstile-container`),!(window?.turnstile===void 0||!window.petitionerCaptcha?.turnstileSiteKey||!this.turnstileContainer)&&this.initTurnstile()}initTurnstile(){let e=window.petitionerCaptcha?.turnstileSiteKey;if(!e){this.handleError();return}this.widgetId=window?.turnstile?.render?.(this.turnstileContainer,{sitekey:e,callback:this.handleSuccess.bind(this),theme:`light`,"error-callback":this.handleError.bind(this)})}handleSuccess(e){if(!e){console.warn(`❌ petitioner - Turnstile token missing.`);return}if(!this.turnstileField){console.error(`❌ petitioner - Turnstile input field not found.`);return}this.turnstileField.value=e,typeof this.callbackFunction==`function`&&this.callbackFunction()}handleError(){console.error(`❌ petitioner - Turnstile encountered an error.`)}validate(e){if(!this.turnstileField||this.turnstileField.value){e();return}this.callbackFunction=e,this.widgetId&&window?.turnstile?.execute?.(this.widgetId)}};async function r({nonceEndpoint:e,fallbackNonce:t=``}){if(!e){if(t)return t;throw Error(`No nonce endpoint available`)}try{let t=await fetch(e,{method:`GET`,credentials:`same-origin`});if(!t.ok)throw Error(`Failed to fetch nonce`);let n=await t.json();if(n.success&&n.data?.nonce)return n.data.nonce;throw Error(`Invalid nonce response`)}catch(e){if(console.warn(`Could not fetch fresh nonce:`,e),t)return t;throw Error(`No nonce available`)}}var i=new Map;function a(e){let{nonceEndpoint:t}=e;if(!t)return r(e);let n=i.get(t);if(n)return n;let a=r(e).finally(()=>{i.delete(t)});return i.set(t,a),a}var o=class{constructor(e){this.captchaValidated=!1,this.hcaptcha=null,this.turnstile=null,this._escListener=null,this.wrapper=e,this.responseTitle=null,this.responseText=null,this.formEl=null,this.viewLetterBTN=null,this.petitionerModal=null,this.modalClose=null,this.backdrop=null;let{actionPath:t=``,nonce:n=``,nonceEndpoint:r=``}=window?.petitionerFormSettings||{};this.actionPath=t||``,this.nonceEndpoint=r||``,this.nonce=n||``,this.wrapper&&(this.responseTitle=this.wrapper.querySelector(`.petitioner__response > h3`),this.responseText=this.wrapper.querySelector(`.petitioner__response > p`),this.formEl=this.wrapper.querySelector(`form`),this.viewLetterBTN=this.wrapper.querySelector(`.petitioner__btn--letter`),this.petitionerModal=this.wrapper.querySelector(`.petitioner-modal`),this.modalClose=this.wrapper.querySelector(`.petitioner-modal__close`),this.backdrop=this.wrapper.querySelector(`.petitioner-modal__backdrop`),this.initializeCaptcha(),this.setupEventListeners())}initializeCaptcha(){window.petitionerCaptcha!==void 0&&(window.petitionerCaptcha.enableRecaptcha===`1`&&this.formEl&&new e(this.formEl),window.petitionerCaptcha.enableHcaptcha===`1`&&this.formEl&&(this.hcaptcha=new t(this.formEl)),window.petitionerCaptcha.enableTurnstile===`1`&&this.formEl&&(this.turnstile=new n(this.formEl)))}setupEventListeners(){this.formEl&&this.formEl.addEventListener(`submit`,this.handleFormSubmit.bind(this)),this.viewLetterBTN&&this.viewLetterBTN.addEventListener(`click`,()=>this.toggleModal(!0)),this.backdrop&&this.backdrop.addEventListener(`click`,()=>this.toggleModal(!1)),this.modalClose&&this.modalClose.addEventListener(`click`,()=>this.toggleModal(!1)),document.addEventListener(`petitionerFormSubmit`,(e=>{if(!e.detail?.success)return;let t=e.detail.wrapperEl.getAttribute(`data-redirect-url`);t&&(window.location.href=t)}))}showResponseMSG(e,t=!1){this.wrapper?.classList.add(`petitioner--submitted`);let{title:n,message:r}=e||{title:``,message:``};
1this.responseTitle&&(this.responseTitle.innerText=n),this.responseText&&(this.responseText.innerHTML=r)}toggleModal(e=!0){this.petitionerModal&&(this.petitionerModal.classList[e?`add`:`remove`](`petitioner-modal--visible`),e?(this._escListener=e=>{e.key===`Escape`&&this.toggleModal(!1)},document.addEventListener(`keydown`,this._escListener)):this._escListener&&=(document.removeEventListener(`keydown`,this._escListener),null))}handleFormSubmit(e){if(e.preventDefault(),this.shouldValidateHCaptcha()){this.hcaptcha.validate(()=>{this.captchaValidated=!0,this.submitForm()});return}if(this.shouldValidateTurnstile()){this.turnstile.validate(()=>{this.captchaValidated=!0,this.submitForm()});return}this.submitForm()}shouldValidateHCaptcha(){return!!(window.petitionerCaptcha?.enableHcaptcha&&this.hcaptcha&&!this.captchaValidated)}shouldValidateTurnstile(){return!!(window.petitionerCaptcha?.enableTurnstile&&this.turnstile&&!this.captchaValidated)}async submitForm(){if(this.formEl){this.wrapper?.classList.add(`petitioner--loading`);try{let e=new FormData(this.formEl),t=await a({nonceEndpoint:this.nonceEndpoint,fallbackNonce:this.nonce});this.nonce=t,e.append(`petitioner_nonce`,t);let n=await fetch(this.actionPath,{method:`POST`,body:e,credentials:`same-origin`,headers:{"X-Requested-With":`XMLHttpRequest`}});if(!n.ok)throw Error(`HTTP error! status: ${n.status}`);let r=await n.json();r.success?this.showResponseMSG(r.data,!0):this.showResponseMSG(r.data,!1),this.handleSubmissionComplete(e,r.success)}catch(e){console.error(`Error:`,e),alert(`An unexpected error occurred. Please try again later.`),this.handleSubmissionComplete()}}}handleSubmissionComplete(e,t=!1){if(this.wrapper?.classList.remove(`petitioner--loading`),this.formEl?.reset(),this.captchaValidated=!1,e){let n=new CustomEvent(`petitionerFormSubmit`,{detail:{formData:e,success:t,wrapperEl:this.wrapper}});document.dispatchEvent(n)}}};function s(e){try{return JSON.parse(e)}catch(e){return console.error(`Error parsing JSON:`,e),{}}}var c=class{constructor(e){if(this.options=e,this.options.currentPage=this.options.currentPage||1,this.submissionListDiv=document.createElement(`div`),this.submissionListDiv.className=`submissions__list`,this.paginationDiv=document.createElement(`div`),this.paginationDiv.className=`submissions__pagination`,this.prevPageLabel=window?.petitionerSubmissionSettings?.labels?.prevPage||`Previous page`,this.nextPageLabel=window?.petitionerSubmissionSettings?.labels?.nextPage||`Next page`,!this.options.wrapper)throw Error(`Element not found`)}formatDate(e){let t=e.split(` `)[0],n=new Date(t+`T00:00:00`);return isNaN(n.getTime())?e:n.toLocaleDateString(void 0,{day:`numeric`,month:`short`,year:`numeric`})}attachEventListeners(){this.paginationDiv&&this.paginationDiv.addEventListener(`click`,async e=>{let t=e.target.closest(`button`);if(t&&!t.disabled&&t.dataset.page){let e=parseInt(t.dataset.page,10);if(!isNaN(e)&&e!==this.options.currentPage){this.options.currentPage=e;let t=await this.options.onPageChange(e);this.options.submissions=t,this.update()}}})}render(){this.options.submissions&&(this.options.wrapper.appendChild(this.submissionListDiv),this.options.wrapper.appendChild(this.paginationDiv),this.submissionListDiv.innerHTML=this.renderSubmissionsList(),this.paginationDiv.innerHTML=this.renderPagination(),this.attachEventListeners())}update(){this.submissionListDiv.innerHTML=this.renderSubmissionsList(),this.paginationDiv.innerHTML=this.renderPagination()}renderSubmissionsList(){return!this.options.submissions||this.options.submissions.length===0?``:this.options.submissions.map(e=>this.renderSubmissionItem(e)).join(`, `)}renderSubmissionItem(e){return`<span class="submissions__item">${e.name}</span>`}getPaginationRange(e,t){let n=[],r=[],i=0,a=Math.max(1,t-1),o=Math.min(e,t+1);n.push(1);for(let t=a;t<=o;t++)t>1&&t<e&&n.push(t);e>1&&n.push(e);for(let e of n)i>0&&e-i!==1&&r.push(`...`),r.push(e),i=e;return r}renderPagination(){if(!this.options.total||!this.options.perPage||!this.options.pagination)return``;let e=Math.ceil(this.options.total/this.options.perPage);if(e<=1)return``;let t=this.options.currentPage||1,n=`<div class="ptr-pagination">`;if(t>1?n+=`<button class="ptr-pagination__item ptr-pagination__item--prev" data-page="${t-1}" aria-label="${this.prevPageLabel}">&lsaquo;</button>`:n+=`<button class="ptr-pagination__item ptr-pagination__item--prev" disabled aria-label="${this.prevPageLabel}">&lsaquo;</button>`,!this.options.hidePageNumbers){let r=this.getPaginationRange(e,t);for(let e of r)e===`...`?n+=`<span class="ptr-pagination__dots">...</span>`:n+=`<button class="ptr-pagination__item ${e===t?`active`:``}" data-page="${e}">${e}</button>`}return t<e?n+=`<button class="ptr-pagination__item ptr-pagination__item--next" data-page="${t+1}" aria-label="${this.nextPageLabel}">&rsaquo;</button>`:n+=`<button class="ptr-pagination__item ptr-pagination__item--next" disabled aria-label="${this.nextPageLabel}">&rsaquo;</button>`,n+=`</div>`,n}},l=class extends c{constructor(e){super(e),this.options=e}render(){this.options.submissions&&(this.options.wrapper.appendChild(this.submissionListDiv),this.options.wrapper.appendChild(this.paginationDiv),this.options.wrapper.style=this.getWrapperStyles(),this.submissionListDiv.innerHTML=this.renderSubmissionsList(),this.paginationDiv.innerHTML=this.renderPagination(),this.attachEventListeners())}renderSubmissionsList(){if(!this.options.submissions||this.options.submissions.length===0)return``;let e=this.prepareLabels(),t=this.options.submissions.map(e=>this.renderSubmissionItem(e)).join(``);return`
2		<div class="submissions__item submissions__item--heading">
3			${e.map(e=>`<div>${e}</div>`).join(``)}
4		</div>
5		${t}`}prepareLabels(){let e=[],t=this.options.submissions[0];return Object.keys(t).forEach(t=>{!this.options.labels?.[t]||!this.options.fields.includes(t)||e.push(this.options.labels?.[t])}),e}renderSubmissionItem(e){let t=Object.keys(e).filter(e=>this.options.labels&&e in this.options.labels&&this.options.fields.includes(e)),n=e.is_featured===`1`,r=[`submissions__item`];return n&&r.push(`submissions__item--featured`),`<div class="${r.join(` `)}">
6			${t.map(t=>{let n=t===`submitted_at`?this.formatDate(String(e[t])):e?.[t];return`<div class="submissions__item__inner">
7						<strong>${this.options.labels?.[t]||t}:</strong>
8						${n||``}
9					</div>`}).join(``)}
10		</div>`}getWrapperStyles(){return`--ptr-submission-columns: ${this.prepareLabels().length}`}},u=class{constructor(e){if(this.wrapper=e,this.currentPage=1,this.totalResults=10,!this.wrapper)throw Error(`Element not found`);let t=this.wrapper.dataset.ptrSettings;if(this.ajaxurl=window?.petitionerSubmissionSettings?.actionPath||``,this.nonce=window?.petitionerSubmissionSettings?.nonce||``,this.labels={},!this.ajaxurl||!this.nonce)throw Error(`AJAX URL or nonce is not defined in settings`);if(!t)throw Error(`Wrapper is missing data-ptr-settings attribute`);let n=s(t);if(!n||typeof n!=`object`||!n.form_id||!n.per_page||!n.style)throw Error(`Invalid settings provided for PetitionerSubmissions`);this.settings=n,this.init()}
10async init(){if(this.settings&&(await this.fetchSubmissions(),typeof this.submissions==`object`&&this.submissions?.length>0)){let e=this.settings.style===`simple`?c:l;this.renderer=new e({wrapper:this.wrapper,submissions:this.submissions,perPage:this.settings.per_page,total:this.totalResults,currentPage:this.currentPage,labels:this.labels,fields:this.settings.fields?this.settings.fields.split(`,`).map(e=>e.trim()):[],pagination:this.settings.show_pagination,hidePageNumbers:this.settings.hide_page_numbers||!1,onPageChange:async e=>(this.currentPage=e,await this.fetchSubmissions(),this.submissions??[])}),this.renderer.render()}}buildURL(){let e=new URL(this.ajaxurl,window.location.origin);return e.searchParams.set(`form_id`,String(this.settings?.form_id)),e.searchParams.set(`per_page`,String(this.settings?.per_page)),e.searchParams.set(`page`,String(this.currentPage)),this.settings?.fields&&e.searchParams.set(`fields`,this.settings.fields),e.toString()}async fetchSubmissions(){let e=this.buildURL(),t=await fetch(e);if(!t.ok)throw Error(`Failed to fetch submissions`);let n=await t.json();if(!n.success)throw Error(`Failed to fetch submissions: `+n.data);this.totalResults=Number(n.data.total)||0,this.submissions=n.data.submissions||[],this.labels=n.data.labels||[]}},d=class{constructor(e){this.wrapper=e,this.goalEl=this.wrapper.querySelector(`.petitioner__goal`),this.formId=this.wrapper.dataset.formId||``;let t=window?.petitionerFormSettings||{};this.goalProgressPath=t.goalProgressPath||``,this.nonceEndpoint=t.nonceEndpoint||``,this.nonce=t.nonce||``,!(!this.goalEl||!this.formId||!this.goalProgressPath)&&(this.init(),document.addEventListener(`petitionerFormSubmit`,e=>this.onFormSubmit(e)))}
10async init(){if(this.goalEl)try{let e=await a({nonceEndpoint:this.nonceEndpoint,fallbackNonce:this.nonce});this.nonce=e;let t=await this.fetchProgress(e);if(!t)return;this.apply(t)}catch(e){console.error(`Error:`,e)}}async fetchProgress(e){let t=new URL(this.goalProgressPath,window.location.origin);t.searchParams.set(`form_id`,this.formId),t.searchParams.set(`petitioner_nonce`,e);let n=await fetch(t.toString(),{method:`GET`,credentials:`same-origin`,headers:{"X-Requested-With":`XMLHttpRequest`}});if(!n.ok)throw Error(`Failed to fetch goal progress`);let r=await n.json();return!r.success||!r.data?null:{form_id:Number(r.data.form_id),count:Number(r.data.count),goal:Number(r.data.goal),progress:Number(r.data.progress)}}apply(e){if(!this.goalEl)return;let t=String(e.count),n=String(e.goal),r=String(e.progress);if(this.goalEl.dataset.count===t&&this.goalEl.dataset.goal===n&&this.goalEl.dataset.progress===r)return;this.goalEl.dataset.count=t,this.goalEl.dataset.goal=n,this.goalEl.dataset.progress=r;let i=this.goalEl.querySelector(`.petitioner__col:not(.petitioner__col--end) .petitioner__num`),a=this.goalEl.querySelector(`.petitioner__col--end .petitioner__num`),o=this.goalEl.querySelector(`.petitioner__progress-bar`),s=this.goalEl.querySelector(`.petitioner__numlabel small`);i&&(i.textContent=t),a&&(a.textContent=n),o&&o.style.setProperty(`width`,`${r}%`,`important`),s&&(s.textContent=`(${r}%)`)}onFormSubmit(e){let t=e.detail;!t?.success||t.wrapperEl!==this.wrapper||this.init()}};document.querySelectorAll(`.petitioner`).forEach(e=>{e instanceof HTMLElement&&(new o(e),new d(e))}),document.querySelectorAll(`.petitioner-submissions`).forEach(e=>{e instanceof HTMLElement&&new u(e)});var f=(window.petitionerFormSettings||{}).labels||{};window.location.search.includes(`petitioner=confirmed`)&&alert(f.emailConfirmedSuccess||`Thank you for confirming your email!`),window.location.search.includes(`petitioner=invalid`)&&alert(f.emailConfirmedError||`Something went wrong, could not confirm the email. Perhaps you have already confirmed it`);

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.