small improvements to file info parsing
This commit is contained in:
parent
1c0349c10d
commit
ac3b09e385
@ -130,21 +130,21 @@ class Post
|
|||||||
thumb.src
|
thumb.src
|
||||||
else
|
else
|
||||||
"#{location.protocol}//t.4cdn.org/#{@board}/thumb/#{@file.URL.match(/(\d+)\./)[1]}s.jpg"
|
"#{location.protocol}//t.4cdn.org/#{@board}/thumb/#{@file.URL.match(/(\d+)\./)[1]}s.jpg"
|
||||||
|
@file.isImage = /(jpg|png|gif)$/i.test @file.URL
|
||||||
|
@file.isVideo = /webm$/i.test @file.URL
|
||||||
|
if @file.isImage or @file.isVideo
|
||||||
|
@file.dimensions = fileText.childNodes[2].textContent.match(/\d+x\d+/)?[0]
|
||||||
@file.name = fileText.title or do ->
|
@file.name = fileText.title or do ->
|
||||||
nameNode = $('span', fileText) or $('a', fileText)
|
nameNode = $('span', fileText) or $('a', fileText)
|
||||||
nameNode.title or nameNode.textContent
|
nameNode?.title or nameNode?.textContent
|
||||||
<% if (type === 'crx') { %>
|
<% if (type === 'crx') { %>
|
||||||
# replace %22 with quotes, see:
|
# replace %22 with quotes, see:
|
||||||
# crbug.com/81193
|
# crbug.com/81193
|
||||||
# webk.it/62107
|
# webk.it/62107
|
||||||
# https://www.w3.org/Bugs/Public/show_bug.cgi?id=16909
|
# https://www.w3.org/Bugs/Public/show_bug.cgi?id=16909
|
||||||
# http://www.whatwg.org/specs/web-apps/current-work/#multipart-form-data
|
# http://www.whatwg.org/specs/web-apps/current-work/#multipart-form-data
|
||||||
@file.name = @file.name.replace /%22/g, '"'
|
@file.name = @file.name?.replace /%22/g, '"'
|
||||||
<% } %>
|
<% } %>
|
||||||
@file.isImage = /(jpg|png|gif)$/i.test @file.URL
|
|
||||||
@file.isVideo = /webm$/i.test @file.URL
|
|
||||||
if @file.isImage or @file.isVideo
|
|
||||||
@file.dimensions = fileText.textContent.match(/\d+x\d+/)[0]
|
|
||||||
|
|
||||||
cleanup: (root) ->
|
cleanup: (root) ->
|
||||||
for node in $$ '.mobile', root
|
for node in $$ '.mobile', root
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user