diff --git a/src/classes/Post.Clone.coffee b/src/classes/Post.Clone.coffee index 923a8f7f9..12773ba58 100644 --- a/src/classes/Post.Clone.coffee +++ b/src/classes/Post.Clone.coffee @@ -41,11 +41,11 @@ Post.Clone = class extends Post @file = {} for key, val of @origin.file @file[key] = val - file = $ '.file', @nodes.post - @file.text = file.firstElementChild - @file.link = $ '.fileText > a, .fileText-original', file - @file.thumb = $ '.fileThumb > [data-md5]', file - @file.fullImage = $ '.full-image', file + {fileRoot} = @nodes + @file.text = fileRoot.firstElementChild + @file.link = $ '.fileText > a, .fileText-original', fileRoot + @file.thumb = $ '.fileThumb > [data-md5]', fileRoot + @file.fullImage = $ '.full-image', fileRoot @file.videoControls = $ '.video-controls', @file.text @file.thumb.muted = true if @file.videoThumb diff --git a/src/classes/Post.coffee b/src/classes/Post.coffee index ccfb665d4..68f17585d 100644 --- a/src/classes/Post.coffee +++ b/src/classes/Post.coffee @@ -70,6 +70,7 @@ class Post nameBlock: $ '.nameBlock', info quote: $ '.postNum > a:nth-of-type(2)', info reply: $ '.replylink', info + fileRoot: $ '.file', post comment: $ '.postMessage', post links: [] quotelinks: [] @@ -161,10 +162,11 @@ class Post @quotes.push fullID unless fullID in @quotes parseFile: -> - return unless fileEl = $ '.file', @nodes.post - return unless link = $ '.fileText > a, .fileText-original > a', fileEl - return unless info = link.nextSibling?.textContent.match /\(([\d.]+ [KMG]?B).*\)/ - fileText = fileEl.firstElementChild + {fileRoot} = @nodes + return unless fileRoot + return unless (link = $ '.fileText > a, .fileText-original > a', fileRoot) + return unless (info = link.nextSibling?.textContent.match /\(([\d.]+ [KMG]?B).*\)/) + fileText = fileRoot.firstElementChild @file = text: fileText link: link @@ -179,7 +181,7 @@ class Post unit = ['B', 'KB', 'MB', 'GB'].indexOf @file.size.match(/\w+$/)[0] size *= 1024 while unit-- > 0 @file.sizeInBytes = size - if (thumb = $ '.fileThumb > [data-md5]', fileEl) + if (thumb = $ '.fileThumb > [data-md5]', fileRoot) $.extend @file, thumb: thumb thumbURL: if m = link.href.match(/\d+(?=\.\w+$)/) then "#{location.protocol}//i.4cdn.org/#{@board}/#{m[0]}s.jpg"