4chan-x/src/report.coffee

15 lines
463 B
CoffeeScript

Report =
init: ->
return unless /report/.test location.search
$.ready @ready
ready: ->
form = $ 'form'
field = $.id 'recaptcha_response_field'
$.on field, 'keydown', (e) ->
$.unsafeWindow.Recaptcha.reload 't' if e.keyCode is 8 and not field.value
$.on form, 'submit', (e) ->
e.preventDefault()
response = field.value.trim()
field.value = "#{response} #{response}" unless /\s/.test response
form.submit()