app/assets/javascripts/anti-spam.js.erb in anti_spam-0.0.1 vs app/assets/javascripts/anti-spam.js.erb in anti_spam-0.0.2

- old
+ new

@@ -1,22 +1,23 @@ (function(){ var antiSpamizeForms = function(){ var forms = document.querySelectorAll("form"); for(var i = 0, max = forms.length; i < max; i++){ - var form = forms[i]; - form.onsubmit = function(){ - if(form.querySelectorAll('input.antispam_token').length == 0){ - var input = document.createElement('input'); - input.type = 'hidden'; - input.name = 'antispam_token'; - input.className = 'antispam_token' - input.value = '<%= AntiSpam.token %>'; - form.appendChild(input); - form.submit(); - return false; + (function(form){ + form.onsubmit = function(){ + if(form.querySelectorAll('input.antispam_token').length == 0){ + var input = document.createElement('input'); + input.type = 'hidden'; + input.name = 'antispam_token'; + input.className = 'antispam_token' + input.value = '<%= AntiSpam.token %>'; + form.appendChild(input); + form.submit(); + return false; + } } - } + })(forms[i]); } } if(document.attachEvent){ document.attachEvent("onreadystatechange", antiSpamizeForms); \ No newline at end of file