Merge some mayhem changes

This commit is contained in:
Jordan Bates 2013-09-19 07:27:53 -07:00
parent decfb32948
commit 3470929e05
9 changed files with 49 additions and 106 deletions

View File

@ -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

View File

@ -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
$.replace email, name
delete @nodes.email

View File

@ -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) ->
"<span class=smaller><span class=bold>#{
switch capcodeType
when 'admin'
'Administrator'
when 'mod'
'Moderator'
when 'developer'
'Developer'
} Repl#{if array.length > 1 then 'ies' else 'y'}:</span> #{
array.map (ID) ->
"<a href='/#{boardID}/res/#{threadID}#p#{ID}' class=quotelink>&gt;&gt;#{ID}</a>"
.join ' '
}</span><br>"
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 ''
]

View File

@ -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

View File

@ -68,13 +68,12 @@ class Post
# <br> -> \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]}"

View File

@ -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'

View File

@ -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

View File

@ -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

View File

@ -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}"