Support turning Cooldown setting on and off without reloading. #763
This commit is contained in:
parent
77a32e3371
commit
63245dfd92
@ -95,7 +95,7 @@ DeleteLink =
|
|||||||
else if msg = resDoc.getElementById 'errmsg' # error!
|
else if msg = resDoc.getElementById 'errmsg' # error!
|
||||||
new Notice 'warning', msg.textContent, 20
|
new Notice 'warning', msg.textContent, 20
|
||||||
$.on link, 'click', DeleteLink.toggle if post.fullID is DeleteLink.post.fullID
|
$.on link, 'click', DeleteLink.toggle if post.fullID is DeleteLink.post.fullID
|
||||||
if Conf['Quick Reply'] and Conf['Cooldown'] and /\bwait\b/i.test(msg.textContent)
|
if QR.cooldown.data and Conf['Cooldown'] and /\bwait\b/i.test(msg.textContent)
|
||||||
DeleteLink.cooldown.start post, 5
|
DeleteLink.cooldown.start post, 5
|
||||||
DeleteLink.auto[+fileOnly][post.fullID] = true
|
DeleteLink.auto[+fileOnly][post.fullID] = true
|
||||||
DeleteLink.nodes.links[+fileOnly].textContent = DeleteLink.linkText fileOnly
|
DeleteLink.nodes.links[+fileOnly].textContent = DeleteLink.linkText fileOnly
|
||||||
@ -124,7 +124,7 @@ DeleteLink =
|
|||||||
|
|
||||||
count: (post) ->
|
count: (post) ->
|
||||||
DeleteLink.nodes.menu.textContent = DeleteLink.menuText() if post.fullID is DeleteLink.post.fullID
|
DeleteLink.nodes.menu.textContent = DeleteLink.menuText() if post.fullID is DeleteLink.post.fullID
|
||||||
if DeleteLink.cooldown.seconds[post.fullID] > 0
|
if DeleteLink.cooldown.seconds[post.fullID] > 0 and Conf['Cooldown']
|
||||||
DeleteLink.cooldown.seconds[post.fullID]--
|
DeleteLink.cooldown.seconds[post.fullID]--
|
||||||
setTimeout DeleteLink.cooldown.count, 1000, post
|
setTimeout DeleteLink.cooldown.count, 1000, post
|
||||||
else
|
else
|
||||||
|
|||||||
@ -11,14 +11,12 @@ QR.cooldown =
|
|||||||
|
|
||||||
# Called from Main
|
# Called from Main
|
||||||
init: ->
|
init: ->
|
||||||
return unless Conf['Quick Reply'] and Conf['Cooldown']
|
return unless Conf['Quick Reply']
|
||||||
@data = Conf['cooldowns']
|
@data = Conf['cooldowns']
|
||||||
$.sync 'cooldowns', @sync
|
$.sync 'cooldowns', @sync
|
||||||
|
|
||||||
# Called from QR
|
# Called from QR
|
||||||
setup: ->
|
setup: ->
|
||||||
return unless Conf['Cooldown']
|
|
||||||
|
|
||||||
# Read cooldown times
|
# Read cooldown times
|
||||||
if m = Get.scriptData().match /\bcooldowns *= *({[^}]+})/
|
if m = Get.scriptData().match /\bcooldowns *= *({[^}]+})/
|
||||||
$.extend QR.cooldown.delays, JSON.parse m[1]
|
$.extend QR.cooldown.delays, JSON.parse m[1]
|
||||||
@ -34,6 +32,7 @@ QR.cooldown =
|
|||||||
start: ->
|
start: ->
|
||||||
{data} = QR.cooldown
|
{data} = QR.cooldown
|
||||||
return unless (
|
return unless (
|
||||||
|
Conf['Cooldown'] and
|
||||||
QR.cooldown.isSetup and
|
QR.cooldown.isSetup and
|
||||||
!QR.cooldown.isCounting and
|
!QR.cooldown.isCounting and
|
||||||
Object.keys(data[g.BOARD.ID] or {}).length + Object.keys(data.global or {}).length > 0
|
Object.keys(data[g.BOARD.ID] or {}).length + Object.keys(data.global or {}).length > 0
|
||||||
@ -66,7 +65,7 @@ QR.cooldown =
|
|||||||
QR.cooldown.start()
|
QR.cooldown.start()
|
||||||
|
|
||||||
delete: (post) ->
|
delete: (post) ->
|
||||||
return unless Conf['Cooldown']
|
return unless QR.cooldown.data
|
||||||
$.forceSync 'cooldowns'
|
$.forceSync 'cooldowns'
|
||||||
cooldowns = (QR.cooldown.data[post.board.ID] or= {})
|
cooldowns = (QR.cooldown.data[post.board.ID] or= {})
|
||||||
for id, cooldown of cooldowns
|
for id, cooldown of cooldowns
|
||||||
@ -75,7 +74,7 @@ QR.cooldown =
|
|||||||
QR.cooldown.save [post.board.ID]
|
QR.cooldown.save [post.board.ID]
|
||||||
|
|
||||||
secondsDeletion: (post) ->
|
secondsDeletion: (post) ->
|
||||||
return 0 unless Conf['Quick Reply'] and Conf['Cooldown']
|
return 0 unless QR.cooldown.data and Conf['Cooldown']
|
||||||
cooldowns = QR.cooldown.data[post.board.ID] or {}
|
cooldowns = QR.cooldown.data[post.board.ID] or {}
|
||||||
for start, cooldown of cooldowns
|
for start, cooldown of cooldowns
|
||||||
if !cooldown.delay? and cooldown.threadID is post.thread.ID and cooldown.postID is post.ID
|
if !cooldown.delay? and cooldown.threadID is post.thread.ID and cooldown.postID is post.ID
|
||||||
@ -110,7 +109,7 @@ QR.cooldown =
|
|||||||
{type, threadID} = QR.cooldown.categorize QR.posts[0]
|
{type, threadID} = QR.cooldown.categorize QR.posts[0]
|
||||||
seconds = 0
|
seconds = 0
|
||||||
|
|
||||||
for scope in [g.BOARD.ID, 'global']
|
if Conf['Cooldown'] then for scope in [g.BOARD.ID, 'global']
|
||||||
cooldowns = (QR.cooldown.data[scope] or= {})
|
cooldowns = (QR.cooldown.data[scope] or= {})
|
||||||
|
|
||||||
for start, cooldown of cooldowns
|
for start, cooldown of cooldowns
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user