Add the URL to the comment when posting files in replies on /f/.
This commit is contained in:
parent
cd5e2b3b34
commit
2de2db4e6c
@ -132,13 +132,9 @@ QR.post = class
|
||||
QR.cooldown.auto = false
|
||||
when 'filename'
|
||||
return unless @file
|
||||
@file.newName = @filename.replace /[/\\]/g, '-'
|
||||
unless /\.(jpe?g|png|gif|pdf|swf|webm)$/i.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.
|
||||
@file.newName += '.jpg'
|
||||
@saveFilename()
|
||||
@updateFilename()
|
||||
@updateFlashURL()
|
||||
when 'name'
|
||||
QR.persona.set @
|
||||
|
||||
@ -188,10 +184,12 @@ QR.post = class
|
||||
@nodes.label.hidden = false if QR.spoiler
|
||||
QR.captcha.onPostChange()
|
||||
URL.revokeObjectURL @URL
|
||||
@saveFilename()
|
||||
if @ is QR.selected
|
||||
@showFileData()
|
||||
else
|
||||
@updateFilename()
|
||||
@updateFlashURL()
|
||||
@nodes.el.style.backgroundImage = null
|
||||
unless @file.type in QR.mimeTypes
|
||||
@fileError 'Unsupported file type.'
|
||||
@ -291,9 +289,18 @@ QR.post = class
|
||||
@nodes.el.style.backgroundImage = null
|
||||
@nodes.label.hidden = true if QR.spoiler
|
||||
@showFileData()
|
||||
@updateFlashURL()
|
||||
URL.revokeObjectURL @URL
|
||||
@dismissErrors (error) -> $.hasClass error, 'file-error'
|
||||
|
||||
saveFilename: ->
|
||||
@file.newName = (@filename or '').replace /[/\\]/g, '-'
|
||||
unless /\.(jpe?g|png|gif|pdf|swf|webm)$/i.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.
|
||||
@file.newName += '.jpg'
|
||||
|
||||
updateFilename: ->
|
||||
long = "#{@filename} (#{@filesize})"
|
||||
@nodes.el.title = long
|
||||
@ -309,6 +316,28 @@ QR.post = class
|
||||
else
|
||||
$.rmClass QR.nodes.fileSubmit, 'has-file'
|
||||
|
||||
updateFlashURL: ->
|
||||
return unless g.BOARD.ID is 'f'
|
||||
if @thread is 'new' or !@file
|
||||
url = ''
|
||||
else
|
||||
url = @file.newName
|
||||
url = url.replace(/"/g, '%22') if $.engine in ['blink', 'webkit']
|
||||
url = url
|
||||
.replace(/[\t\n\f\r \xa0\u200B\u2029\u3000]+/g, ' ')
|
||||
.replace(/(^ | $)/g, '')
|
||||
.replace(/\.[0-9A-Za-z]+$/, '')
|
||||
url = "https://i.4cdn.org/f/#{encodeURIComponent E url}.swf\n"
|
||||
oldURL = @flashURL or ''
|
||||
if url isnt oldURL
|
||||
@com or= ''
|
||||
@com = @com[oldURL.length..] if @com[...oldURL.length] is oldURL
|
||||
@com = (url + @com) or null
|
||||
if @ is QR.selected
|
||||
QR.nodes.com.value = @com
|
||||
QR.characterCount()
|
||||
@flashURL = url
|
||||
|
||||
pasteText: (file) ->
|
||||
@pasting = true
|
||||
reader = new FileReader()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user