Merge branch 'next'
This commit is contained in:
commit
8328f27567
@ -431,6 +431,11 @@ Config =
|
||||
'Remember the spoiler state, instead of resetting after posting.'
|
||||
1
|
||||
]
|
||||
'Randomize Filename': [
|
||||
false
|
||||
'Set the filename to a random timestamp within the past year. Disabled on /f/.'
|
||||
1
|
||||
]
|
||||
'Show New Thread Option in Threads': [
|
||||
false
|
||||
'Show the option to post a new / different thread from inside a thread.'
|
||||
|
||||
@ -133,7 +133,7 @@ Captcha.noscript =
|
||||
if captcha = @captchas.shift()
|
||||
@count()
|
||||
$.set 'captchas', @captchas
|
||||
{challenge: captcha.response, response: 'manual_challenge'}
|
||||
captcha
|
||||
else if /\S/.test @nodes.input.value
|
||||
(cb) =>
|
||||
@submitCB = cb
|
||||
@ -149,15 +149,17 @@ Captcha.noscript =
|
||||
save: (token) ->
|
||||
delete @occupied
|
||||
@nodes.input.value = ''
|
||||
captcha =
|
||||
challenge: token
|
||||
response: 'manual_challenge'
|
||||
timeout: @timeout
|
||||
if @submitCB
|
||||
@submitCB {challenge: token, response: 'manual_challenge'}
|
||||
@submitCB captcha
|
||||
delete @submitCB
|
||||
if @needed() then @reload() else @destroy()
|
||||
else
|
||||
$.forceSync 'captchas'
|
||||
@captchas.push
|
||||
response: token
|
||||
timeout: @timeout
|
||||
@captchas.push captcha
|
||||
@count()
|
||||
$.set 'captchas', @captchas
|
||||
@reload()
|
||||
|
||||
@ -135,16 +135,17 @@ Captcha.v1 =
|
||||
getOne: ->
|
||||
@clear()
|
||||
if captcha = @captchas.shift()
|
||||
{challenge, response} = captcha
|
||||
@count()
|
||||
$.set 'captchas', @captchas
|
||||
captcha
|
||||
else
|
||||
challenge = @nodes.img.alt
|
||||
challenge = @nodes.img.alt
|
||||
timeout = @timeout
|
||||
if /\S/.test(response = @nodes.input.value)
|
||||
@destroy()
|
||||
{challenge, response, timeout}
|
||||
else
|
||||
return null
|
||||
{challenge, response}
|
||||
null
|
||||
|
||||
save: ->
|
||||
return unless /\S/.test(response = @nodes.input.value)
|
||||
|
||||
@ -169,7 +169,7 @@ Captcha.v2 =
|
||||
if captcha = @captchas.shift()
|
||||
$.set 'captchas', @captchas
|
||||
@count()
|
||||
captcha.response
|
||||
captcha
|
||||
else
|
||||
null
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
QR =
|
||||
mimeTypes: ['image/jpeg', 'image/png', 'image/gif', 'application/pdf', 'application/vnd.adobe.flash.movie', 'application/x-shockwave-flash', 'video/webm']
|
||||
|
||||
validExtension: /\.(jpe?g|png|gif|pdf|swf|webm)$/i
|
||||
|
||||
typeFromExtension:
|
||||
'jpg': 'image/jpeg'
|
||||
'jpeg': 'image/jpeg'
|
||||
@ -363,7 +365,7 @@ QR =
|
||||
for i in [0...bstr.length]
|
||||
arr[i] = bstr.charCodeAt(i)
|
||||
blob = new Blob [arr], {type: m[1]}
|
||||
blob.name = "image.#{m[2]}"
|
||||
blob.name = "file.#{m[2]}"
|
||||
QR.handleFiles [blob]
|
||||
else if /^https?:\/\//.test src
|
||||
QR.handleUrl src
|
||||
@ -678,7 +680,7 @@ QR =
|
||||
extra.form.append 'recaptcha_challenge_field', response.challenge
|
||||
extra.form.append 'recaptcha_response_field', response.response
|
||||
else
|
||||
extra.form.append 'g-recaptcha-response', response
|
||||
extra.form.append 'g-recaptcha-response', response.response
|
||||
QR.req = $.ajax "https://sys.4chan.org/#{g.BOARD}/post", options, extra
|
||||
QR.req.progress = '...'
|
||||
|
||||
|
||||
@ -179,7 +179,11 @@ QR.post = class
|
||||
return
|
||||
|
||||
setFile: (@file) ->
|
||||
@filename = @file.name
|
||||
if Conf['Randomize Filename'] and g.BOARD.ID isnt 'f'
|
||||
@filename = "#{Date.now() - Math.floor(Math.random() * 365 * $.DAY)}"
|
||||
@filename += ext[0] if ext = @file.name.match QR.validExtension
|
||||
else
|
||||
@filename = @file.name
|
||||
@filesize = $.bytesToString @file.size
|
||||
@checkSize()
|
||||
@nodes.label.hidden = false if QR.spoiler
|
||||
@ -296,7 +300,7 @@ QR.post = class
|
||||
|
||||
saveFilename: ->
|
||||
@file.newName = (@filename or '').replace /[/\\]/g, '-'
|
||||
unless /\.(jpe?g|png|gif|pdf|swf|webm)$/i.test @filename
|
||||
unless QR.validExtension.test @filename
|
||||
# 4chan will truncate the filename if it has no extension,
|
||||
# but it will always replace the extension by the correct one,
|
||||
# so we suffix it with '.jpg' when needed.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user