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 nameBlock: $ '.nameBlock', info quote: $ '.postNum > a:nth-of-type(2)', 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.hand', info if nodes.flag @nodes.flag = $ '.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 = $ '.fileThumb > [data-md5]', file @file.fullImage = $ '.full-image', file # Contract thumbnails in quote preview ImageExpand.contract @ if contractThumb @isDead = true if origin.isDead @isClone = true root.dataset.clone = origin.clones.push(@) - 1 cloneWithoutVideo: (node) -> if node.tagName is 'VIDEO' and !node.dataset.md5 # (exception for WebM thumbnails) [] 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