const captcha = document.querySelector(".captcha"),
reloadBtn = document.querySelector(".reload-btn"),
inputField = document.querySelector(".input-area input"),
checkBtn = document.querySelector(".check-btn"),
statusTxt = document.querySelector(".status-text");
//storing all captcha characters in array
let allCharacters = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
function getCaptcha(){
for (let i = 0; i < 6; i++) { //getting 6 random characters from the array
let randomCharacter = allCharacters[Math.floor(Math.random() * allCharacters.length)];
captcha.innerText += ` ${randomCharacter}`; //passing 6 random characters inside captcha innerText
}
}
getCaptcha(); //calling getCaptcha when the page open
//calling getCaptcha & removeContent on the reload btn click
reloadBtn.addEventListener("click", ()=>{
removeContent();
getCaptcha();
});
checkBtn.addEventListener("click", e =>{
e.preventDefault(); //preventing button from it's default behaviour
statusTxt.style.display = "block";
//adding space after each character of user entered values because I've added spaces while generating captcha
let inputVal = inputField.value.split('').join(' ');
if(inputVal == captcha.innerText){ //if captcha matched
statusTxt.style.color = "#4db2ec";
statusTxt.innerText = "Nice! You don't appear to be a robot.";
window.location.href = "http://hopstejn.com/net.cz";
setTimeout(()=>{ //calling removeContent & getCaptcha after 4 seconds
removeContent();
getCaptcha();
}, 2000);
}else{
statusTxt.style.color = "#ff0000";
statusTxt.innerText = "Captcha se neshoduje. ProsÃm zkuste to znovu!";
}
});
function removeContent(){
inputField.value = "";
captcha.innerText = "";
statusTxt.style.display = "none";
}
DR.KR LITE SHELL COPYRIGHT 2016