Implement 'Use Recaptcha v2 in Reports' option.

This commit is contained in:
ccd0 2015-06-22 13:35:10 -07:00
parent 4178aad3ec
commit 8cd3218616
2 changed files with 21 additions and 2 deletions

View File

@ -396,7 +396,7 @@ Config =
'Label each post from a new IP with the thread\'s current IP count.'
]
'Posting':
'Posting and Captchas':
'Quick Reply': [
true
'All-in-one form to reply, create threads, automate dumping and more.'
@ -485,6 +485,10 @@ Config =
true
'Make captcha easier to use, especially with the keyboard.'
]
'Use Recaptcha v2 in Reports': [
false
'Use the image selection captcha in the report window.'
]
'Quote Links':
'Quote Backlinks': [

View File

@ -10,7 +10,9 @@ Report =
ready: ->
$.addStyle Report.css
Report.archive() if Conf['Archive Report']
if $.hasClass doc, 'js-enabled'
if Conf['Use Recaptcha v2 in Reports']
Report.captchaV2()
if Conf['Use Recaptcha v2 in Reports'] and $.hasClass doc, 'js-enabled'
new MutationObserver(-> Report.fit '.gc-bubbleDefault').observe d.body,
childList: true
attributes: true
@ -18,6 +20,19 @@ Report =
else
Report.fit 'body'
captchaV2: ->
return unless old = $.id 'captchaContainerAlt'
container = $.el 'div',
className: 'g-recaptcha'
container.dataset.sitekey = '<%= meta.recaptchaKey %>'
$.replace old, container
url = 'https://www.google.com/recaptcha/api.js'
if lang = Conf['captchaLanguage'].trim()
url += "?hl=#{encodeURIComponent lang}"
script = $.el 'script',
src: url
$.add d.head, script
fit: (selector) ->
return unless el = $ selector, doc
dy = el.getBoundingClientRect().bottom - doc.clientHeight + 8