Prevent auto-posting when editing any part of the first post in the last 5 seconds of the cooldown, not just when editing the comment.
This commit is contained in:
parent
5da5ca4079
commit
339163dfc3
@ -398,6 +398,7 @@ QR =
|
|||||||
|
|
||||||
handleUrl: (urlDefault) ->
|
handleUrl: (urlDefault) ->
|
||||||
QR.open()
|
QR.open()
|
||||||
|
QR.selected.preventAutoPost()
|
||||||
url = prompt 'Enter a URL:', urlDefault
|
url = prompt 'Enter a URL:', urlDefault
|
||||||
return if url is null
|
return if url is null
|
||||||
QR.nodes.fileButton.focus()
|
QR.nodes.fileButton.focus()
|
||||||
|
|||||||
@ -92,7 +92,9 @@ QR.cooldown =
|
|||||||
delete data[scope]
|
delete data[scope]
|
||||||
$.set 'cooldowns', data
|
$.set 'cooldowns', data
|
||||||
|
|
||||||
count: ->
|
update: ->
|
||||||
|
return unless QR.cooldown.isCounting
|
||||||
|
|
||||||
$.forceSync 'cooldowns'
|
$.forceSync 'cooldowns'
|
||||||
save = []
|
save = []
|
||||||
nCooldowns = 0
|
nCooldowns = 0
|
||||||
@ -163,4 +165,7 @@ QR.cooldown =
|
|||||||
update = seconds isnt QR.cooldown.seconds
|
update = seconds isnt QR.cooldown.seconds
|
||||||
QR.cooldown.seconds = seconds
|
QR.cooldown.seconds = seconds
|
||||||
QR.status() if update
|
QR.status() if update
|
||||||
QR.submit() if seconds is 0 and QR.cooldown.auto and !QR.req
|
|
||||||
|
count: ->
|
||||||
|
QR.cooldown.update()
|
||||||
|
QR.submit() if QR.cooldown.seconds is 0 and QR.cooldown.auto and !QR.req
|
||||||
|
|||||||
@ -97,6 +97,7 @@ QR.oekaki =
|
|||||||
QR.oekaki.toggle()
|
QR.oekaki.toggle()
|
||||||
|
|
||||||
edit: ->
|
edit: ->
|
||||||
|
QR.cooldown.auto = false
|
||||||
QR.oekaki.load -> $.global ->
|
QR.oekaki.load -> $.global ->
|
||||||
{Tegaki, FCX} = window
|
{Tegaki, FCX} = window
|
||||||
name = document.getElementById('qr-filename').value.replace(/\.\w+$/, '') + '.png'
|
name = document.getElementById('qr-filename').value.replace(/\.\w+$/, '') + '.png'
|
||||||
|
|||||||
@ -16,7 +16,8 @@ QR.post = class
|
|||||||
$.on @nodes.rm, 'click', (e) => e.stopPropagation(); @rm()
|
$.on @nodes.rm, 'click', (e) => e.stopPropagation(); @rm()
|
||||||
$.on @nodes.spoiler, 'change', (e) =>
|
$.on @nodes.spoiler, 'change', (e) =>
|
||||||
@spoiler = e.target.checked
|
@spoiler = e.target.checked
|
||||||
(QR.nodes.spoiler.checked = @spoiler if @ is QR.selected)
|
QR.nodes.spoiler.checked = @spoiler if @ is QR.selected
|
||||||
|
@preventAutoPost()
|
||||||
for label in $$ 'label', el
|
for label in $$ 'label', el
|
||||||
$.on label, 'click', (e) -> e.stopPropagation()
|
$.on label, 'click', (e) -> e.stopPropagation()
|
||||||
$.add QR.nodes.dumpList, el
|
$.add QR.nodes.dumpList, el
|
||||||
@ -112,7 +113,7 @@ QR.post = class
|
|||||||
@showFileData()
|
@showFileData()
|
||||||
QR.characterCount()
|
QR.characterCount()
|
||||||
|
|
||||||
save: (input) ->
|
save: (input, forced) ->
|
||||||
if input.type is 'checkbox'
|
if input.type is 'checkbox'
|
||||||
@spoiler = input.checked
|
@spoiler = input.checked
|
||||||
return
|
return
|
||||||
@ -125,10 +126,6 @@ QR.post = class
|
|||||||
QR.status()
|
QR.status()
|
||||||
when 'com'
|
when 'com'
|
||||||
@updateComment()
|
@updateComment()
|
||||||
# Disable auto-posting if you're typing in the first post
|
|
||||||
# during the last 5 seconds of the cooldown.
|
|
||||||
if QR.cooldown.auto and @ is QR.posts[0] and 0 < QR.cooldown.seconds <= 5
|
|
||||||
QR.cooldown.auto = false
|
|
||||||
when 'filename'
|
when 'filename'
|
||||||
return unless @file
|
return unless @file
|
||||||
@saveFilename()
|
@saveFilename()
|
||||||
@ -136,6 +133,7 @@ QR.post = class
|
|||||||
when 'name'
|
when 'name'
|
||||||
if @name isnt prev # only save manual changes, not values filled in by persona settings
|
if @name isnt prev # only save manual changes, not values filled in by persona settings
|
||||||
QR.persona.set @
|
QR.persona.set @
|
||||||
|
@preventAutoPost() unless forced
|
||||||
|
|
||||||
forceSave: ->
|
forceSave: ->
|
||||||
return unless @ is QR.selected
|
return unless @ is QR.selected
|
||||||
@ -143,9 +141,16 @@ QR.post = class
|
|||||||
# that do not trigger the `input` event.
|
# that do not trigger the `input` event.
|
||||||
for name in ['thread', 'name', 'email', 'sub', 'com', 'filename', 'spoiler']
|
for name in ['thread', 'name', 'email', 'sub', 'com', 'filename', 'spoiler']
|
||||||
continue if not (node = QR.nodes[name])
|
continue if not (node = QR.nodes[name])
|
||||||
@save node
|
@save node, true
|
||||||
return
|
return
|
||||||
|
|
||||||
|
preventAutoPost: ->
|
||||||
|
# Disable auto-posting if you're editing the first post
|
||||||
|
# during the last 5 seconds of the cooldown.
|
||||||
|
if QR.cooldown.auto and @ is QR.posts[0]
|
||||||
|
QR.cooldown.update() # adding/removing file can change cooldown
|
||||||
|
QR.cooldown.auto = false if QR.cooldown.seconds <= 5
|
||||||
|
|
||||||
setComment: (com) ->
|
setComment: (com) ->
|
||||||
@com = com or null
|
@com = com or null
|
||||||
if @ is QR.selected
|
if @ is QR.selected
|
||||||
@ -210,6 +215,7 @@ QR.post = class
|
|||||||
@fileError 'Unsupported file type.'
|
@fileError 'Unsupported file type.'
|
||||||
else if /^(image|video)\//.test @file.type
|
else if /^(image|video)\//.test @file.type
|
||||||
@readFile()
|
@readFile()
|
||||||
|
@preventAutoPost()
|
||||||
|
|
||||||
checkSize: ->
|
checkSize: ->
|
||||||
max = QR.max_size
|
max = QR.max_size
|
||||||
@ -306,6 +312,7 @@ QR.post = class
|
|||||||
@showFileData()
|
@showFileData()
|
||||||
URL.revokeObjectURL @URL
|
URL.revokeObjectURL @URL
|
||||||
@dismissErrors (error) -> $.hasClass error, 'file-error'
|
@dismissErrors (error) -> $.hasClass error, 'file-error'
|
||||||
|
@preventAutoPost()
|
||||||
|
|
||||||
saveFilename: ->
|
saveFilename: ->
|
||||||
@file.newName = (@filename or '').replace /[/\\]/g, '-'
|
@file.newName = (@filename or '').replace /[/\\]/g, '-'
|
||||||
@ -336,6 +343,7 @@ QR.post = class
|
|||||||
|
|
||||||
pasteText: (file) ->
|
pasteText: (file) ->
|
||||||
@pasting = true
|
@pasting = true
|
||||||
|
@preventAutoPost()
|
||||||
reader = new FileReader()
|
reader = new FileReader()
|
||||||
reader.onload = (e) =>
|
reader.onload = (e) =>
|
||||||
{result} = e.target
|
{result} = e.target
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user