Merge from Appchan X: src/Miscellaneous

excluded: CatalogLinks.coffee
deferred: Flash.coffee
This commit is contained in:
ccd0 2015-01-31 01:01:56 -08:00
parent eaec80f5a5
commit 7147ad0a01
6 changed files with 20 additions and 23 deletions

View File

@ -16,16 +16,15 @@ Banner =
if g.BOARD.ID isnt 'f' and g.VIEW is 'thread' and Conf['Remove Thread Excerpt'] if g.BOARD.ID isnt 'f' and g.VIEW is 'thread' and Conf['Remove Thread Excerpt']
Banner.setTitle children[1].textContent Banner.setTitle children[1].textContent
i = 0 for child, i in children
while child = children[i++] if i is 0
if i is 1
child.title = "Click to change" child.title = "Click to change"
$.on child, 'click', Banner.cb.toggle $.on child, 'click', Banner.cb.toggle
continue continue
if Conf['Custom Board Titles'] if Conf['Custom Board Titles']
Banner.custom(child).title = "Ctrl/\u2318+click to edit board #{if i is 3 Banner.custom(child).title = "Ctrl/\u2318+click to edit board #{if i is 2
'sub' 'sub'
else else
''}title" ''}title"

View File

@ -13,5 +13,5 @@ CustomCSS =
update: -> update: ->
unless @style unless @style
@addStyle() return @addStyle()
@style.textContent = Conf['usercss'] @style.textContent = Conf['usercss']

View File

@ -1,6 +1,6 @@
ExpandComment = ExpandComment =
init: -> init: ->
return if g.VIEW isnt 'index' or !Conf['Comment Expansion'] return if g.VIEW isnt 'index' or !Conf['Comment Expansion'] or Conf['JSON Navigation']
@callbacks.push Fourchan.code if g.BOARD.ID is 'g' @callbacks.push Fourchan.code if g.BOARD.ID is 'g'
@callbacks.push Fourchan.math if g.BOARD.ID is 'sci' @callbacks.push Fourchan.math if g.BOARD.ID is 'sci'

View File

@ -1,28 +1,26 @@
IDColor = IDColor =
init: -> init: ->
return if g.VIEW not in ['index', 'thread'] or not Conf['Color User IDs'] return unless g.VIEW in ['index', 'thread'] and Conf['Color User IDs']
@ids = {} @ids = {
Heaven: [0, 0, 0, '#fff']
}
Post.callbacks.push Post.callbacks.push
name: 'Color User IDs' name: 'Color User IDs'
cb: @node cb: @node
node: -> node: ->
return if @isClone or not uid = @info.uniqueID return if @isClone or !((uid = @info.uniqueID) and (span = $ 'span.hand', @nodes.uniqueID))
span = $ '.hand', @nodes.uniqueID
return unless span and span.nodeName is 'SPAN' rgb = IDColor.ids[uid] or IDColor.compute uid
rgb = IDColor.compute uid
# Style the damn node. # Style the damn node.
{style} = span {style} = span
style.color = rgb[3] style.color = rgb[3]
style.backgroundColor = "rgb(#{rgb[0]},#{rgb[1]},#{rgb[2]})" style.backgroundColor = "rgb(#{rgb[0]},#{rgb[1]},#{rgb[2]})"
$.addClass span, 'painted' $.addClass span, 'painted'
span.title = 'Highlight posts by this ID'
compute: (uid) -> compute: (uid) ->
return IDColor.ids[uid] if IDColor.ids[uid]
# Convert chars to integers, bitshift and math to create a larger integer # Convert chars to integers, bitshift and math to create a larger integer
# Create a nice string of binary # Create a nice string of binary
hash = IDColor.hash uid hash = IDColor.hash uid
@ -35,7 +33,7 @@ IDColor =
] ]
# Weight color luminance values, assign a font color that should be readable. # Weight color luminance values, assign a font color that should be readable.
rgb[3] = if (rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114) > 125 rgb.push if (rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114) > 125
'#000' '#000'
else else
'#fff' '#fff'

View File

@ -46,7 +46,7 @@ Keybinds =
else if (notifications = $$ '.notification').length else if (notifications = $$ '.notification').length
for notification in notifications for notification in notifications
$('.close', notification).click() $('.close', notification).click()
else if QR.nodes and !QR.nodes.el.hidden and window.getComputedStyle(QR.nodes.form).display isnt 'none' else if QR.nodes and not (QR.nodes.el.hidden or window.getComputedStyle(QR.nodes.form).display is 'none')
if Conf['Persistent QR'] if Conf['Persistent QR']
QR.hide() QR.hide()
else else
@ -139,19 +139,19 @@ Keybinds =
Index.cycleSortType() Index.cycleSortType()
# Thread Navigation # Thread Navigation
when Conf['Next thread'] when Conf['Next thread']
return if g.VIEW isnt 'index' or !threadRoot return unless g.VIEW is 'index' and threadRoot
Nav.scroll +1 Nav.scroll +1
when Conf['Previous thread'] when Conf['Previous thread']
return if g.VIEW isnt 'index' or !threadRoot return unless g.VIEW is 'index' and threadRoot
Nav.scroll -1 Nav.scroll -1
when Conf['Expand thread'] when Conf['Expand thread']
return if g.VIEW isnt 'index' or !threadRoot return unless g.VIEW is 'index' and threadRoot
ExpandThread.toggle thread ExpandThread.toggle thread
when Conf['Open thread'] when Conf['Open thread']
return if g.VIEW isnt 'index' or !threadRoot return unless g.VIEW is 'index' and threadRoot
Keybinds.open thread Keybinds.open thread
when Conf['Open thread tab'] when Conf['Open thread tab']
return if g.VIEW isnt 'index' or !threadRoot return unless g.VIEW is 'index' and threadRoot
Keybinds.open thread, true Keybinds.open thread, true
# Reply Navigation # Reply Navigation
when Conf['Next reply'] when Conf['Next reply']

View File

@ -1,6 +1,6 @@
Time = Time =
init: -> init: ->
return if g.VIEW not in ['index', 'thread'] or !Conf['Time Formatting'] return unless g.VIEW in ['index', 'thread'] and Conf['Time Formatting']
Post.callbacks.push Post.callbacks.push
name: 'Time Formatting' name: 'Time Formatting'