Additional cooldown -> custom cooldown.

This commit is contained in:
ccd0 2015-02-21 20:35:12 -08:00
parent d1f3ab1f63
commit 9238b39874
7 changed files with 21 additions and 21 deletions

View File

@ -936,4 +936,4 @@ Config =
] ]
'Interval': 30 'Interval': 30
additionalCooldown: 0 customCooldown: 0

View File

@ -315,7 +315,7 @@ Settings =
items = {} items = {}
inputs = {} inputs = {}
for name in ['boardnav', 'time', 'backlink', 'fileInfo', 'favicon', 'usercss', 'additionalCooldown'] for name in ['boardnav', 'time', 'backlink', 'fileInfo', 'favicon', 'usercss', 'customCooldown']
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 in ['usercss', 'additionalCooldown'] continue if key in ['usercss', 'customCooldown']
Settings[key].call input Settings[key].call input
return return

View File

@ -1321,10 +1321,10 @@ input#qr-filename:not(.edit) {
#file-n-submit { #file-n-submit {
height: 23px; height: 23px;
} }
#file-n-submit.add-cooldown { #file-n-submit.custom-cooldown {
height: 43px; height: 43px;
} }
#file-n-submit:not(.add-cooldown) #add-cooldown-label { #file-n-submit:not(.custom-cooldown) #custom-cooldown-label {
display: none; display: none;
} }
#qr input[type="file"] { #qr input[type="file"] {

View File

@ -36,7 +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>
<label id="add-cooldown-label"><input type=checkbox data-name=addCooldown title="Add Custom Cooldown">Enable Custom Cooldown</label> <label id="custom-cooldown-label"><input type=checkbox data-name=customCooldown>Enable Custom Cooldown</label>
</div> </div>
<input type=file multiple> <input type=file multiple>
</form> </form>

View File

@ -110,9 +110,9 @@
</fieldset> </fieldset>
<fieldset> <fieldset>
<legend>Additional Cooldown Time</legend> <legend>Custom Cooldown Time</legend>
<div> <div>
Seconds: <input type=number name=additionalCooldown class=field min=0> Seconds: <input type=number name=customCooldown class=field min=0>
</div> </div>
</fieldset> </fieldset>

View File

@ -166,11 +166,11 @@ QR =
else else
QR.unhide() QR.unhide()
toggleAddCooldown: -> toggleCustomCooldown: ->
if @checked if @checked
QR.cooldown.addCooldown = true QR.cooldown.customCooldown = true
else else
QR.cooldown.addCooldown = false QR.cooldown.customCooldown = false
error: (err) -> error: (err) ->
QR.open() QR.open()
@ -491,7 +491,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]' setNode 'customCooldown', '[data-name=customCooldown]'
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+).+/)
@ -529,10 +529,10 @@ QR =
else else
nodes.spoiler.parentElement.hidden = true nodes.spoiler.parentElement.hidden = true
if parseInt(Conf['additionalCooldown']) > 0 if parseInt(Conf['customCooldown']) > 0
$.addClass QR.nodes.fileSubmit, 'add-cooldown' $.addClass QR.nodes.fileSubmit, 'custom-cooldown'
else else
$.rmClass QR.nodes.fileSubmit, 'add-cooldown' $.rmClass QR.nodes.fileSubmit, 'custom-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',
@ -564,8 +564,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 if parseInt(Conf['customCooldown']) > 0
$.on nodes.addCooldown,'change', QR.toggleAddCooldown $.on nodes.customCooldown,'change', QR.toggleCustomCooldown
# save selected post's data # save selected post's data
items = ['thread', 'name', 'email', 'sub', 'com', 'filename'] items = ['thread', 'name', 'email', 'sub', 'com', 'filename']

View File

@ -110,8 +110,8 @@ QR.cooldown =
QR.cooldown.maxDelay QR.cooldown.maxDelay
else else
QR.cooldown.delays[if scope is 'global' then 'thread_global' else 'thread'] QR.cooldown.delays[if scope is 'global' then 'thread_global' else 'thread']
if QR.cooldown.addCooldown if QR.cooldown.customCooldown
maxDelay += parseInt(Conf['additionalCooldown']) maxDelay = Math.max maxDelay, parseInt(Conf['customCooldown'], 10)
if maxDelay <= elapsed if maxDelay <= elapsed
delete QR.cooldown[scope][start] delete QR.cooldown[scope][start]
save = true save = true
@ -130,8 +130,8 @@ 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 additional cooldown is enabled, add the configured seconds to the count.
if QR.cooldown.addCooldown if QR.cooldown.customCooldown
seconds = Math.max seconds, QR.cooldown.delays[type] + parseInt(Conf['additionalCooldown']) - elapsed seconds = Math.max seconds, parseInt(Conf['customCooldown'], 10) - elapsed
QR.cooldown.save scope if save QR.cooldown.save scope if save