Rename captcheck.dist.js to captcheck.min.js, update docs
This commit is contained in:
parent
bc7e250972
commit
9d889455cc
|
@ -0,0 +1,2 @@
|
|||
RewriteEngine On
|
||||
RewriteRule ^captcheck.dist.js captcheck.min.js [L]
|
|
@ -1 +0,0 @@
|
|||
window.onload=function(){var e="https://captcheck.netsyms.com/api.php";function t(e,t){return document.getElementById("captcheck_"+e+"_answer_"+t).checked=!0,!1}function a(e){var t=document.getElementById("captcheck_"+e+"_alt_question_button"),a=document.getElementById("captcheck_"+e+"_question_image"),n=document.getElementById("captcheck_"+e+"_question_access"),c=document.getElementById("captcheck_"+e+"_answer_images"),i=document.getElementById("captcheck_"+e+"_answer_access");"> Text mode"==t.innerHTML?(t.innerHTML="> Image mode",a.style.display="none",n.style.display="initial",c.style.display="none",i.style.display="initial",i.innerHTML="<input type='text' name='captcheck_selected_answer' aria-label='Type your answer here.' autocomplete='off' autofill='off'/>"):(t.innerHTML="> Text mode",a.style.display="initial",n.style.display="none",c.style.display="initial",i.style.display="none",i.innerHTML="")}var n="";Array.prototype.forEach.call(document.getElementsByClassName("captcheck_container"),function(c){c.dataset.stylenonce&&(n=c.dataset.stylenonce);var i=new XMLHttpRequest;i.open("GET",e+"?action=new",!0),i.onreadystatechange=function(){if(4==this.readyState){var n=this.status,i=this.responseText,s=document.createElement("div");if(s.setAttribute("class","captcheck_box"),c.appendChild(s),200==n){for(var r=JSON.parse(i),o=r.id_prefix,d="<div class='captcheck_answer_images' id='captcheck_"+o+"_answer_images'>",l=0,p=r.answers.length;l<p;l++){var _=e+"?action=img&s="+r.session+"&c="+r.answers[l];d+="<a class='captcheck_answer_label' href='' data-prefix='"+o+"' data-answer='"+r.answers[l]+"' tabindex='0' aria-role='button'><input id='captcheck_"+o+"_answer_"+r.answers[l]+"' type='radio' name='captcheck_selected_answer' value='"+r.answers[l]+"' data-prefix='"+o+"' data-answer='"+r.answers[l]+"' /><img src='"+_+"' data-prefix='"+o+"' data-answer='"+r.answers[l]+"'/></a>"}d+="</div>";var u=document.createElement("div");u.innerHTML=d+"<div class='captcheck_answer_access' id='captcheck_"+o+"_answer_access'></div>";var h=document.createElement("div");h.setAttribute("class","captcheck_label_message"),h.setAttribute("id","captcheck_"+o+"_label_message"),h.innerHTML="<span class='captcheck_question_image' id='captcheck_"+o+"_question_image'>"+r.question_i+"</span><span class='captcheck_question_access' id='captcheck_"+o+"_question_access'>"+r.question_a+"</span><a href='' class='captcheck_alt_question_button' data-prefix='"+o+"' id='captcheck_"+o+"_alt_question_button' aria-role='button' aria-label='Switch between image and text question' tabindex='0'>> Text mode</a>",s.appendChild(h),s.appendChild(u);var m=document.createElement("span");m.innerHTML="<input type='hidden' name='captcheck_session_code' value='"+r.session+"' />",s.appendChild(m);var k=document.querySelectorAll('.captcheck_answer_label[data-prefix="'+o+'"]');for(l=0;l<k.length;l++)k[l].addEventListener("click",function(e){t(e.target.getAttribute("data-prefix"),e.target.getAttribute("data-answer")),e.preventDefault()}),k[l].addEventListener("keydown",function(e){"Enter"!==e.key&&13!==e.which&&13!==e.keyCode&&" "!==e.key&&32!==e.which&&32!==e.keyCode||(t(e.target.getAttribute("data-prefix"),e.target.getAttribute("data-answer")),e.preventDefault())});document.querySelector('.captcheck_alt_question_button[data-prefix="'+o+'"]').addEventListener("click",function(e){a(e.target.getAttribute("data-prefix")),e.preventDefault()}),document.querySelector('.captcheck_alt_question_button[data-prefix="'+o+'"]').addEventListener("keydown",function(e){"Enter"!==e.key&&13!==e.which&&13!==e.keyCode&&" "!==e.key&&32!==e.which&&32!==e.keyCode||(a(e.target.getAttribute("data-prefix")),e.preventDefault())})}else s.innerHTML="<span class='captcheck_error_message'>There was a problem loading the CAPTCHA.</span>"}},i.send()});var c=document.createElement("style");""!=n&&c.setAttribute("nonce",n),c.innerHTML=".captcheck_box{font-family:Ubuntu,Arial,sans-serif;color:black;border:1px solid #e0e0e0;border-radius:3px;display:inline-block;padding:3px;margin:5px 2px 5px 1px;background-color:#f5f5f5;text-decoration:none}.captcheck_label_message,.captcheck_label_message b{color:black;font-family:Ubuntu,Roboto,Arial,sans-serif}.captcheck_answer_label{border:0}.captcheck_answer_label>input{visibility:hidden;position:absolute}.captcheck_answer_label>input+img{cursor:pointer;border:2px solid transparent;border-radius:3px;min-width:32px;width:18%;max-width:64px}.captcheck_answer_label>input:checked+img{cursor:pointer;border:2px solid #424242;border-radius:3px}.captcheck_error_message{color:red}.captcheck_question_image{display:initial}.captcheck_question_access{display:none}.captcheck_alt_question_button{float:right;font-size:80%;cursor:pointer;color:inherit;text-decoration:inherit;border:0}.captcheck_answer_images{display:initial}.captcheck_answer_access{display:none}",document.body.appendChild(c)};
|
|
@ -0,0 +1,10 @@
|
|||
/* 2018 Netsyms Technologies. See repository license. */
|
||||
window.onload=function(){function m(c,g){document.getElementById("captcheck_"+c+"_answer_"+g).checked=!0;return!1}function n(c){var g=document.getElementById("captcheck_"+c+"_alt_question_button"),b=document.getElementById("captcheck_"+c+"_question_image"),d=document.getElementById("captcheck_"+c+"_question_access"),f=document.getElementById("captcheck_"+c+"_answer_images");c=document.getElementById("captcheck_"+c+"_answer_access");"> Text mode"==g.innerHTML?(g.innerHTML="> Image mode",b.style.display=
|
||||
"none",d.style.display="initial",f.style.display="none",c.style.display="initial",c.innerHTML="<input type='text' name='captcheck_selected_answer' aria-label='Type your answer here.' autocomplete='off' autofill='off'/>"):(g.innerHTML="> Text mode",b.style.display="initial",d.style.display="none",f.style.display="initial",c.style.display="none",c.innerHTML="")}var k="";Array.prototype.forEach.call(document.getElementsByClassName("captcheck_container"),function(c){c.dataset.stylenonce&&(k=c.dataset.stylenonce);
|
||||
var g=new XMLHttpRequest;g.open("GET","https://captcheck.netsyms.com/api.php?action=new",!0);g.onreadystatechange=function(){if(4==this.readyState){var b=this.status,d=this.responseText;if(""==c.innerHTML.trim()){var f=document.createElement("div");f.setAttribute("class","captcheck_box");c.appendChild(f);if(200==b){d=JSON.parse(d);b=d.id_prefix;for(var h="<div class='captcheck_answer_images' id='captcheck_"+b+"_answer_images'>",e=0,g=d.answers.length;e<g;e++)h+="<a class='captcheck_answer_label' href='' data-prefix='"+
|
||||
b+"' data-answer='"+d.answers[e]+"' tabindex='0' aria-role='button'><input id='captcheck_"+b+"_answer_"+d.answers[e]+"' type='radio' name='captcheck_selected_answer' value='"+d.answers[e]+"' data-prefix='"+b+"' data-answer='"+d.answers[e]+"' /><img src='"+("https://captcheck.netsyms.com/api.php?action=img&s="+d.session+"&c="+d.answers[e])+"' data-prefix='"+b+"' data-answer='"+d.answers[e]+"'/></a>";h+="</div>";e=document.createElement("div");e.innerHTML=h+"<div class='captcheck_answer_access' id='captcheck_"+
|
||||
b+"_answer_access'></div>";h=document.createElement("div");h.setAttribute("class","captcheck_label_message");h.setAttribute("id","captcheck_"+b+"_label_message");h.innerHTML="<span class='captcheck_question_image' id='captcheck_"+b+"_question_image'>"+d.question_i+"</span><span class='captcheck_question_access' id='captcheck_"+b+"_question_access'>"+d.question_a+"</span><a href='' class='captcheck_alt_question_button' data-prefix='"+b+"' id='captcheck_"+b+"_alt_question_button' aria-role='button' aria-label='Switch between image and text question' tabindex='0'>> Text mode</a>";
|
||||
f.appendChild(h);f.appendChild(e);h=document.createElement("span");h.innerHTML="<input type='hidden' name='captcheck_session_code' value='"+d.session+"' />";f.appendChild(h);f=document.querySelectorAll('.captcheck_answer_label[data-prefix="'+b+'"]');for(e=0;e<f.length;e++)f[e].addEventListener("click",function(a){m(a.target.getAttribute("data-prefix"),a.target.getAttribute("data-answer"));a.preventDefault()}),f[e].addEventListener("keydown",function(a){if("Enter"===a.key||13===a.which||13===a.keyCode||
|
||||
" "===a.key||32===a.which||32===a.keyCode)m(a.target.getAttribute("data-prefix"),a.target.getAttribute("data-answer")),a.preventDefault()});document.querySelector('.captcheck_alt_question_button[data-prefix="'+b+'"]').addEventListener("click",function(a){n(a.target.getAttribute("data-prefix"));a.preventDefault()});document.querySelector('.captcheck_alt_question_button[data-prefix="'+b+'"]').addEventListener("keydown",function(a){if("Enter"===a.key||13===a.which||13===a.keyCode||" "===a.key||32===
|
||||
a.which||32===a.keyCode)n(a.target.getAttribute("data-prefix")),a.preventDefault()})}else f.innerHTML="<span class='captcheck_error_message'>There was a problem loading the CAPTCHA.</span>"}}};g.send()});var l=document.createElement("style");""!=k&&l.setAttribute("nonce",k);l.innerHTML=".captcheck_box{font-family:Ubuntu,Arial,sans-serif;color:black;border:1px solid #e0e0e0;border-radius:3px;display:inline-block;padding:3px;margin:5px 2px 5px 1px;background-color:#f5f5f5;text-decoration:none}.captcheck_label_message,.captcheck_label_message b{color:black;font-family:Ubuntu,Roboto,Arial,sans-serif}.captcheck_answer_label{border:0}.captcheck_answer_label>input{visibility:hidden;position:absolute}.captcheck_answer_label>input+img{cursor:pointer;border:2px solid transparent;border-radius:3px;min-width:32px;width:18%;max-width:64px}.captcheck_answer_label>input:checked+img{cursor:pointer;border:2px solid #424242;border-radius:3px}.captcheck_error_message{color:red}.captcheck_question_image{display:initial}.captcheck_question_access{display:none}.captcheck_alt_question_button{float:right;font-size:80%;cursor:pointer;color:inherit;text-decoration:inherit;border:0}.captcheck_answer_images{display:initial}.captcheck_answer_access{display:none}";
|
||||
document.body.appendChild(l)};
|
|
@ -100,7 +100,7 @@
|
|||
</div>
|
||||
<div class="card-body">
|
||||
<b>Put this in your page somewhere:</b>
|
||||
<pre><code class="language-html"><script src="https://captcheck.netsyms.com/captcheck.dist.js"></script></code></pre>
|
||||
<pre><code class="language-html"><script src="https://captcheck.netsyms.com/captcheck.min.js"></script></code></pre>
|
||||
<b>Put this in your form where you want the CAPTCHA:</b>
|
||||
<pre><code class="language-html"><div class="captcheck_container"></div></code></pre>
|
||||
<b>Put this in your server-side form validation (PHP example):</b>
|
||||
|
|
|
@ -11,7 +11,7 @@ How to use
|
|||
----------
|
||||
|
||||
In your form, put an empty div with the class "captcheck_container".
|
||||
Add `captcheck.js` (or `captcheck.dist.js`) into your page.
|
||||
Add `captcheck.js` (or `captcheck.min.js`) into your page.
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
|
27
test.html
27
test.html
|
@ -1,17 +1,12 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Captcheck Sample Form</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<script src="captcheck.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<form action="test.php" method="POST">
|
||||
<input type="text" name="form_field" placeholder="Some random form field" />
|
||||
<div class="captcheck_container">
|
||||
</div>
|
||||
<button type="submit">Submit Form</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
<meta charset="UTF-8">
|
||||
<title>Captcheck Sample Form</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<script src="captcheck.js"></script>
|
||||
|
||||
<form action="test.php" method="POST">
|
||||
<input type="text" name="form_field" placeholder="Some random form field" />
|
||||
<div class="captcheck_container">
|
||||
</div>
|
||||
<button type="submit">Submit Form</button>
|
||||
</form>
|
Loading…
Reference in New Issue