PageSourceSearch

https://www.bonusfinder.com/wp-content/cache/min/1/wp-content/them…/js/profile_page.js?ver=1790070200

js bonusfinder.com collected 2026-09-25 18:46:32 UTC 16,455 bytes, 66 lines download raw bytes

1(function(){'use strict';const FIELD_MAP={password:['passw1','passw2'],};function fieldListItem(form,name){const input=form.querySelector('[name="'+name+'"]');return input?input.closest('li'):null}
2function buildPanel(key,title,variant){const isSub=variant==='subpanel';const panel=document.createElement('section');panel.className=isSub?'profile-subpanel':'profile-panel';panel.id=(isSub?'profile-subpanel-':'profile-panel-')+key;panel.setAttribute('role','tabpanel');panel.setAttribute('aria-labelledby',(isSub?'profile-subtab-':'profile-tab-')+key);panel.setAttribute(isSub?'data-profile-subtab':'data-profile-tab',key);const heading=document.createElement('h2');heading.className='profile-panel__title';heading.textContent=title;panel.appendChild(heading);const list=document.createElement('ul');list.className='profile-panel__list';panel.appendChild(list);const foot=document.createElement('div');foot.className='profile-panel__foot';panel.appendChild(foot);return panel}
3function tabLabel(id){const el=document.getElementById(id);return el?el.textContent.trim():''}
4function graftFromTemplate(templateId,panel){const template=document.getElementById(templateId);if(!template||!panel){return null}
5const fragment=template.content.cloneNode(!0);const node=fragment.firstElementChild;panel.appendChild(fragment);return node}
6function wirePreferenceToggle(config){const{toggle,indicator,ajaxUrl,action,nonce,valueField}=config;if(!toggle||!ajaxUrl||!action||!nonce){return}
7let hideTimer;let fadeTimer;function setIndicator(state){if(!indicator){return}
8clearTimeout(hideTimer);clearTimeout(fadeTimer);indicator.classList.remove('is-loading','is-done','is-error','is-fading');if(state){indicator.classList.add(state)}}
9function autoHide(){hideTimer=setTimeout(function(){if(indicator){indicator.classList.add('is-fading')}
10fadeTimer=setTimeout(function(){setIndicator(null)},400)},3000)}
11toggle.addEventListener('click',function(event){const desired=toggle.checked;event.preventDefault();toggle.disabled=!0;const field=toggle.closest('.profile-marketing__field');if(field){field.style.pointerEvents='none'}
12setIndicator('is-loading');const body=new URLSearchParams();body.append('action',action);body.append('nonce',nonce);body.append(valueField,desired?'1':'0');fetch(ajaxUrl,{method:'POST',credentials:'same-origin',headers:{'Content-Type':'application/x-www-form-urlencoded',},body:body.toString(),}).then(function(response){if(!response.ok){throw new Error('Request failed')}
13return response.json()}).then(function(result){if(!result||!result.success){throw new Error('Save failed')}
14toggle.checked=desired;setIndicator('is-done');autoHide()}).catch(function(err){console.error(err);setIndicator('is-error');autoHide()}).finally(function(){toggle.disabled=!1;if(field){field.style.pointerEvents=''}})})}
15function graftMarketing(profile,marketingPanel){const node=graftFromTemplate('profile-marketing-template',marketingPanel);if(!node){return}
16const ajaxUrl=profile.getAttribute('data-ajax-url');const marketingToggle=node.querySelector('[data-marketing-toggle]');if(marketingToggle){marketingToggle.checked=profile.getAttribute('data-marketing-consent')==='1';wirePreferenceToggle({toggle:marketingToggle,indicator:node.querySelector('[data-marketing-indicator]'),ajaxUrl,action:'bf_profile_toggle_marketing',nonce:profile.getAttribute('data-marketing-nonce'),valueField:'consent',})}
17const newsletterToggle=node.querySelector('[data-newsletter-toggle]');if(newsletterToggle){newsletterToggle.checked=profile.getAttribute('data-newsletter-subscribed')==='1';wirePreferenceToggle({toggle:newsletterToggle,indicator:node.querySelector('[data-newsletter-indicator]'),ajaxUrl,action:'bf_profile_toggle_newsletter',nonce:profile.getAttribute('data-newsletter-nonce'),valueField:'subscribed',})}}
18function graftDelete(profile,adminPanel){const node=graftFromTemplate('profile-delete-template',adminPanel);if(!node){return}
19const button=node.querySelector('[data-delete-account]');const modal=node.querySelector('[data-delete-modal]');const deleteUrl=profile.getAttribute('data-delete-url');if(!button||!modal||!deleteUrl){return}
20const cancelBtn=modal.querySelector('[data-delete-modal-cancel]');const confirmBtn=modal.querySelector('[data-delete-modal-confirm]');button.addEventListener('click',function(){if(typeof modal.showModal==='function'){modal.showModal()}else{window.location.href=deleteUrl}});if(cancelBtn){cancelBtn.addEventListener('click',function(){modal.close()})}
21modal.addEventListener('click',function(event){if(event.target===modal){modal.close()}});if(confirmBtn){confirmBtn.addEventListener('click',function(){confirmBtn.disabled=!0;window.location.href=deleteUrl})}}
22function graftGdpr(adminPanel){graftFromTemplate('profile-gdpr-template',adminPanel)}
23function relocateFields(profile,form,subpanels){const passwordList=subpanels.password.querySelector('.profile-panel__list');FIELD_MAP.password.forEach(function(name){const item=fieldListItem(form,name);if(item){passwordList.appendChild(item)}});
23graftMarketing(profile,subpanels.marketing);graftDelete(profile,subpanels.admin);graftGdpr(subpanels.admin)}
24function hideLeftoverFields(form){form.querySelectorAll(':scope > ul').forEach(function(ul){ul.hidden=!0})}
25function setupNav(submitWrap){const topButtons=Array.prototype.slice.call(document.querySelectorAll('.profile-tabs__item'));const subButtons=Array.prototype.slice.call(document.querySelectorAll('.profile-subtabs__item'));const host=document.getElementById('bf-profile-form');let currentTop='rewards';let currentSub='marketing';function updateSubmit(){if(!submitWrap){return}
26const show=currentTop==='settings'&&currentSub==='password';if(show){const foot=document.querySelector('#profile-subpanel-password .profile-panel__foot');if(foot){foot.appendChild(submitWrap)}
27submitWrap.hidden=!1}else{submitWrap.hidden=!0}}
28function activateTop(tab){currentTop=tab;topButtons.forEach(function(btn){const isActive=btn.getAttribute('data-profile-tab')===tab;btn.classList.toggle('active',isActive);btn.setAttribute('aria-selected',isActive?'true':'false')});document.querySelectorAll('.profile-panel').forEach(function(panel){panel.classList.toggle('active',panel.getAttribute('data-profile-tab')===tab)});if(host){host.style.display=tab==='settings'?'block':'none'}
29updateSubmit()}
30function activateSub(sub){currentSub=sub;subButtons.forEach(function(btn){const isActive=btn.getAttribute('data-profile-subtab')===sub;btn.classList.toggle('active',isActive);btn.setAttribute('aria-selected',isActive?'true':'false')});document.querySelectorAll('.profile-subpanel').forEach(function(panel){panel.classList.toggle('active',panel.getAttribute('data-profile-subtab')===sub)});updateSubmit()}
31topButtons.forEach(function(btn){btn.addEventListener('click',function(){activateTop(btn.getAttribute('data-profile-tab'))})});subButtons.forEach(function(btn){btn.addEventListener('click',function(){activateSub(btn.getAttribute('data-profile-subtab'))})});let savedTop='';let savedSub='';try{savedTop=sessionStorage.getItem('bfProfileTab')||'';savedSub=sessionStorage.getItem('bfProfileSubtab')||'';sessionStorage.removeItem('bfProfileTab');sessionStorage.removeItem('bfProfileSubtab')}catch(e){savedTop='';savedSub=''}
32const initialSub=document.querySelector('.profile-subtabs__item.active');activateSub(savedSub||(initialSub?initialSub.getAttribute('data-profile-subtab'):'marketing'));const initialTop=document.querySelector('.profile-tabs__item.active');activateTop(savedTop||(initialTop?initialTop.getAttribute('data-profile-tab'):'rewards'))}
33function rememberActiveTab(form){if(!form){return}
34form.addEventListener('submit',function(){const top=document.querySelector('.profile-tabs__item.active');const sub=document.querySelector('.profile-subtabs__item.active');try{sessionStorage.setItem('bfProfileSubmitted','1');sessionStorage.setItem('bfProfileTab',top?top.getAttribute('data-profile-tab'):'');sessionStorage.setItem('bfProfileSubtab',sub?sub.getAttribute('data-profile-subtab'):'')}catch(e){}})}
35function surfaceProfileNotice(){const host=document.getElementById('bf-profile-form');if(!host){return}
36const messages=host.querySelectorAll('#wppb_form_general_message, #registration-error');if(!messages.length){return}
37let messageEl=null;messages.forEach(function(m){if(!messageEl&&''!==m.textContent.trim()){messageEl=m}
38m.setAttribute('hidden','hidden');m.style.setProperty('display','none','important')});if(!messageEl){return}
39let justSubmitted=!1;try{justSubmitted=sessionStorage.getItem('bfProfileSubmitted')==='1';sessionStorage.removeItem('bfProfileSubmitted')}catch(e){justSubmitted=!1}
40if(!justSubmitted){return}
41if(document.getElementById('bfpbvc-toast-container')){return}
42const isError=messageEl.classList.contains('wppb-error');const messageText=isError?messageEl.textContent.trim()||'Something went wrong. Please try again.':'Successfully updated the profile';const iconType=isError?'warning':'info';const iconFill=isError?'#D2191C':'#5B2ABF';const iconSvg='<svg width="20.126" height="20.126" viewBox="0 0 21 21" fill="none" xmlns="http://www.w3.org/2000/svg"><circle cx="10.5" cy="10.5" r="10.5" fill="'+iconFill+'"/><circle cx="10.5" cy="6" r="1.5" fill="white"/><rect x="9" y="8.5" width="3" height="7.5" rx="1.5" fill="white"/></svg>';const container=document.createElement('div');container.id='bf-profile-toast';container.className='bfpbvc-toast-container';container.setAttribute('role','alert');container.setAttribute('aria-live','polite');container.setAttribute('aria-atomic','true');const toast=document.createElement('div');toast.className='bfpbvc-toast bfpbvc-toast-'+iconType;const icon=document.createElement('span');icon.className='bfpbvc-toast-icon bfpbvc-toast-icon-'+iconType;icon.setAttribute('aria-hidden','true');icon.innerHTML=iconSvg;toast.appendChild(icon);const text=document.createElement('span');text.className='bfpbvc-toast-message';text.textContent=messageText;toast.appendChild(text);container.appendChild(toast);document.body.appendChild(container);let hideTimer=null;function dismiss(){if(hideTimer){clearTimeout(hideTimer);hideTimer=null}
43toast.classList.add('bfpbvc-toast-dismissing');setTimeout(function(){if(container.parentNode){container.parentNode.removeChild(container)}},300)}
44toast.addEventListener('click',dismiss);hideTimer=setTimeout(dismiss,4000)}
45function renderExport(output,data){output.innerHTML='';function addSection(title,rows){const wrap=document.createElement('div');wrap.className='profile-gdpr__section';const h=document.createElement('h4');h.textContent=title;wrap.appendChild(h);const dl=document.createElement('dl');rows.forEach(function(row){const dt=document.createElement('dt');dt.textContent=row[0];const dd=document.createElement('dd');dd.textContent=row[1];dl.appendChild(dt);dl.appendChild(dd)});wrap.appendChild(dl);output.appendChild(wrap)}
46const p=data.profile||{};addSection('Profile details',[['Username',p.username||''],['Email',p.email||''],['Full name',p.full_name||''],['First name',p.first_name||''],['Last name',p.last_name||''],['Display name',p.display_name||''],['Phone',p.phone||''],['Registered',p.registered||''],]);const mp=data.marketing_preferences||{};addSection('Marketing preferences',[['Send me offers and updates',mp.marketing_consent?'Yes':'No'],['Subscribe to our newsletter',mp.newsletter_subscribed?'Yes':'No',],]);const listSection=function(title,items,format,linkFor){const wrap=document.createElement('div');wrap.className='profile-gdpr__section';const h=document.createElement('h4');h.textContent=title+' ('+items.length+')';wrap.appendChild(h);const ul=document.createElement('ul');
46items.forEach(function(item){const li=document.createElement('li');li.textContent=format(item);const url=linkFor?linkFor(item):'';if(url){li.appendChild(document.createTextNode(' '));const link=document.createElement('a');link.href=url;link.textContent='View';link.target='_blank';link.rel='noopener noreferrer';link.className='profile-gdpr__link';li.appendChild(link)}
47ul.appendChild(li)});wrap.appendChild(ul);output.appendChild(wrap)};listSection('Comments',data.comments||[],function(c){return c.date+' — '+(c.post||'')+': '+c.content},function(c){return c.url||''});listSection('Reviews',data.reviews||[],function(r){const stars=r.rating?' ('+r.rating+'★)':'';return r.date+' — '+(r.title||r.content||'')+stars},function(r){return r.url||''});output.hidden=!1}
48function setupDetailsSave(profile,wppbForm){const form=document.querySelector('[data-profile-details-form]');const ajaxUrl=profile.getAttribute('data-ajax-url');const nonce=profile.getAttribute('data-name-nonce');if(!form||!ajaxUrl||!nonce){return}
49const button=form.querySelector('[data-profile-details-save]');const status=form.querySelector('[data-profile-details-status]');let hideTimer;function showStatus(isError){if(!status||!button){return}
50status.textContent=isError?button.getAttribute('data-error-text')||'':button.getAttribute('data-saved-text')||'';status.classList.toggle('is-error',isError);status.hidden=!1;window.clearTimeout(hideTimer);hideTimer=window.setTimeout(function(){status.hidden=!0},3000)}
51form.addEventListener('submit',function(event){event.preventDefault();if(button&&button.disabled){return}
52if(button){button.disabled=!0;button.style.pointerEvents='none'}
53const phone=form.querySelector('#bf_phone');const body=new URLSearchParams();body.append('action','bf_profile_save_name');body.append('nonce',nonce);const first=form.querySelector('#bf_first_name');const last=form.querySelector('#bf_last_name');if(first){body.append('first_name',first.value)}
54if(last){body.append('last_name',last.value)}
55if(phone){body.append('phone_number',phone.value)}
56fetch(ajaxUrl,{method:'POST',credentials:'same-origin',headers:{'Content-Type':'application/x-www-form-urlencoded',},body:body.toString(),}).then(function(response){if(!response.ok){throw new Error('Request failed')}
57if(phone&&wppbForm){const wppbPhone=wppbForm.querySelector('[name="phone_number"]');if(wppbPhone){wppbPhone.value=phone.value}}
58showStatus(!1)}).catch(function(err){console.error(err);showStatus(!0)}).finally(function(){if(button){button.disabled=!1;button.style.pointerEvents=''}})})}
59function setupGdpr(){const profile=document.querySelector('.profile');const button=document.querySelector('[data-gdpr-print]');const output=document.querySelector('[data-gdpr-output]');if(!profile||!button||!output){return}
60const restUrl=profile.getAttribute('data-rest-export');const restNonce=profile.getAttribute('data-rest-nonce');const defaultText=button.textContent;button.addEventListener('click',function(){button.disabled=!0;button.textContent=button.getAttribute('data-loading-text')||defaultText;fetch(restUrl,{headers:{'X-WP-Nonce':restNonce},credentials:'same-origin',}).then(function(response){if(!response.ok){throw new Error('Request failed')}
61return response.json()}).then(function(data){renderExport(output,data)}).catch(function(err){console.error(err);output.hidden=!1;output.textContent=button.getAttribute('data-error-text')||'Error'}).finally(function(){button.disabled=!1;button.textContent=defaultText})})}
62function init(){const profile=document.querySelector('.profile');const host=document.getElementById('bf-profile-form');const settingsPanel=document.getElementById('profile-panel-settings');if(!profile||!host||!settingsPanel){return}
63const form=host.querySelector('form.wppb-edit-user')||Array.prototype.find.call(host.querySelectorAll('form'),function(f){return f.querySelector('[name="edit_profile"]')})||host.querySelector('form');if(!form){return}
64const subpanels={marketing:buildPanel('marketing',tabLabel('profile-subtab-marketing'),'subpanel'),password:buildPanel('password',tabLabel('profile-subtab-password'),'subpanel'),admin:buildPanel('admin',tabLabel('profile-subtab-admin'),'subpanel'),};const submitWrap=form.querySelector('.form-submit');if(submitWrap){form.insertBefore(settingsPanel,submitWrap)}else{form.appendChild(settingsPanel)}
65const subContainer=settingsPanel.querySelector('.profile-subpanels');['marketing','password','admin'].forEach(function(sub){subContainer.appendChild(subpanels[sub])});subpanels.marketing.classList.add('active');relocateFields(profile,form,subpanels);hideLeftoverFields(form);setupNav(submitWrap);setupDetailsSave(profile,form);rememberActiveTab(form);surfaceProfileNotice();setupGdpr()}
66if(document.readyState==='loading'){document.addEventListener('DOMContentLoaded',init)}else{init()}})()

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.