Whitespace.

This commit is contained in:
ccd0 2015-03-14 19:23:22 -07:00
parent 9aec2129ef
commit 7dd1014a12

View File

@ -9,11 +9,13 @@ Sauce =
catch err catch err
# Don't add random text plz. # Don't add random text plz.
return unless links.length return unless links.length
@links = links @links = links
@link = $.el 'a', target: '_blank' @link = $.el 'a', target: '_blank'
Post.callbacks.push Post.callbacks.push
name: 'Sauce' name: 'Sauce'
cb: @node cb: @node
createSauceLink: (link, post) -> createSauceLink: (link, post) ->
parts = {} parts = {}
for part, i in link.split /;(?=(?:text|boards|types):)/ for part, i in link.split /;(?=(?:text|boards|types):)/
@ -22,6 +24,7 @@ Sauce =
else else
m = part.match /^(\w*):(.*)$/ m = part.match /^(\w*):(.*)$/
parts[m[1]] = m[2] parts[m[1]] = m[2]
parts['text'] or= parts['url'].match(/(\w+)\.\w+\//)?[1] or '?' parts['text'] or= parts['url'].match(/(\w+)\.\w+\//)?[1] or '?'
skip = false skip = false
for key of parts for key of parts
@ -38,11 +41,14 @@ Sauce =
if not type? if not type?
skip = true skip = true
return '' return ''
if key is 'url' and parameter isnt '%%' and parameter isnt '%semi' if key is 'url' and parameter isnt '%%' and parameter isnt '%semi'
type = JSON.stringify type if /^javascript:/i.test parts['url'] type = JSON.stringify type if /^javascript:/i.test parts['url']
type = encodeURIComponent type type = encodeURIComponent type
type type
return null if skip return null if skip
ext = post.file.URL.match(/\.([^\.]*)$/)?[1] or '' ext = post.file.URL.match(/\.([^\.]*)$/)?[1] or ''
return null unless !parts['boards'] or post.board.ID in parts['boards'].split ',' return null unless !parts['boards'] or post.board.ID in parts['boards'].split ','
return null unless !parts['types'] or ext in parts['types'].split ',' return null unless !parts['types'] or ext in parts['types'].split ','
@ -51,8 +57,10 @@ Sauce =
a.textContent = parts['text'] a.textContent = parts['text']
a.removeAttribute 'target' if /^javascript:/i.test parts['url'] a.removeAttribute 'target' if /^javascript:/i.test parts['url']
a a
node: -> node: ->
return if @isClone or !@file return if @isClone or !@file
nodes = [] nodes = []
for link in Sauce.links when node = Sauce.createSauceLink link, @ for link in Sauce.links when node = Sauce.createSauceLink link, @
# \u00A0 is nbsp # \u00A0 is nbsp