PageSourceSearch

https://www.bonusfinder.it/wp-content/cache/min/1/wp-content/themes/bonusfinder/js/comments.js?ver=1790767814

js bonusfinder.it collected 2026-09-30 15:21:04 UTC 8,127 bytes, 22 lines download raw bytes

1document.addEventListener('DOMContentLoaded',function(){const loadMoreBtn=document.getElementById('load-more-comments');const hideCommentsBtn=document.getElementById('hide-comments');attachCommentFormListener();attachCommentFieldListeners();if(loadMoreBtn){loadMoreBtn.addEventListener('click',function(){loadMoreComments()})}
2if(hideCommentsBtn){hideCommentsBtn.addEventListener('click',function(){resetToFirstPage()})}});function attachCommentFormListener(){const commentForm=document.getElementById('comment-form');const botCheck=document.createElement('input');botCheck.type='checkbox';botCheck.name='confirmation_checkbox';botCheck.style.position='absolute';botCheck.style.left='-9999px';botCheck.tabIndex=-1;if(commentForm){commentForm.appendChild(botCheck);commentForm.removeEventListener('submit',handleCommentSubmit);commentForm.addEventListener('submit',handleCommentSubmit)}}
3function handleCommentSubmit(event){event.preventDefault();const author=event.target.querySelector('#author')?.value.trim();const email=event.target.querySelector('#email')?.value.trim();const commentField=document.getElementById('comment-field');const commentValue=commentField.value.trim();const hiddenInput=event.target.querySelector('input[name="comment_input"]');const botCheck=event.target.querySelector('input[name="confirmation_checkbox"]');if(!author||!email){alert('Name and email are required.');return}
4if(!/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(email)){alert('Please enter a valid email address.');return}
5if(hiddenInput?.value||botCheck.checked){console.warn('Bot detected: submission blocked.');return}
6if(commentValue.length<5){alert('Comment must be at least 5 characters long.');return}
7const linkRegex=/(https?:\/\/|www\.|<a\s)/i;if(linkRegex.test(commentValue)){alert('Links are not allowed in comments.');return}
8const formData=new FormData(event.target);formData.append('action','submit_comment');const parentField=document.getElementById('comment_parent');formData.append('comment_parent',parentField?parentField.value:0);fetch(ajaxurl,{method:'POST',body:formData}).then(response=>response.json()).then(data=>{if(data.success){if(typeof ktag!=='undefined'&&typeof ktag.pushHashedData==='function'){ktag.pushHashedData({email:email},'comment submission')}
9document.getElementById('comment-field').value='';document.getElementById('author').value='';document.getElementById('email').value='';const savedParent=document.getElementById('comment_parent')?.value||0;refreshCommentSection(savedParent,()=>{const messageEl=document.querySelector('.comments-successful-submission-message');if(messageEl){messageEl.style.display='block';const formSection=document.getElementById('comment-form-section');if(formSection){requestAnimationFrame(()=>{const observer=new IntersectionObserver((entries,observerInstance)=>{entries.forEach(entry=>{if(!entry.isIntersecting){messageEl.style.display='none';observerInstance.disconnect()}})},{threshold:0.25});observer.observe(formSection)})}}})}else{console.error('Comment submission failed:',data.message)}}).catch(error=>console.error('Error submitting comment:',error))}
10function refreshCommentSection(savedParent=null,callback=null){const savedParentId=savedParent||document.getElementById('comment_parent')?.value||0;const savedComment=document.getElementById('comment-field')?.value||'';fetch(window.location.href,{method:'GET'}).then(response=>response.text()).then(html=>{const parser=new DOMParser();const doc=parser.parseFromString(html,'text/html');const newCommentSection=doc.getElementById('comment-form');if(newCommentSection){document.querySelector('#comment-form').innerHTML=newCommentSection.innerHTML;const commentField=document.getElementById('comment-field');const commentParent=document.getElementById('comment_parent');if(commentField){commentField.value=savedComment}
11if(commentParent){commentParent.value=savedParentId}
12attachCommentFormListener();attachCommentFieldListeners();handleCommentInput();if(typeof callback==='function'){callback()}}}).catch(error=>console.error('Error refreshing comment section:',error))}
13function attachCommentFieldListeners(){const commentField=document.getElementById('comment-field');const cancelComment=document.querySelector('.comment-cancel');const submitComment=document.querySelector('.comment-submit');if(commentField&&cancelComment&&submitComment){commentField.removeEventListener('input',handleCommentInput);cancelComment.removeEventListener('click',handleCancelClick);commentField.addEventListener('input',handleCommentInput);cancelComment.addEventListener('click',handleCancelClick)}}
14function handleCommentInput(){const commentField=document.getElementById('comment-field');const cancelComment=document.querySelector('.comment-cancel');const submitComment=document.querySelector('.comment-submit');if(!commentField||!cancelComment||!submitComment){return}
15cancelComment.disabled=commentField.value.trim().length===0;submitComment.disabled=commentField.value.trim().length<=4;cancelComment.classList.toggle('active',commentField.value.trim().length>0);submitComment.classList.toggle('active',commentField.value.trim().length>4)}
16function handleCancelClick(){const commentField=document.getElementById('comment-field');const cancelComment=document.querySelector('.comment-cancel');const submitComment=document.querySelector('.comment-submit');if(commentField&&cancelComment&&submitComment){commentField.value='';cancelComment.classList.remove('active');submitComment.classList.remove('active');cancelComment.disabled=!0;submitComment.disabled=!0}}
17function scrollToCommentForm(event,replyButton){event.preventDefault();let clickedCommentId=replyButton.getAttribute('data-commentid');let topLevel=replyButton.closest('li.comment');if(topLevel&&topLevel.classList.contains('reply')){topLevel=topLevel.closest('li.comment:not(.reply)');if(topLevel){clickedCommentId=topLevel.getAttribute('id').replace('comment-','')}}
18const parentField=document.getElementById('comment_parent');if(parentField){parentField.value=clickedCommentId}
19const commentForm=document.getElementById('comment-form');if(commentForm){commentForm.scrollIntoView({behavior:'smooth',block:'center'})}}
20function loadMoreComments(){const loadMoreBtn=document.getElementById('load-more-comments');const commentList=document.getElementById('comment-list');if(!loadMoreBtn||!commentList){return}
21let currentPage=parseInt(loadMoreBtn.getAttribute('data-page'))||1;let nextPage=currentPage+1;const postIdInput=document.getElementById('comment-form')?.querySelector('[name="comment_post_ID"]');if(!postIdInput)return;const postId=postIdInput.value;const formData=new FormData();formData.append('action','load_more_comments');formData.append('cpage',nextPage);formData.append('post_id',postId);fetch(ajaxurl,{method:'POST',body:formData}).then(response=>response.json()).then(data=>{if(data.success&&data.data.trim()){commentList.insertAdjacentHTML('beforeend',data.data);loadMoreBtn.setAttribute('data-page',nextPage);const totalPages=parseInt(loadMoreBtn.getAttribute('data-total-pages'));if(nextPage>=totalPages){document.querySelector('.load-more-comments').style.display='none';document.querySelector('.hide-comments').style.display='block'}else{loadMoreBtn.setAttribute('data-page',nextPage)}}}).catch(error=>console.error('Error loading more comments',error))}
22function resetToFirstPage(){const commentList=document.getElementById('comment-list');const postIdInput=document.querySelector('#comment-form [name="comment_post_ID"]');if(!commentList||!postIdInput)return;const postId=postIdInput.value;const formData=new FormData();formData.append('action','load_more_comments');formData.append('cpage',1);formData.append('post_id',postId);fetch(ajaxurl,{method:'POST',body:formData}).then(response=>response.json()).then(data=>{if(data.success&&data.data.trim()){commentList.innerHTML=data.data;document.getElementById('load-more-comments').setAttribute('data-page',1);document.querySelector('.hide-comments').style.display='none';document.querySelector('.load-more-comments').style.display='block'}}).catch(error=>console.error('Error resetting comments:',error))}

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.