From 4b1391a81b5c1743248e71071aa06e7f13cb3b85 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 5 Oct 2012 16:20:37 +0200 Subject: [PATCH] Tiny refactor. --- 4chan_x.user.js | 5 ++--- script.coffee | 27 ++++++++++++--------------- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 11ce157d6..c34abfb08 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1934,13 +1934,12 @@ } continue; } - type = isReply && cooldown.isReply ? isSage && cooldown.isSage ? 'sage' : hasFile && cooldown.hasFile ? 'file' : 'post' : !(isReply || cooldown.isReply) ? 'thread' : void 0; - if (type) { + if (isReply === cooldown.isReply) { + type = !isReply ? 'thread' : isSage && cooldown.isSage ? 'sage' : hasFile && cooldown.hasFile ? 'file' : 'post'; elapsed = Math.floor((now - start) / 1000); if (elapsed >= 0) { seconds = Math.max(seconds, types[type] - elapsed); } - type = ''; } if (!((start <= now && now <= cooldown.timeout))) { QR.cooldown.unset(start); diff --git a/script.coffee b/script.coffee index 335a7890e..988d3e58b 100644 --- a/script.coffee +++ b/script.coffee @@ -1451,13 +1451,12 @@ QR = type = unless isReply 'thread' + else if isSage + 'sage' + else if hasFile + 'file' else - if isSage - 'sage' - else if hasFile - 'file' - else - 'post' + 'post' cooldown = isReply: isReply isSage: isSage @@ -1496,23 +1495,21 @@ QR = QR.cooldown.unset start continue - # Only cooldowns relevant to this post can set the seconds value. - # Unset outdated cooldowns that can no longer impact us. - type = - if isReply and cooldown.isReply - if isSage and cooldown.isSage + if isReply is cooldown.isReply + # Only cooldowns relevant to this post can set the seconds value. + # Unset outdated cooldowns that can no longer impact us. + type = + unless isReply + 'thread' + else if isSage and cooldown.isSage 'sage' else if hasFile and cooldown.hasFile 'file' else 'post' - else unless isReply or cooldown.isReply - 'thread' - if type elapsed = Math.floor (now - start) / 1000 if elapsed >= 0 # clock changed since then? seconds = Math.max seconds, types[type] - elapsed - type = '' unless start <= now <= cooldown.timeout QR.cooldown.unset start