Don't create unnecessary Sauce elements. #1272
This commit is contained in:
parent
2b4f59beab
commit
11a465c720
@ -52,7 +52,7 @@ Sauce =
|
|||||||
return null unless !parts['types'] or ext in parts['types'].split ','
|
return null unless !parts['types'] or ext in parts['types'].split ','
|
||||||
return null unless !parts['regexp'] or (matches = post.file.name.match parts['regexp'])
|
return null unless !parts['regexp'] or (matches = post.file.name.match parts['regexp'])
|
||||||
|
|
||||||
skip = false
|
missing = []
|
||||||
for key in ['url', 'text']
|
for key in ['url', 'text']
|
||||||
parts[key] = parts[key].replace /%(T?URL|IMG|[sh]?MD5|board|name|%|semi|\$\d+)/g, (orig, parameter) ->
|
parts[key] = parts[key].replace /%(T?URL|IMG|[sh]?MD5|board|name|%|semi|\$\d+)/g, (orig, parameter) ->
|
||||||
if parameter[0] is '$'
|
if parameter[0] is '$'
|
||||||
@ -61,7 +61,7 @@ Sauce =
|
|||||||
else
|
else
|
||||||
type = Sauce.formatters[parameter] post, ext
|
type = Sauce.formatters[parameter] post, ext
|
||||||
if not type?
|
if not type?
|
||||||
skip = true
|
missing.push parameter
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
if key is 'url' and parameter not in ['%', 'semi']
|
if key is 'url' and parameter not in ['%', 'semi']
|
||||||
@ -69,7 +69,12 @@ Sauce =
|
|||||||
type = encodeURIComponent type
|
type = encodeURIComponent type
|
||||||
type
|
type
|
||||||
|
|
||||||
return null if skip
|
if post.board.ID is 'f' and missing.length and !missing.filter((x) -> !/^.?MD5$/.test(x)).length
|
||||||
|
a = Sauce.link.cloneNode false
|
||||||
|
a.dataset.skip = '1'
|
||||||
|
return a
|
||||||
|
|
||||||
|
return null if missing.length
|
||||||
|
|
||||||
a = Sauce.link.cloneNode false
|
a = Sauce.link.cloneNode false
|
||||||
a.href = parts['url']
|
a.href = parts['url']
|
||||||
@ -83,10 +88,9 @@ Sauce =
|
|||||||
nodes = []
|
nodes = []
|
||||||
skipped = []
|
skipped = []
|
||||||
for link in Sauce.links
|
for link in Sauce.links
|
||||||
if not (node = Sauce.createSauceLink link, @)
|
if (node = Sauce.createSauceLink link, @)
|
||||||
node = Sauce.link.cloneNode false
|
nodes.push $.tn(' '), node
|
||||||
skipped.push [link, node]
|
skipped.push [link, node] if node.dataset.skip
|
||||||
nodes.push $.tn(' '), node
|
|
||||||
$.add @file.text, nodes
|
$.add @file.text, nodes
|
||||||
|
|
||||||
if @board.ID is 'f'
|
if @board.ID is 'f'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user