Use the &altc=1 report form but substitute our own captcha options.
Also - fix tab order in report form - focus on captcha in report form - extend refresh on image click / backspace to original post form - support language setting for v1 (#458)
This commit is contained in:
parent
c8ff3f0bcd
commit
e8276ca800
@ -14,10 +14,11 @@ ReportLink =
|
||||
unless post.isDead or (post.thread.isDead and not post.thread.isArchived)
|
||||
a.textContent = 'Report'
|
||||
ReportLink.url = "//sys.4chan.org/#{post.board}/imgboard.php?mode=report&no=#{post}"
|
||||
ReportLink.dims = if Conf['Use Recaptcha v1 in Reports'] or d.cookie.indexOf('pass_enabled=1') >= 0
|
||||
'width=350,height=275'
|
||||
if (Conf['Use Recaptcha v1 in Reports'] and Main.jsEnabled) or d.cookie.indexOf('pass_enabled=1') >= 0
|
||||
ReportLink.url += '&altc=1'
|
||||
ReportLink.dims = 'width=350,height=275'
|
||||
else
|
||||
'width=400,height=550'
|
||||
ReportLink.dims = 'width=400,height=550'
|
||||
else if Conf['Archive Report']
|
||||
a.textContent = 'Report to archive'
|
||||
ReportLink.url = Redirect.to 'report', {boardID: post.board.ID, postID: post.ID}
|
||||
|
||||
@ -38,16 +38,6 @@ Report =
|
||||
else
|
||||
Report.fit 'body'
|
||||
|
||||
if Conf['Use Recaptcha v1 in Reports'] and Main.jsEnabled and d.cookie.indexOf('pass_enabled=1') < 0
|
||||
$.onExists d.body, '#recaptcha_image', (image) ->
|
||||
$.on image, 'click', ->
|
||||
if $.id 'recaptcha_challenge_image'
|
||||
$.global -> window.Recaptcha.reload()
|
||||
$.onExists d.body, '#recaptcha_response_field', (field) ->
|
||||
$.on field, 'keydown', (e) ->
|
||||
if e.keyCode is 8 and not field.value
|
||||
$.global -> window.Recaptcha.reload()
|
||||
|
||||
fit: (selector) ->
|
||||
return unless (el = $ selector, doc) and getComputedStyle(el).visibility isnt 'hidden'
|
||||
dy = el.getBoundingClientRect().bottom - doc.clientHeight + 8
|
||||
|
||||
@ -2,6 +2,12 @@ Captcha.replace =
|
||||
init: ->
|
||||
return unless d.cookie.indexOf('pass_enabled=1') < 0
|
||||
|
||||
if location.hostname is 'sys.4chan.org' and /[?&]altc\b/.test(location.search) and Main.jsEnabled
|
||||
$.onExists doc, 'script[src="//www.google.com/recaptcha/api/js/recaptcha_ajax.js"]', ->
|
||||
$.global -> window.el.onload = null
|
||||
Captcha.v1.create()
|
||||
return
|
||||
|
||||
if (
|
||||
(Conf['Use Recaptcha v1'] and location.hostname is 'boards.4chan.org') or
|
||||
(Conf['Use Recaptcha v1 in Reports'] and location.hostname is 'sys.4chan.org')
|
||||
|
||||
@ -50,12 +50,30 @@ Captcha.v1 =
|
||||
$.replace old, container
|
||||
|
||||
create: ->
|
||||
cont = $.id 'captchaContainerAlt'
|
||||
return if @occupied
|
||||
|
||||
@occupied = true
|
||||
|
||||
if (lang = Conf['captchaLanguage'].trim())
|
||||
cont.dataset.lang = lang
|
||||
|
||||
$.onExists cont, '#recaptcha_image', (image) ->
|
||||
$.on image, 'click', ->
|
||||
if $.id 'recaptcha_challenge_image'
|
||||
$.global -> window.Recaptcha.reload()
|
||||
$.onExists cont, '#recaptcha_response_field', (field) ->
|
||||
$.on field, 'keydown', (e) ->
|
||||
if e.keyCode is 8 and not field.value
|
||||
$.global -> window.Recaptcha.reload()
|
||||
field.focus() if location.hostname is 'sys.4chan.org'
|
||||
|
||||
$.global ->
|
||||
container = document.getElementById 'captchaContainerAlt'
|
||||
return if container.firstChild
|
||||
options =
|
||||
theme: 'clean'
|
||||
tabindex: {"boards.4chan.org": 5, "sys.4chan.org": 3}[location.hostname]
|
||||
theme: 'clean'
|
||||
tabindex: {"boards.4chan.org": 5}[location.hostname]
|
||||
lang: container.dataset.lang
|
||||
if window.Recaptcha
|
||||
window.Recaptcha.create '<%= meta.recaptchaKey %>', container, options
|
||||
else
|
||||
@ -123,6 +141,7 @@ Captcha.v1 =
|
||||
destroy: ->
|
||||
return unless @script
|
||||
$.global -> window.Recaptcha.destroy()
|
||||
delete @occupied
|
||||
@beforeSetup() if @nodes
|
||||
|
||||
sync: (captchas=[]) ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user