Implement additional cooldown.
This commit is contained in:
parent
82cd322c4b
commit
ee53c212cf
@ -935,3 +935,5 @@ Config =
|
|||||||
'Increase the intervals between updates on threads without new posts.'
|
'Increase the intervals between updates on threads without new posts.'
|
||||||
]
|
]
|
||||||
'Interval': 30
|
'Interval': 30
|
||||||
|
|
||||||
|
additionalCooldown: 0
|
||||||
|
|||||||
@ -315,7 +315,7 @@ Settings =
|
|||||||
|
|
||||||
items = {}
|
items = {}
|
||||||
inputs = {}
|
inputs = {}
|
||||||
for name in ['boardnav', 'time', 'backlink', 'fileInfo', 'favicon', 'usercss']
|
for name in ['boardnav', 'time', 'backlink', 'fileInfo', 'favicon', 'usercss', 'additionalCooldown']
|
||||||
input = $ "[name='#{name}']", section
|
input = $ "[name='#{name}']", section
|
||||||
items[name] = Conf[name]
|
items[name] = Conf[name]
|
||||||
inputs[name] = input
|
inputs[name] = input
|
||||||
@ -339,7 +339,7 @@ Settings =
|
|||||||
for key, val of items
|
for key, val of items
|
||||||
input = inputs[key]
|
input = inputs[key]
|
||||||
input.value = val
|
input.value = val
|
||||||
continue if key is 'usercss'
|
continue if key in ['usercss', 'additionalCooldown']
|
||||||
Settings[key].call input
|
Settings[key].call input
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@ -1277,6 +1277,9 @@ input#qr-filename:not(.edit) {
|
|||||||
#file-n-submit {
|
#file-n-submit {
|
||||||
height: 23px;
|
height: 23px;
|
||||||
}
|
}
|
||||||
|
#file-n-submit.add-cooldown {
|
||||||
|
height: 43px;
|
||||||
|
}
|
||||||
#qr input[type="file"] {
|
#qr input[type="file"] {
|
||||||
visibility: hidden;
|
visibility: hidden;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
@ -36,6 +36,7 @@
|
|||||||
<input type=checkbox id=qr-file-spoiler title='Spoiler image'>
|
<input type=checkbox id=qr-file-spoiler title='Spoiler image'>
|
||||||
</label>
|
</label>
|
||||||
<input type=submit>
|
<input type=submit>
|
||||||
|
#{if parseInt(Conf['additionalCooldown']) > 0 then '<span><input type=checkbox data-name=addCooldown title="Add Custom Cooldown">Enable Custom Cooldown</span>' else ''}
|
||||||
</div>
|
</div>
|
||||||
<input type=file multiple>
|
<input type=file multiple>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@ -109,6 +109,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>Additional Cooldown Time</legend>
|
||||||
|
<div>
|
||||||
|
Seconds: <input type=number name=additionalCooldown class=field min=1 value=#{Conf['additionalCooldown']}>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>
|
<legend>
|
||||||
<label><input type=checkbox name='Custom CSS'> Custom CSS</label>
|
<label><input type=checkbox name='Custom CSS'> Custom CSS</label>
|
||||||
|
|||||||
@ -166,6 +166,16 @@ QR =
|
|||||||
else
|
else
|
||||||
QR.unhide()
|
QR.unhide()
|
||||||
|
|
||||||
|
toggleAddCooldown: ->
|
||||||
|
if @checked
|
||||||
|
QR.cooldown.addCooldown = true
|
||||||
|
if QR.cooldown.seconds
|
||||||
|
QR.cooldown.seconds += parseInt(Conf['additionalCooldown'])
|
||||||
|
else
|
||||||
|
QR.cooldown.addCooldown = false
|
||||||
|
if QR.cooldown.seconds
|
||||||
|
QR.cooldown.seconds -= parseInt(Conf['additionalCooldown'])
|
||||||
|
|
||||||
error: (err) ->
|
error: (err) ->
|
||||||
QR.open()
|
QR.open()
|
||||||
if typeof err is 'string'
|
if typeof err is 'string'
|
||||||
@ -485,6 +495,7 @@ QR =
|
|||||||
setNode 'spoilerPar', '#qr-spoiler-label'
|
setNode 'spoilerPar', '#qr-spoiler-label'
|
||||||
setNode 'status', '[type=submit]'
|
setNode 'status', '[type=submit]'
|
||||||
setNode 'fileInput', '[type=file]'
|
setNode 'fileInput', '[type=file]'
|
||||||
|
setNode 'addCooldown', '[data-name=addCooldown]'
|
||||||
|
|
||||||
rules = $('ul.rules').textContent.trim()
|
rules = $('ul.rules').textContent.trim()
|
||||||
match_min = rules.match(/.+smaller than (\d+)x(\d+).+/)
|
match_min = rules.match(/.+smaller than (\d+)x(\d+).+/)
|
||||||
@ -522,6 +533,11 @@ QR =
|
|||||||
else
|
else
|
||||||
nodes.spoiler.parentElement.hidden = true
|
nodes.spoiler.parentElement.hidden = true
|
||||||
|
|
||||||
|
if parseInt(Conf['additionalCooldown']) > 0
|
||||||
|
$.addClass QR.nodes.fileSubmit, 'add-cooldown'
|
||||||
|
else
|
||||||
|
$.rmClass QR.nodes.fileSubmit, 'add-cooldown'
|
||||||
|
|
||||||
if g.BOARD.ID is 'f' and g.VIEW isnt 'thread'
|
if g.BOARD.ID is 'f' and g.VIEW isnt 'thread'
|
||||||
nodes.flashTag = $.el 'select',
|
nodes.flashTag = $.el 'select',
|
||||||
name: 'filetag'
|
name: 'filetag'
|
||||||
@ -552,6 +568,8 @@ QR =
|
|||||||
$.on nodes.fileExtras, 'click', (e) -> e.stopPropagation()
|
$.on nodes.fileExtras, 'click', (e) -> e.stopPropagation()
|
||||||
$.on nodes.spoiler, 'change', -> QR.selected.nodes.spoiler.click()
|
$.on nodes.spoiler, 'change', -> QR.selected.nodes.spoiler.click()
|
||||||
$.on nodes.fileInput, 'change', QR.handleFiles
|
$.on nodes.fileInput, 'change', QR.handleFiles
|
||||||
|
if parseInt(Conf['additionalCooldown']) > 0
|
||||||
|
$.on nodes.addCooldown,'change', QR.toggleAddCooldown
|
||||||
|
|
||||||
# save selected post's data
|
# save selected post's data
|
||||||
items = ['thread', 'name', 'email', 'sub', 'com', 'filename']
|
items = ['thread', 'name', 'email', 'sub', 'com', 'filename']
|
||||||
|
|||||||
@ -105,6 +105,10 @@ QR.cooldown =
|
|||||||
seconds = Math.max seconds, cooldown.delay - elapsed
|
seconds = Math.max seconds, cooldown.delay - elapsed
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Increase the max delay if additional cooldown is enabled
|
||||||
|
if QR.cooldown.addCooldown
|
||||||
|
QR.cooldown.maxDelay = QR.cooldown.maxDelay + parseInt(Conf['additionalCooldown'])
|
||||||
|
|
||||||
# Clean up expired cooldowns
|
# Clean up expired cooldowns
|
||||||
maxDelay = if cooldown.threadID isnt cooldown.postID
|
maxDelay = if cooldown.threadID isnt cooldown.postID
|
||||||
QR.cooldown.maxDelay
|
QR.cooldown.maxDelay
|
||||||
@ -127,6 +131,10 @@ QR.cooldown =
|
|||||||
''
|
''
|
||||||
seconds = Math.max seconds, QR.cooldown.delays[type + suffix] - elapsed
|
seconds = Math.max seconds, QR.cooldown.delays[type + suffix] - elapsed
|
||||||
|
|
||||||
|
# If additional cooldown is enabled, add the configured seconds to the count.
|
||||||
|
if QR.cooldown.addCooldown
|
||||||
|
seconds = Math.max seconds, QR.cooldown.delays[type] + parseInt(Conf['additionalCooldown']) - elapsed
|
||||||
|
|
||||||
QR.cooldown.save scope if save
|
QR.cooldown.save scope if save
|
||||||
|
|
||||||
if Object.keys(QR.cooldown.local).length + Object.keys(QR.cooldown.global).length
|
if Object.keys(QR.cooldown.local).length + Object.keys(QR.cooldown.global).length
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user