Add nodes.fileRoot to Post object.
This commit is contained in:
parent
084967ff51
commit
88efaeae67
@ -41,11 +41,11 @@ Post.Clone = class extends Post
|
|||||||
@file = {}
|
@file = {}
|
||||||
for key, val of @origin.file
|
for key, val of @origin.file
|
||||||
@file[key] = val
|
@file[key] = val
|
||||||
file = $ '.file', @nodes.post
|
{fileRoot} = @nodes
|
||||||
@file.text = file.firstElementChild
|
@file.text = fileRoot.firstElementChild
|
||||||
@file.link = $ '.fileText > a, .fileText-original', file
|
@file.link = $ '.fileText > a, .fileText-original', fileRoot
|
||||||
@file.thumb = $ '.fileThumb > [data-md5]', file
|
@file.thumb = $ '.fileThumb > [data-md5]', fileRoot
|
||||||
@file.fullImage = $ '.full-image', file
|
@file.fullImage = $ '.full-image', fileRoot
|
||||||
@file.videoControls = $ '.video-controls', @file.text
|
@file.videoControls = $ '.video-controls', @file.text
|
||||||
|
|
||||||
@file.thumb.muted = true if @file.videoThumb
|
@file.thumb.muted = true if @file.videoThumb
|
||||||
|
|||||||
@ -70,6 +70,7 @@ class Post
|
|||||||
nameBlock: $ '.nameBlock', info
|
nameBlock: $ '.nameBlock', info
|
||||||
quote: $ '.postNum > a:nth-of-type(2)', info
|
quote: $ '.postNum > a:nth-of-type(2)', info
|
||||||
reply: $ '.replylink', info
|
reply: $ '.replylink', info
|
||||||
|
fileRoot: $ '.file', post
|
||||||
comment: $ '.postMessage', post
|
comment: $ '.postMessage', post
|
||||||
links: []
|
links: []
|
||||||
quotelinks: []
|
quotelinks: []
|
||||||
@ -161,10 +162,11 @@ class Post
|
|||||||
@quotes.push fullID unless fullID in @quotes
|
@quotes.push fullID unless fullID in @quotes
|
||||||
|
|
||||||
parseFile: ->
|
parseFile: ->
|
||||||
return unless fileEl = $ '.file', @nodes.post
|
{fileRoot} = @nodes
|
||||||
return unless link = $ '.fileText > a, .fileText-original > a', fileEl
|
return unless fileRoot
|
||||||
return unless info = link.nextSibling?.textContent.match /\(([\d.]+ [KMG]?B).*\)/
|
return unless (link = $ '.fileText > a, .fileText-original > a', fileRoot)
|
||||||
fileText = fileEl.firstElementChild
|
return unless (info = link.nextSibling?.textContent.match /\(([\d.]+ [KMG]?B).*\)/)
|
||||||
|
fileText = fileRoot.firstElementChild
|
||||||
@file =
|
@file =
|
||||||
text: fileText
|
text: fileText
|
||||||
link: link
|
link: link
|
||||||
@ -179,7 +181,7 @@ class Post
|
|||||||
unit = ['B', 'KB', 'MB', 'GB'].indexOf @file.size.match(/\w+$/)[0]
|
unit = ['B', 'KB', 'MB', 'GB'].indexOf @file.size.match(/\w+$/)[0]
|
||||||
size *= 1024 while unit-- > 0
|
size *= 1024 while unit-- > 0
|
||||||
@file.sizeInBytes = size
|
@file.sizeInBytes = size
|
||||||
if (thumb = $ '.fileThumb > [data-md5]', fileEl)
|
if (thumb = $ '.fileThumb > [data-md5]', fileRoot)
|
||||||
$.extend @file,
|
$.extend @file,
|
||||||
thumb: thumb
|
thumb: thumb
|
||||||
thumbURL: if m = link.href.match(/\d+(?=\.\w+$)/) then "#{location.protocol}//i.4cdn.org/#{@board}/#{m[0]}s.jpg"
|
thumbURL: if m = link.href.match(/\d+(?=\.\w+$)/) then "#{location.protocol}//i.4cdn.org/#{@board}/#{m[0]}s.jpg"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user