10 lines
4.7 KiB
JavaScript
Executable File

(function(d){function l(a){for(var c=5381,b=0;b<a.length;b++)c=(c<<5)+c+a.charCodeAt(b);return c}var k=[" * ; * * ; * * ; * * ; ***** ;* *;* *".split(";"),"****** ;* *;* *;****** ;* *;* *;****** ".split(";")," ***** ;* *;* ;* ;* ;* *; ***** ".split(";"),"****** ;* *;* *;* *;* *;* *;****** ".split(";"),"*******;* ;* ;**** ;* ;* ;*******".split(";"),"*******;* ;* ;**** ;* ;* ;* ".split(";"),
" ***** ;* *;* ;* ;* ***;* *; ***** ".split(";"),"* *;* *;* *;*******;* *;* *;* *".split(";"),"*******; * ; * ; * ; * ; * ;*******".split(";")," *; *; *; *; *;* *; ***** ".split(";"),"* *;* ** ;* ** ;** ;* ** ;* ** ;* *".split(";"),"* ;* ;* ;* ;* ;* ;*******".split(";"),"* *;** **;* * * *;* * *;* *;* *;* *".split(";"),"* *;** *;* * *;* * *;* * *;* **;* *".split(";"),
" ***** ;* *;* *;* *;* *;* *; ***** ".split(";"),"****** ;* *;* *;****** ;* ;* ;* ".split(";")," ***** ;* *;* *;* *;* * *;* * ; **** *".split(";"),"****** ;* *;* *;****** ;* * ;* * ;* *".split(";")," ***** ;* *;* ; ***** ; *;* *; ***** ".split(";"),"*******; * ; * ; * ; * ; * ; * ".split(";"),"* *;* *;* *;* *;* *;* *; ***** ".split(";"),"* *;* *; * * ; * * ; * * ; * * ; * ".split(";"),
"* *;* *;* *;* * *;* * * *;** **;* *".split(";"),"* *; * * ; * * ; * ; * * ; * * ;* *".split(";"),"* *; * * ; * * ; * ; * ; * ; * ".split(";"),"*******; * ; * ; * ; * ; * ;*******".split(";")," *** ; * * ;* * *;* * *;* * *; * * ; *** ".split(";")," * ; ** ; * * ; * ; * ; * ;*******".split(";")," ***** ;* *; *; * ; ** ; ** ;*******".split(";")," ***** ;* *; *; ** ; *;* *; ***** ".split(";"),
" * ; ** ; * * ; * * ;*******; * ; * ".split(";"),"*******;* ;****** ; *; *;* *; ***** ".split(";")," **** ; * ;* ;****** ;* *;* *; ***** ".split(";"),"*******; * ; * ; * ; * ; * ;* ".split(";")," ***** ;* *;* *; ***** ;* *;* *; ***** ".split(";")," ***** ;* *;* *; ******; *; * ; **** ".split(";")];d.JQPlugin.createPlugin({name:"realperson",alphabetic:"ABCDEFGHIJKLMNOPQRSTUVWXYZ",alphanumeric:"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
defaultDots:k,defaultOptions:{length:6,regenerate:"Click to change",hashName:"{n}Hash",dot:"*",dots:k,chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZ"},_challengeClass:"realperson-challenge",_disabledClass:"realperson-disabled",_hashClass:"realperson-hash",_regenerateClass:"realperson-regen",_textClass:"realperson-text",_optionsChanged:function(a,c,b){d.extend(c.options,b);var g="";for(b=0;b<c.options.length;b++)g+=c.options.chars.charAt(Math.floor(Math.random()*c.options.chars.length));var e=this;a.closest("form").off("."+
c.name).on("submit."+c.name,function(){var b=c.options.hashName.replace(/\{n\}/,a.attr("name")),h=d(this);h.find('input[name="'+b+'"]').remove();h.append('<input type="hidden" class="'+e._hashClass+'" name="'+b+'" value="'+l(g+f)+'">');setTimeout(function(){h.find('input[name="'+b+'"]').remove()},0)});a.prevAll("."+this._challengeClass+",."+this._hashClass).remove().end().before(this._generateHTML(c,g)).prevAll("div."+this._challengeClass).click(function(){d(this).hasClass(e._disabledClass)||d(this).nextAll("."+
e._getMarker()).realperson("option",{})})},enable:function(a){a=d(a);a.hasClass(this._getMarker())&&a.removeClass(this._disabledClass).prop("disabled",!1).prevAll("."+this._challengeClass).removeClass(this._disabledClass)},disable:function(a){a=d(a);a.hasClass(this._getMarker())&&a.addClass(this._disabledClass).prop("disabled",!0).prevAll("."+this._challengeClass).addClass(this._disabledClass)},_generateHTML:function(a,c){for(var b='<div class="'+this._challengeClass+'"><div class="'+this._textClass+
'">',d=0;d<a.options.dots[0].length;d++){for(var e=0;e<c.length;e++)b+=a.options.dots[a.options.chars.indexOf(c.charAt(e))][d].replace(/ /g,"&nbsp;").replace(/\*/g,a.options.dot)+"&nbsp;&nbsp;";b+="<br>"}return b+='</div><div class="'+this._regenerateClass+'">'+a.options.regenerate+"</div></div>"},_preDestroy:function(a,c){a.closest("form").off("."+c.name);a.prevAll("."+this._challengeClass+",."+this._hashClass).remove()}});var f=d.salt||"#salt";delete d.salt;d(function(){var a=d(f);a.length&&(f=
a.text(),a.remove());"#salt"===f&&(f="")})})(jQuery);