diff --git a/src/Miscellaneous/Banner.coffee b/src/Miscellaneous/Banner.coffee index 829861d40..5fcc5ea02 100644 --- a/src/Miscellaneous/Banner.coffee +++ b/src/Miscellaneous/Banner.coffee @@ -16,16 +16,15 @@ Banner = if g.BOARD.ID isnt 'f' and g.VIEW is 'thread' and Conf['Remove Thread Excerpt'] Banner.setTitle children[1].textContent - i = 0 - while child = children[i++] - if i is 1 + for child, i in children + if i is 0 child.title = "Click to change" $.on child, 'click', Banner.cb.toggle continue 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' else ''}title" diff --git a/src/Miscellaneous/CustomCSS.coffee b/src/Miscellaneous/CustomCSS.coffee index af3b94227..b3a7d4336 100755 --- a/src/Miscellaneous/CustomCSS.coffee +++ b/src/Miscellaneous/CustomCSS.coffee @@ -13,5 +13,5 @@ CustomCSS = update: -> unless @style - @addStyle() + return @addStyle() @style.textContent = Conf['usercss'] diff --git a/src/Miscellaneous/ExpandComment.coffee b/src/Miscellaneous/ExpandComment.coffee index bb62bacbe..9e6822b96 100755 --- a/src/Miscellaneous/ExpandComment.coffee +++ b/src/Miscellaneous/ExpandComment.coffee @@ -1,6 +1,6 @@ ExpandComment = 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.math if g.BOARD.ID is 'sci' diff --git a/src/Miscellaneous/IDColor.coffee b/src/Miscellaneous/IDColor.coffee index 32f41ced4..47ba83b74 100755 --- a/src/Miscellaneous/IDColor.coffee +++ b/src/Miscellaneous/IDColor.coffee @@ -1,28 +1,26 @@ IDColor = init: -> - return if g.VIEW not in ['index', 'thread'] or not Conf['Color User IDs'] - @ids = {} + return unless g.VIEW in ['index', 'thread'] and Conf['Color User IDs'] + @ids = { + Heaven: [0, 0, 0, '#fff'] + } Post.callbacks.push name: 'Color User IDs' cb: @node node: -> - return if @isClone or not uid = @info.uniqueID - span = $ '.hand', @nodes.uniqueID - return unless span and span.nodeName is 'SPAN' - rgb = IDColor.compute uid + return if @isClone or !((uid = @info.uniqueID) and (span = $ 'span.hand', @nodes.uniqueID)) + + rgb = IDColor.ids[uid] or IDColor.compute uid # Style the damn node. {style} = span style.color = rgb[3] style.backgroundColor = "rgb(#{rgb[0]},#{rgb[1]},#{rgb[2]})" $.addClass span, 'painted' - span.title = 'Highlight posts by this ID' compute: (uid) -> - return IDColor.ids[uid] if IDColor.ids[uid] - # Convert chars to integers, bitshift and math to create a larger integer # Create a nice string of binary hash = IDColor.hash uid @@ -35,7 +33,7 @@ IDColor = ] # 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' else '#fff' diff --git a/src/Miscellaneous/Keybinds.coffee b/src/Miscellaneous/Keybinds.coffee index 73ae10155..26dcaf314 100755 --- a/src/Miscellaneous/Keybinds.coffee +++ b/src/Miscellaneous/Keybinds.coffee @@ -46,7 +46,7 @@ Keybinds = else if (notifications = $$ '.notification').length for notification in notifications $('.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'] QR.hide() else @@ -139,19 +139,19 @@ Keybinds = Index.cycleSortType() # Thread Navigation when Conf['Next thread'] - return if g.VIEW isnt 'index' or !threadRoot + return unless g.VIEW is 'index' and threadRoot Nav.scroll +1 when Conf['Previous thread'] - return if g.VIEW isnt 'index' or !threadRoot + return unless g.VIEW is 'index' and threadRoot Nav.scroll -1 when Conf['Expand thread'] - return if g.VIEW isnt 'index' or !threadRoot + return unless g.VIEW is 'index' and threadRoot ExpandThread.toggle thread when Conf['Open thread'] - return if g.VIEW isnt 'index' or !threadRoot + return unless g.VIEW is 'index' and threadRoot Keybinds.open thread 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 # Reply Navigation when Conf['Next reply'] diff --git a/src/Miscellaneous/Time.coffee b/src/Miscellaneous/Time.coffee index a2a565ca8..f31ce0d7a 100755 --- a/src/Miscellaneous/Time.coffee +++ b/src/Miscellaneous/Time.coffee @@ -1,6 +1,6 @@ Time = 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 name: 'Time Formatting'