84 lines
2.4 KiB
Plaintext
Executable File
84 lines
2.4 KiB
Plaintext
Executable File
class Clone extends Post
|
|
constructor: (@origin, @context, contractThumb) ->
|
|
for key in ['ID', 'fullID', 'board', 'thread', 'info', 'quotes', 'isReply']
|
|
# Copy or point to the origin's key value.
|
|
@[key] = origin[key]
|
|
|
|
{nodes} = origin
|
|
root = if contractThumb
|
|
@cloneWithoutVideo nodes.root
|
|
else
|
|
nodes.root.cloneNode true
|
|
post = $ '.post', root
|
|
info = $ '.postInfo', post
|
|
@nodes =
|
|
root: root
|
|
post: post
|
|
info: info
|
|
comment: $ '.postMessage', post
|
|
quotelinks: []
|
|
backlinks: info.getElementsByClassName 'backlink'
|
|
|
|
# Remove inlined posts inside of this post.
|
|
for inline in $$ '.inline', post
|
|
$.rm inline
|
|
for inlined in $$ '.inlined', post
|
|
$.rmClass inlined, 'inlined'
|
|
|
|
root.hidden = false # post hiding
|
|
$.rmClass root, 'forwarded' # quote inlining
|
|
$.rmClass post, 'highlight' # keybind navigation, ID highlighting
|
|
|
|
if nodes.subject
|
|
@nodes.subject = $ '.subject', info
|
|
if nodes.name
|
|
@nodes.name = $ '.name', info
|
|
if nodes.email
|
|
@nodes.email = $ '.useremail', info
|
|
if nodes.tripcode
|
|
@nodes.tripcode = $ '.postertrip', info
|
|
if nodes.uniqueID
|
|
@nodes.uniqueID = $ '.posteruid', info
|
|
if nodes.capcode
|
|
@nodes.capcode = $ '.capcode', info
|
|
if nodes.flag
|
|
@nodes.flag = $ '.countryFlag', info
|
|
if nodes.date
|
|
@nodes.date = $ '.dateTime', info
|
|
|
|
@parseQuotes()
|
|
|
|
if origin.file
|
|
# Copy values, point to relevant elements.
|
|
# See comments in Post's constructor.
|
|
@file = {}
|
|
for key, val of origin.file
|
|
@file[key] = val
|
|
file = $ '.file', post
|
|
@file.text = file.firstElementChild
|
|
@file.thumb = $ 'img[data-md5]', file
|
|
@file.fullImage = $ '.full-image', file
|
|
|
|
# Contract thumbnails in quote preview
|
|
if contractThumb
|
|
$.rmClass @nodes.root, 'expanded-image'
|
|
$.rmClass @file.thumb, 'expanding'
|
|
|
|
# Remove any #ihover ID
|
|
@file.fullImage?.removeAttribute 'id'
|
|
|
|
@isDead = true if origin.isDead
|
|
@isClone = true
|
|
root.dataset.clone = origin.clones.push(@) - 1
|
|
|
|
cloneWithoutVideo: (node) ->
|
|
if node.tagName is 'VIDEO'
|
|
[]
|
|
else if node.nodeType is Node.ELEMENT_NODE and $ 'video', node
|
|
clone = node.cloneNode false
|
|
$.add clone, @cloneWithoutVideo child for child in node.childNodes
|
|
clone
|
|
else
|
|
node.cloneNode true
|
|
|