Created
November 12, 2015 21:24
-
-
Save justinobney/73908b0f36ad85568545 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function onSuccess(){ | |
| $('form').attr('action', 'foo'); | |
| } | |
| function makeEquation(successCallback){ | |
| var words = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten']; | |
| var left = Math.floor(Math.random() * 10 + 1); | |
| var right = Math.floor(Math.random() * 10 + 1); | |
| var question = words[left-1] + ' + ' + words[right-1] + ' = ? (example: one + two = 3)'; | |
| return { | |
| question: question, | |
| verify: function verify(answer){ | |
| var answer == left + right; | |
| if(successCallback){ | |
| (successCallback || function(){}).call() | |
| } | |
| } | |
| }; | |
| } | |
| var captcha = makeEquation(onSuccess); | |
| captcha.question; // "ten + six = ? (example: one + two = 3)" | |
| captcha.verify(16) // calls success callback | |
| captcha.verify(14) // does nothing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment