From 3470929e0522db3f9a9e934d13fcb1293af3ed6e Mon Sep 17 00:00:00 2001 From: Jordan Bates Date: Thu, 19 Sep 2013 07:27:53 -0700 Subject: [PATCH] Merge some mayhem changes --- LICENSE | 2 +- src/Filtering/Anonymize.coffee | 7 +- src/General/Build.coffee | 34 ---------- src/General/Config.coffee | 5 +- src/General/lib/post.class | 6 +- src/Menu/DeleteLink.coffee | 2 +- src/Miscellaneous/ExpandComment.coffee | 5 -- src/Miscellaneous/ExpandThread.coffee | 2 +- src/Posting/QuickReply.coffee | 92 ++++++++++++-------------- 9 files changed, 49 insertions(+), 106 deletions(-) diff --git a/LICENSE b/LICENSE index 8e6440b8c..13113c1dd 100755 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.2.37 - 2013-09-12 +* 4chan X - Version 1.2.37 - 2013-09-19 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE diff --git a/src/Filtering/Anonymize.coffee b/src/Filtering/Anonymize.coffee index 40e991564..1db6de4ad 100755 --- a/src/Filtering/Anonymize.coffee +++ b/src/Filtering/Anonymize.coffee @@ -14,8 +14,5 @@ Anonymize = $.rm tripcode delete @nodes.tripcode if @info.email - if /sage/i.test @info.email - email.href = 'mailto:sage' - else - $.replace email, name - delete @nodes.email \ No newline at end of file + $.replace email, name + delete @nodes.email \ No newline at end of file diff --git a/src/General/Build.coffee b/src/General/Build.coffee index 6a1683a38..2c577c0ad 100755 --- a/src/General/Build.coffee +++ b/src/General/Build.coffee @@ -27,7 +27,6 @@ Build = date: data.now dateUTC: data.time comment: data.com - capcodeReplies: data.capcode_replies # thread status isSticky: !!data.sticky isClosed: !!data.closed @@ -59,7 +58,6 @@ Build = postID, threadID, boardID name, capcode, tripcode, uniqueID, email, subject, flagCode, flagName, date, dateUTC isSticky, isClosed - comment, capcodeReplies file } = o isOP = postID is threadID @@ -201,36 +199,4 @@ Build = continue if href[0] is '/' # Cross-board quote, or board link quote.href = "/#{boardID}/res/#{href}" # Fix pathnames - Build.capcodeReplies {boardID, threadID, root: container, capcodeReplies} - container - - capcodeReplies: ({boardID, threadID, bq, root, capcodeReplies}) -> - return unless capcodeReplies - - generateCapcodeReplies = (capcodeType, array) -> - "#{ - switch capcodeType - when 'admin' - 'Administrator' - when 'mod' - 'Moderator' - when 'developer' - 'Developer' - } Repl#{if array.length > 1 then 'ies' else 'y'}: #{ - array.map (ID) -> - ">>#{ID}" - .join ' ' - }
" - html = [] - for capcodeType, array of capcodeReplies - html.push generateCapcodeReplies capcodeType, array - - bq or= $ 'blockquote', root - $.add bq, [ - $.el 'br' - $.el 'br' - $.el 'span', - className: 'capcodeReplies' - innerHTML: html.join '' - ] diff --git a/src/General/Config.coffee b/src/General/Config.coffee index d0f1d5d3a..b851d9a19 100755 --- a/src/General/Config.coffee +++ b/src/General/Config.coffee @@ -455,10 +455,7 @@ Config = #/Admin$/;highlight:moot;op:yes """ - email: """ -# Filter any e-mails that are not `sage` on /a/ and /jp/: -#/^(?!sage$)/;boards:a,jp -""" + email: "" subject: """ # Filter Generals on /v/: #/general/i;boards:v;op:only diff --git a/src/General/lib/post.class b/src/General/lib/post.class index 8224e9941..aee4cce71 100755 --- a/src/General/lib/post.class +++ b/src/General/lib/post.class @@ -68,13 +68,12 @@ class Post #
-> \n # Remove: # 'Comment too long'... - # Admin/Mod/Dev replies. (/q/) # EXIF data. (/p/) # Rolls. (/tg/) # Preceding and following new lines. # Trailing spaces. bq = @nodes.comment.cloneNode true - nodes = $$ '.abbr, .capcodeReplies, .exif, b', bq + nodes = $$ '.abbr, .exif, b', bq i = 0 while node = nodes[i++] $.rm node @@ -108,8 +107,7 @@ class Post @nodes.quotelinks.push quotelink - # Don't count capcode replies as quotes in OPs. (Admin/Mod/Dev Replies: ...) - return if @isClone or !@isReply and $.hasClass quotelink.parentNode.parentNode, 'capcodeReplies' + return if @isClone # ES6 Set when? fullID = "#{match[1]}.#{match[2]}" diff --git a/src/Menu/DeleteLink.coffee b/src/Menu/DeleteLink.coffee index 1912733c6..dca9e889f 100755 --- a/src/Menu/DeleteLink.coffee +++ b/src/Menu/DeleteLink.coffee @@ -31,7 +31,7 @@ DeleteLink = el: div order: 40 open: (post) -> - return false if post.isDead or post.board.ID is 'q' + return false if post.isDead DeleteLink.post = post node = div.firstChild node.textContent = 'Delete' diff --git a/src/Miscellaneous/ExpandComment.coffee b/src/Miscellaneous/ExpandComment.coffee index ee7451dde..f5d194e6f 100755 --- a/src/Miscellaneous/ExpandComment.coffee +++ b/src/Miscellaneous/ExpandComment.coffee @@ -54,11 +54,6 @@ ExpandComment = href = quote.getAttribute 'href' continue if href[0] is '/' # Cross-board quote, or board link quote.href = "/#{post.board}/res/#{href}" # Fix pathnames - Build.capcodeReplies - boardID: post.board.ID - threadID: post.thread.ID - bq: clone - capcodeReplies: postObj.capcode_replies post.nodes.shortComment = comment $.replace comment, clone post.nodes.comment = post.nodes.longComment = clone diff --git a/src/Miscellaneous/ExpandThread.coffee b/src/Miscellaneous/ExpandThread.coffee index 504fb1125..5ea898fc7 100755 --- a/src/Miscellaneous/ExpandThread.coffee +++ b/src/Miscellaneous/ExpandThread.coffee @@ -54,7 +54,7 @@ ExpandThread = 1 else switch g.BOARD.ID # XXX boards config - when 'b', 'vg', 'q' then 3 + when 'b', 'vg' then 3 when 't' then 1 else 5 posts = $$ ".thread > .replyContainer", threadRoot diff --git a/src/Posting/QuickReply.coffee b/src/Posting/QuickReply.coffee index 62654dfbe..1591a8be1 100755 --- a/src/Posting/QuickReply.coffee +++ b/src/Posting/QuickReply.coffee @@ -272,22 +272,20 @@ QR = cooldown: init: -> return unless Conf['Cooldown'] - board = g.BOARD.ID - QR.cooldown.types = - thread: switch board - when 'q' then 86400 - when 'b', 'soc', 'r9k' then 600 - else 300 - sage: if board is 'q' then 600 else 60 - file: if board is 'q' then 300 else 30 - post: if board is 'q' then 150 else 30 + setTimers = (e) => QR.cooldown.types = e.detail + $.on window, 'cooldown:timers', setTimers + $.globalEval 'window.dispatchEvent(new CustomEvent("cooldown:timers", {detail: cooldowns}))' + QR.cooldown.types or= {} # XXX tmp workaround until all pages and the catalogs get the cooldowns var. + $.off window, 'cooldown:timers', setTimers + for type of QR.cooldown.types + QR.cooldown.types[type] = +QR.cooldown.types[type] QR.cooldown.upSpd = 0 QR.cooldown.upSpdAccuracy = .5 - $.get "cooldown.#{board}", {}, (item) -> - QR.cooldown.cooldowns = item["cooldown.#{board}"] + key = "cooldown.#{g.BOARD}" + $.get key, {}, (item) -> + QR.cooldown.cooldowns = item[key] QR.cooldown.start() - $.sync "cooldown.#{board}", QR.cooldown.sync - + $.sync key, QR.cooldown.sync start: -> return unless Conf['Cooldown'] return if QR.cooldown.isCounting @@ -303,30 +301,17 @@ QR = set: (data) -> return unless Conf['Cooldown'] - {req, post, isReply, delay} = data + {req, post, isReply, threadID, delay} = data start = if req then req.uploadEndTime else Date.now() if delay cooldown = {delay} else if post.file - upSpd = post.file.size / ((req.uploadEndTime - req.uploadStartTime) / $.SECOND) + upSpd = post.file.size / ((start - req.uploadStartTime) / $.SECOND) QR.cooldown.upSpdAccuracy = ((upSpd > QR.cooldown.upSpd * .9) + QR.cooldown.upSpdAccuracy) / 2 QR.cooldown.upSpd = upSpd - isSage = /sage/i.test post.email hasFile = !!post.file - type = unless isReply - 'thread' - else if isSage - 'sage' - else if hasFile - 'file' - else - 'post' - cooldown = - isReply: isReply - isSage: isSage - hasFile: hasFile - timeout: start + QR.cooldown.types[type] * $.SECOND + cooldown = {isReply, hasFile, threadID} QR.cooldown.cooldowns[start] = cooldown $.set "cooldown.#{g.BOARD}", QR.cooldown.cooldowns QR.cooldown.start() @@ -346,12 +331,12 @@ QR = QR.status() return - setTimeout QR.cooldown.count, $.SECOND + clearTimeout QR.cooldown.timeout + QR.cooldown.timeout = setTimeout QR.cooldown.count, $.SECOND - now = Date.now() - post = QR.posts[0] + now = Date.now() + post = QR.posts[0] isReply = post.thread isnt 'new' - isSage = /sage/i.test post.email hasFile = !!post.file seconds = null {types, cooldowns, upSpd, upSpdAccuracy} = QR.cooldown @@ -365,26 +350,31 @@ QR = QR.cooldown.unset start continue + if 'timeout' of cooldown + # XXX tmp conversion from previous cooldowns + QR.cooldown.unset start + continue + 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. + # Only cooldowns relevant to this post can set the seconds variable: + # reply cooldown with a reply, thread cooldown with a thread + elapsed = Math.floor (now - start) / $.SECOND + continue if elapsed < 0 # clock changed since then? type = unless isReply 'thread' - else if isSage and cooldown.isSage - 'sage' - else if hasFile and cooldown.hasFile - 'file' + else if hasFile + 'image' else - 'post' - elapsed = Math.floor (now - start) / $.SECOND - if elapsed >= 0 # clock changed since then? - seconds = Math.max seconds, types[type] - elapsed - if Conf['Cooldown Prediction'] and hasFile and upSpd - seconds -= Math.floor post.file.size / upSpd * upSpdAccuracy - seconds = Math.max seconds, 0 - unless start <= now <= cooldown.timeout - QR.cooldown.unset start + 'reply' + maxTimer = Math.max types[type] or 0, types[type + '_intra'] or 0 + unless start <= now <= start + maxTimer * $.SECOND + QR.cooldown.unset start + type += '_intra' if isReply and +post.thread is cooldown.threadID + seconds = Math.max seconds, types[type] - elapsed + if seconds and Conf['Cooldown Prediction'] and hasFile and upSpd + seconds -= Math.floor post.file.size / upSpd * upSpdAccuracy + seconds = Math.max seconds, 0 # Update the status when we change posting type. # Don't get stuck at some random number. # Don't interfere with progress status updates. @@ -908,7 +898,7 @@ QR = form: 'form' dumpButton: '#dump-button' name: '[data-name=name]' - email: '[data-name=email]' + email: '[data-'q'=email]' sub: '[data-name=sub]' com: '[data-name=com]' dumpList: '#dump-list' @@ -1038,7 +1028,7 @@ QR = # prevent errors if threadID is 'new' threadID = null - if ['vg', 'q'].contains(g.BOARD.ID) and !post.sub + if g.BOARD.ID is 'vg' and !post.sub err = 'New threads require a subject.' else unless post.file or textOnly = !!$ 'input[name=textonly]', $.id 'postForm' err = 'No file selected.' @@ -1231,7 +1221,7 @@ QR = else post.rm() - QR.cooldown.set {req, post, isReply} + QR.cooldown.set {req, post, isReply, threadID} URL = if threadID is postID # new thread "/#{g.BOARD}/res/#{threadID}"