var site_key='6Lcl_swiAAAAABGaiD6D3JvK4ceeYR7B1v7QPTTG';
var verifyCallback=function(response){
if(response){
jQuery('#searchsubmit').click();
}else{
jQuery('#searchform').preventDefault();
}};
var widgetId1;
var onloadCallback=function(){
widgetId1=grecaptcha.render('g-recaptcha', {
'sitekey': site_key,
'theme': 'light',
'callback': verifyCallback,
});
};
var isCaptchaVerified=true;
window.addEventListener('load', async ()=> {
try {
const path_name=window.location.pathname;
const page_name=path_name.replace(/\//g, ""); // Removes all slashes
if(getCookie(page_name)){
isCaptchaVerified=false;
}} catch (error){
console.error("Error fetching captcha verification:", error);
}});
jQuery(document).ready(function(){
jQuery("#searchform").submit(async function(e){
if(isCaptchaVerified){
if(grecaptcha.getResponse(widgetId1)){
jQuery('.g-recaptcha-error').hide();
const path_name=window.location.pathname;
const page_name=path_name.replace(/\//g, ""); // Removes all slashes
setCookie(page_name, true, 1);
e.submit();
}else{
e.preventDefault();
jQuery('.g-recaptcha-error').show();
}}else{
e.submit();
}});
});
function setCookie(name, value, days){
let date=new Date();
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
document.cookie=`${name}=${value}; expires=${date.toUTCString()}; path=/`;
}
function getCookie(name){
let cookies=document.cookie.split("; ");
for (let cookie of cookies){
let [cookieName, cookieValue]=cookie.split("=");
if(cookieName===name) return true;
}
return false;
}
jQuery(document).ready(function(){
jQuery('#searchsubmit').click(function(e){
if(jQuery("#g-recaptcha #g-recaptcha-response").length){
var textlen=jQuery('#searchform #s').val().length;
if(textlen >=1&&isCaptchaVerified){
jQuery('#searchform #s').removeClass('error_not_fill');
jQuery('#g-recaptcha').show();
}else{
jQuery('#g-recaptcha').hide();
}}else{
e.preventDefault();
}});
jQuery('#searchform #s').keyup(function(event){
if(jQuery("#g-recaptcha #g-recaptcha-response").length){
var textlen=jQuery('#searchform #s').val().length;
if(textlen >=1){
jQuery('#searchform #s').removeClass('error_not_fill');
jQuery('#google_captcha_msg').show();
if(e.which==10||e.which==13){
var textlen=jQuery('#searchform #s').val().length;
if(textlen >=1&&isCaptchaVerified){
jQuery('#g-recaptcha').show();
}}
}else{
jQuery('#g-recaptcha').hide();
}}else{
event.preventDefault();
}});
});