diff --git a/Makefile b/Makefile index 5ae047f34..1673549f0 100644 --- a/Makefile +++ b/Makefile @@ -131,7 +131,7 @@ tmp/declaration.js : .events/declare $(if $(wildcard $@),,node tools/declare.js && echo -> $^) define force_compile -$$(call dests_of,$1) : $1 $$(call imports,$$(call part_of,$1)) $$(template_deps) $$(coffee_deps) tools/globalize.js tools/chain.js +$$(call dests_of,$1) : $1 $$(call imports,$$(call part_of,$1)) $$(template_deps) $$(coffee_deps) tools/chain.js $(RM) $$(subst $$$$,$$(ESC_DOLLAR),$$@) endef diff --git a/src/Archive/Redirect.coffee b/src/Archive/Redirect.coffee index 693c47911..233ac7ec3 100644 --- a/src/Archive/Redirect.coffee +++ b/src/Archive/Redirect.coffee @@ -114,3 +114,5 @@ Redirect = location.replace url else if alternative location.replace alternative + +return Redirect diff --git a/src/Filtering/Anonymize.coffee b/src/Filtering/Anonymize.coffee index ba3693342..1f992447d 100644 --- a/src/Filtering/Anonymize.coffee +++ b/src/Filtering/Anonymize.coffee @@ -24,3 +24,5 @@ Anonymize = name.textContent = 'Anonymous' for name in $$ '.name' $.rm trip for trip in $$ '.postertrip' return + +return Anonymize diff --git a/src/Filtering/Filter.coffee b/src/Filtering/Filter.coffee index e7d896d8b..8ade2b603 100644 --- a/src/Filtering/Filter.coffee +++ b/src/Filtering/Filter.coffee @@ -247,3 +247,5 @@ Filter = tl = ta.textLength ta.setSelectionRange tl, tl ta.focus() + +return Filter diff --git a/src/Filtering/PostHiding.coffee b/src/Filtering/PostHiding.coffee index 3b64fa661..cd37410c0 100644 --- a/src/Filtering/PostHiding.coffee +++ b/src/Filtering/PostHiding.coffee @@ -215,3 +215,5 @@ PostHiding = for quotelink in Get.allQuotelinksLinkingTo post $.rmClass quotelink, 'filtered' return + +return PostHiding diff --git a/src/Filtering/Recursive.coffee b/src/Filtering/Recursive.coffee index 902fce8b7..1c6f44139 100644 --- a/src/Filtering/Recursive.coffee +++ b/src/Filtering/Recursive.coffee @@ -32,3 +32,5 @@ Recursive = g.posts.forEach (post) -> if fullID in post.quotes recursive post, args... + +return Recursive diff --git a/src/Filtering/ThreadHiding.coffee b/src/Filtering/ThreadHiding.coffee index 7087deb12..3f83bd5e6 100644 --- a/src/Filtering/ThreadHiding.coffee +++ b/src/Filtering/ThreadHiding.coffee @@ -189,3 +189,5 @@ ThreadHiding = threadRoot = thread.OP.nodes.root.parentNode threadRoot.hidden = thread.isHidden = false Index.updateHideLabel() if Conf['JSON Index'] + +return ThreadHiding diff --git a/src/General/Build.coffee b/src/General/Build.coffee index 83c96fd10..8259c5cb3 100644 --- a/src/General/Build.coffee +++ b/src/General/Build.coffee @@ -260,3 +260,5 @@ Build = $.addClass $('.file-count', root), 'warning' root + +return Build diff --git a/src/General/Get.coffee b/src/General/Get.coffee index aff510085..3a2a56000 100644 --- a/src/General/Get.coffee +++ b/src/General/Get.coffee @@ -67,3 +67,5 @@ Get = for script in $$ 'script:not([src])', d.head return script.textContent if /\bcooldowns *=/.test script.textContent '' + +return Get diff --git a/src/General/Header.coffee b/src/General/Header.coffee index b7417391f..76ee8da9b 100644 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -539,3 +539,5 @@ Header = $.set 'Desktop Notifications', false notice.close() notice = new Notice 'info', el + +return Header diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 8682dbab5..da54baa0c 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -773,3 +773,5 @@ Index = for keyword in keywords return false if -1 is text.indexOf keyword return true + +return Index diff --git a/src/General/Polyfill.coffee b/src/General/Polyfill.coffee index df2f7c030..a6f5b2442 100644 --- a/src/General/Polyfill.coffee +++ b/src/General/Polyfill.coffee @@ -13,3 +13,5 @@ Polyfill = ui8a[i] = data.charCodeAt i cb new Blob [ui8a], {type} $.globalEval "HTMLCanvasElement.prototype.toBlob = (#{HTMLCanvasElement::toBlob});" + +return Polyfill diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee index 647f9963e..cb4d55911 100644 --- a/src/General/Settings.coffee +++ b/src/General/Settings.coffee @@ -613,3 +613,5 @@ Settings = return unless (key = Keybinds.keyCode e)? @value = key $.cb.value.call @ + +return Settings diff --git a/src/General/UI.coffee b/src/General/UI.coffee index ccc48d62d..700136650 100644 --- a/src/General/UI.coffee +++ b/src/General/UI.coffee @@ -1,390 +1,389 @@ -UI = do -> - dialog = (id, position, properties) -> - el = $.el 'div', +dialog = (id, position, properties) -> + el = $.el 'div', + className: 'dialog' + id: id + $.extend el, properties + el.style.cssText = position + $.get "#{id}.position", position, (item) -> + el.style.cssText = item["#{id}.position"] + + move = $ '.move', el + $.on move, 'touchstart mousedown', dragstart + for child in move.children + continue unless child.tagName + $.on child, 'touchstart mousedown', (e) -> + e.stopPropagation() + + el + +class Menu + currentMenu = null + lastToggledButton = null + + constructor: (@type) -> + # XXX AddMenuEntry event is deprecated + $.on d, 'AddMenuEntry', ({detail}) => + return if detail.type isnt @type + delete detail.open + @addEntry detail + @entries = [] + + makeMenu: -> + menu = $.el 'div', className: 'dialog' - id: id - $.extend el, properties - el.style.cssText = position - $.get "#{id}.position", position, (item) -> - el.style.cssText = item["#{id}.position"] + id: 'menu' + tabIndex: 0 + $.on menu, 'click', (e) -> e.stopPropagation() + $.on menu, 'keydown', @keybinds + menu - move = $ '.move', el - $.on move, 'touchstart mousedown', dragstart - for child in move.children - continue unless child.tagName - $.on child, 'touchstart mousedown', (e) -> - e.stopPropagation() + toggle: (e, button, data) -> + e.preventDefault() + e.stopPropagation() - el + if currentMenu + # Close if it's already opened. + # Reopen if we clicked on another button. + previousButton = lastToggledButton + currentMenu.close() + return if previousButton is button - class Menu + return unless @entries.length + @open button, data + + open: (button, data) -> + menu = @menu = @makeMenu() + currentMenu = @ + lastToggledButton = button + + @entries.sort (first, second) -> + first.order - second.order + + for entry in @entries + @insertEntry entry, menu, data + + $.addClass lastToggledButton, 'active' + + $.on d, 'click CloseMenu', @close + $.on d, 'scroll', @close unless @type is 'gallery' + $.add button, menu + + # Position + mRect = menu.getBoundingClientRect() + bRect = button.getBoundingClientRect() + bTop = window.scrollY + bRect.top + bLeft = window.scrollX + bRect.left + cHeight = doc.clientHeight + cWidth = doc.clientWidth + [top, bottom] = if bRect.top + bRect.height + mRect.height < cHeight + [bRect.bottom, null] + else + [null, cHeight - bRect.top] + [left, right] = if bRect.left + mRect.width < cWidth + [bRect.left, null] + else + [null, cWidth - bRect.right] + {style} = menu + style.top = "#{top}px" + style.right = "#{right}px" + style.bottom = "#{bottom}px" + style.left = "#{left}px" + if right + $.addClass menu, 'left' + + entry = $ '.entry', menu + # We've removed flexbox, so we don't use order anymore. + # while prevEntry = @findNextEntry entry, -1 + # entry = prevEntry + @focus entry + + menu.focus() + + insertEntry: (entry, parent, data) -> + if typeof entry.open is 'function' + try + return unless entry.open data + catch err + Main.handleErrors + message: "Error in building the #{@type} menu." + error: err + return + $.add parent, entry.el + + return unless entry.subEntries + if submenu = $ '.submenu', entry.el + # Reset sub menu, remove irrelevant entries. + $.rm submenu + submenu = $.el 'div', + className: 'dialog submenu' + for subEntry in entry.subEntries + @insertEntry subEntry, submenu, data + $.add entry.el, submenu + return + + close: => + $.rm @menu + delete @menu + $.rmClass lastToggledButton, 'active' currentMenu = null lastToggledButton = null + $.off d, 'click scroll CloseMenu', @close - constructor: (@type) -> - # XXX AddMenuEntry event is deprecated - $.on d, 'AddMenuEntry', ({detail}) => - return if detail.type isnt @type - delete detail.open - @addEntry detail - @entries = [] + findNextEntry: (entry, direction) -> + entries = [entry.parentNode.children...] + entries.sort (first, second) -> first.style.order - second.style.order + entries[entries.indexOf(entry) + direction] - makeMenu: -> - menu = $.el 'div', - className: 'dialog' - id: 'menu' - tabIndex: 0 - $.on menu, 'click', (e) -> e.stopPropagation() - $.on menu, 'keydown', @keybinds - menu + keybinds: (e) => + entry = $ '.focused', @menu + while subEntry = $ '.focused', entry + entry = subEntry - toggle: (e, button, data) -> - e.preventDefault() - e.stopPropagation() - - if currentMenu - # Close if it's already opened. - # Reopen if we clicked on another button. - previousButton = lastToggledButton - currentMenu.close() - return if previousButton is button - - return unless @entries.length - @open button, data - - open: (button, data) -> - menu = @menu = @makeMenu() - currentMenu = @ - lastToggledButton = button - - @entries.sort (first, second) -> - first.order - second.order - - for entry in @entries - @insertEntry entry, menu, data - - $.addClass lastToggledButton, 'active' - - $.on d, 'click CloseMenu', @close - $.on d, 'scroll', @close unless @type is 'gallery' - $.add button, menu - - # Position - mRect = menu.getBoundingClientRect() - bRect = button.getBoundingClientRect() - bTop = window.scrollY + bRect.top - bLeft = window.scrollX + bRect.left - cHeight = doc.clientHeight - cWidth = doc.clientWidth - [top, bottom] = if bRect.top + bRect.height + mRect.height < cHeight - [bRect.bottom, null] + switch e.keyCode + when 27 # Esc + lastToggledButton.focus() + @close() + when 13, 32 # Enter, Space + entry.click() + when 38 # Up + if next = @findNextEntry entry, -1 + @focus next + when 40 # Down + if next = @findNextEntry entry, +1 + @focus next + when 39 # Right + if (submenu = $ '.submenu', entry) and next = submenu.firstElementChild + while nextPrev = @findNextEntry next, -1 + next = nextPrev + @focus next + when 37 # Left + if next = $.x 'parent::*[contains(@class,"submenu")]/parent::*', entry + @focus next else - [null, cHeight - bRect.top] - [left, right] = if bRect.left + mRect.width < cWidth - [bRect.left, null] - else - [null, cWidth - bRect.right] - {style} = menu - style.top = "#{top}px" - style.right = "#{right}px" - style.bottom = "#{bottom}px" - style.left = "#{left}px" - if right - $.addClass menu, 'left' - - entry = $ '.entry', menu - # We've removed flexbox, so we don't use order anymore. - # while prevEntry = @findNextEntry entry, -1 - # entry = prevEntry - @focus entry - - menu.focus() - - insertEntry: (entry, parent, data) -> - if typeof entry.open is 'function' - try - return unless entry.open data - catch err - Main.handleErrors - message: "Error in building the #{@type} menu." - error: err - return - $.add parent, entry.el - - return unless entry.subEntries - if submenu = $ '.submenu', entry.el - # Reset sub menu, remove irrelevant entries. - $.rm submenu - submenu = $.el 'div', - className: 'dialog submenu' - for subEntry in entry.subEntries - @insertEntry subEntry, submenu, data - $.add entry.el, submenu - return - - close: => - $.rm @menu - delete @menu - $.rmClass lastToggledButton, 'active' - currentMenu = null - lastToggledButton = null - $.off d, 'click scroll CloseMenu', @close - - findNextEntry: (entry, direction) -> - entries = [entry.parentNode.children...] - entries.sort (first, second) -> first.style.order - second.style.order - entries[entries.indexOf(entry) + direction] - - keybinds: (e) => - entry = $ '.focused', @menu - while subEntry = $ '.focused', entry - entry = subEntry - - switch e.keyCode - when 27 # Esc - lastToggledButton.focus() - @close() - when 13, 32 # Enter, Space - entry.click() - when 38 # Up - if next = @findNextEntry entry, -1 - @focus next - when 40 # Down - if next = @findNextEntry entry, +1 - @focus next - when 39 # Right - if (submenu = $ '.submenu', entry) and next = submenu.firstElementChild - while nextPrev = @findNextEntry next, -1 - next = nextPrev - @focus next - when 37 # Left - if next = $.x 'parent::*[contains(@class,"submenu")]/parent::*', entry - @focus next - else - return - - e.preventDefault() - e.stopPropagation() - - onFocus: (e) => - e.stopPropagation() - @focus e.target - - focus: (entry) -> - while focused = $.x 'parent::*/child::*[contains(@class,"focused")]', entry - $.rmClass focused, 'focused' - for focused in $$ '.focused', entry - $.rmClass focused, 'focused' - $.addClass entry, 'focused' - - # Submenu positioning. - return unless submenu = $ '.submenu', entry - sRect = submenu.getBoundingClientRect() - eRect = entry.getBoundingClientRect() - cHeight = doc.clientHeight - cWidth = doc.clientWidth - [top, bottom] = if eRect.top + sRect.height < cHeight - ['0px', 'auto'] - else - ['auto', '0px'] - [left, right] = if eRect.right + sRect.width < cWidth - 150 - ['100%', 'auto'] - else - ['auto', '100%'] - {style} = submenu - style.top = top - style.bottom = bottom - style.left = left - style.right = right - - addEntry: (entry) => - @parseEntry entry - @entries.push entry - - parseEntry: (entry) -> - {el, subEntries} = entry - $.addClass el, 'entry' - $.on el, 'focus mouseover', @onFocus - el.style.order = entry.order or 100 - return unless subEntries - $.addClass el, 'has-submenu' - for subEntry in subEntries - @parseEntry subEntry - return - - dragstart = (e) -> - return if e.type is 'mousedown' and e.button isnt 0 # not LMB - # prevent text selection - e.preventDefault() - if isTouching = e.type is 'touchstart' - e = e.changedTouches[e.changedTouches.length - 1] - # distance from pointer to el edge is constant; calculate it here. - el = $.x 'ancestor::div[contains(@class,"dialog")][1]', @ - rect = el.getBoundingClientRect() - screenHeight = doc.clientHeight - screenWidth = doc.clientWidth - o = { - id: el.id - style: el.style - dx: e.clientX - rect.left - dy: e.clientY - rect.top - height: screenHeight - rect.height - width: screenWidth - rect.width - screenHeight: screenHeight - screenWidth: screenWidth - isTouching: isTouching - } - - [o.topBorder, o.bottomBorder] = if Conf['Header auto-hide'] or not Conf['Fixed Header'] - [0, 0] - else if Conf['Bottom Header'] - [0, Header.bar.getBoundingClientRect().height] - else - [Header.bar.getBoundingClientRect().height, 0] - - if isTouching - o.identifier = e.identifier - o.move = touchmove.bind o - o.up = touchend.bind o - $.on d, 'touchmove', o.move - $.on d, 'touchend touchcancel', o.up - else # mousedown - o.move = drag.bind o - o.up = dragend.bind o - $.on d, 'mousemove', o.move - $.on d, 'mouseup', o.up - - touchmove = (e) -> - for touch in e.changedTouches - if touch.identifier is @identifier - drag.call @, touch return - drag = (e) -> - {clientX, clientY} = e + e.preventDefault() + e.stopPropagation() - left = clientX - @dx - left = if left < 10 - 0 - else if @width - left < 10 - null + onFocus: (e) => + e.stopPropagation() + @focus e.target + + focus: (entry) -> + while focused = $.x 'parent::*/child::*[contains(@class,"focused")]', entry + $.rmClass focused, 'focused' + for focused in $$ '.focused', entry + $.rmClass focused, 'focused' + $.addClass entry, 'focused' + + # Submenu positioning. + return unless submenu = $ '.submenu', entry + sRect = submenu.getBoundingClientRect() + eRect = entry.getBoundingClientRect() + cHeight = doc.clientHeight + cWidth = doc.clientWidth + [top, bottom] = if eRect.top + sRect.height < cHeight + ['0px', 'auto'] else - left / @screenWidth * 100 + '%' - - top = clientY - @dy - top = if top < (10 + @topBorder) - @topBorder + 'px' - else if @height - top < (10 + @bottomBorder) - null + ['auto', '0px'] + [left, right] = if eRect.right + sRect.width < cWidth - 150 + ['100%', 'auto'] else - top / @screenHeight * 100 + '%' - - right = if left is null - 0 - else - null - - bottom = if top is null - @bottomBorder + 'px' - else - null - - {style} = @ - style.left = left - style.right = right + ['auto', '100%'] + {style} = submenu style.top = top style.bottom = bottom + style.left = left + style.right = right - touchend = (e) -> - for touch in e.changedTouches - if touch.identifier is @identifier - dragend.call @ - return + addEntry: (entry) => + @parseEntry entry + @entries.push entry - dragend = -> - if @isTouching - $.off d, 'touchmove', @move - $.off d, 'touchend touchcancel', @up - else # mouseup - $.off d, 'mousemove', @move - $.off d, 'mouseup', @up - $.set "#{@id}.position", @style.cssText + parseEntry: (entry) -> + {el, subEntries} = entry + $.addClass el, 'entry' + $.on el, 'focus mouseover', @onFocus + el.style.order = entry.order or 100 + return unless subEntries + $.addClass el, 'has-submenu' + for subEntry in subEntries + @parseEntry subEntry + return - hoverstart = ({root, el, latestEvent, endEvents, height, cb, noRemove}) -> - o = { - root - el - style: el.style - isImage: el.nodeName in ['IMG', 'VIDEO'] - cb - endEvents - latestEvent - clientHeight: doc.clientHeight - clientWidth: doc.clientWidth - height - noRemove - } - o.hover = hover.bind o - o.hoverend = hoverend.bind o - - o.hover o.latestEvent - new MutationObserver(-> - o.hover o.latestEvent if el.parentNode - ).observe el, {childList: true} - - $.on root, endEvents, o.hoverend - if $.x 'ancestor::div[contains(@class,"inline")][1]', root - $.on d, 'keydown', o.hoverend - $.on root, 'mousemove', o.hover - - # Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=674955 - o.workaround = (e) -> o.hoverend(e) unless root.contains e.target - $.on doc, 'mousemove', o.workaround - - hoverstart.padding = 25 - - hover = (e) -> - @latestEvent = e - height = (@height or @el.offsetHeight) + hoverstart.padding - {clientX, clientY} = e - - top = if @isImage - Math.max 0, clientY * (@clientHeight - height) / @clientHeight - else - Math.max 0, Math.min(@clientHeight - height, clientY - 120) - - threshold = @clientWidth / 2 - threshold = Math.max threshold, @clientWidth - 400 unless @isImage - [left, right] = if clientX <= threshold - [clientX + 45 + 'px', null] - else - [null, @clientWidth - clientX + 45 + 'px'] - - {style} = @ - style.top = top + 'px' - style.left = left - style.right = right - - hoverend = (e) -> - return if e.type is 'keydown' and e.keyCode isnt 13 or e.target.nodeName is "TEXTAREA" - $.rm @el unless @noRemove - $.off @root, @endEvents, @hoverend - $.off d, 'keydown', @hoverend - $.off @root, 'mousemove', @hover - # Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=674955 - $.off doc, 'mousemove', @workaround - @cb.call @ if @cb - - checkbox = (name, text, checked) -> - checked = Conf[name] unless checked? - label = $.el 'label' - input = $.el 'input', {type: 'checkbox', name, checked} - $.add label, [input, $.tn " #{text}"] - label - - return { - dialog: dialog - Menu: Menu - hover: hoverstart - checkbox: checkbox +dragstart = (e) -> + return if e.type is 'mousedown' and e.button isnt 0 # not LMB + # prevent text selection + e.preventDefault() + if isTouching = e.type is 'touchstart' + e = e.changedTouches[e.changedTouches.length - 1] + # distance from pointer to el edge is constant; calculate it here. + el = $.x 'ancestor::div[contains(@class,"dialog")][1]', @ + rect = el.getBoundingClientRect() + screenHeight = doc.clientHeight + screenWidth = doc.clientWidth + o = { + id: el.id + style: el.style + dx: e.clientX - rect.left + dy: e.clientY - rect.top + height: screenHeight - rect.height + width: screenWidth - rect.width + screenHeight: screenHeight + screenWidth: screenWidth + isTouching: isTouching } + + [o.topBorder, o.bottomBorder] = if Conf['Header auto-hide'] or not Conf['Fixed Header'] + [0, 0] + else if Conf['Bottom Header'] + [0, Header.bar.getBoundingClientRect().height] + else + [Header.bar.getBoundingClientRect().height, 0] + + if isTouching + o.identifier = e.identifier + o.move = touchmove.bind o + o.up = touchend.bind o + $.on d, 'touchmove', o.move + $.on d, 'touchend touchcancel', o.up + else # mousedown + o.move = drag.bind o + o.up = dragend.bind o + $.on d, 'mousemove', o.move + $.on d, 'mouseup', o.up + +touchmove = (e) -> + for touch in e.changedTouches + if touch.identifier is @identifier + drag.call @, touch + return + +drag = (e) -> + {clientX, clientY} = e + + left = clientX - @dx + left = if left < 10 + 0 + else if @width - left < 10 + null + else + left / @screenWidth * 100 + '%' + + top = clientY - @dy + top = if top < (10 + @topBorder) + @topBorder + 'px' + else if @height - top < (10 + @bottomBorder) + null + else + top / @screenHeight * 100 + '%' + + right = if left is null + 0 + else + null + + bottom = if top is null + @bottomBorder + 'px' + else + null + + {style} = @ + style.left = left + style.right = right + style.top = top + style.bottom = bottom + +touchend = (e) -> + for touch in e.changedTouches + if touch.identifier is @identifier + dragend.call @ + return + +dragend = -> + if @isTouching + $.off d, 'touchmove', @move + $.off d, 'touchend touchcancel', @up + else # mouseup + $.off d, 'mousemove', @move + $.off d, 'mouseup', @up + $.set "#{@id}.position", @style.cssText + +hoverstart = ({root, el, latestEvent, endEvents, height, cb, noRemove}) -> + o = { + root + el + style: el.style + isImage: el.nodeName in ['IMG', 'VIDEO'] + cb + endEvents + latestEvent + clientHeight: doc.clientHeight + clientWidth: doc.clientWidth + height + noRemove + } + o.hover = hover.bind o + o.hoverend = hoverend.bind o + + o.hover o.latestEvent + new MutationObserver(-> + o.hover o.latestEvent if el.parentNode + ).observe el, {childList: true} + + $.on root, endEvents, o.hoverend + if $.x 'ancestor::div[contains(@class,"inline")][1]', root + $.on d, 'keydown', o.hoverend + $.on root, 'mousemove', o.hover + + # Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=674955 + o.workaround = (e) -> o.hoverend(e) unless root.contains e.target + $.on doc, 'mousemove', o.workaround + +hoverstart.padding = 25 + +hover = (e) -> + @latestEvent = e + height = (@height or @el.offsetHeight) + hoverstart.padding + {clientX, clientY} = e + + top = if @isImage + Math.max 0, clientY * (@clientHeight - height) / @clientHeight + else + Math.max 0, Math.min(@clientHeight - height, clientY - 120) + + threshold = @clientWidth / 2 + threshold = Math.max threshold, @clientWidth - 400 unless @isImage + [left, right] = if clientX <= threshold + [clientX + 45 + 'px', null] + else + [null, @clientWidth - clientX + 45 + 'px'] + + {style} = @ + style.top = top + 'px' + style.left = left + style.right = right + +hoverend = (e) -> + return if e.type is 'keydown' and e.keyCode isnt 13 or e.target.nodeName is "TEXTAREA" + $.rm @el unless @noRemove + $.off @root, @endEvents, @hoverend + $.off d, 'keydown', @hoverend + $.off @root, 'mousemove', @hover + # Workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=674955 + $.off doc, 'mousemove', @workaround + @cb.call @ if @cb + +checkbox = (name, text, checked) -> + checked = Conf[name] unless checked? + label = $.el 'label' + input = $.el 'input', {type: 'checkbox', name, checked} + $.add label, [input, $.tn " #{text}"] + label + +return { + dialog: dialog + Menu: Menu + hover: hoverstart + checkbox: checkbox +} diff --git a/src/Images/FappeTyme.coffee b/src/Images/FappeTyme.coffee index fdcd46d8e..cda1a96e6 100644 --- a/src/Images/FappeTyme.coffee +++ b/src/Images/FappeTyme.coffee @@ -49,3 +49,5 @@ FappeTyme = toggle: (type) -> @set type, !@enabled[type] $.cb.checked.call @nodes[type] if type is 'werk' + +return FappeTyme diff --git a/src/Images/Gallery.coffee b/src/Images/Gallery.coffee index c3c33110a..3915f53f7 100644 --- a/src/Images/Gallery.coffee +++ b/src/Images/Gallery.coffee @@ -368,3 +368,5 @@ Gallery = subEntries.push el: delayLabel subEntries + +return Gallery diff --git a/src/Images/ImageCommon.coffee b/src/Images/ImageCommon.coffee index c8d421543..92fb8f6ff 100644 --- a/src/Images/ImageCommon.coffee +++ b/src/Images/ImageCommon.coffee @@ -88,3 +88,5 @@ ImageCommon = @click() else new Notice 'error', "Could not download #{@href}", 30 + +return ImageCommon diff --git a/src/Images/ImageExpand.coffee b/src/Images/ImageExpand.coffee index cc6e66f08..e33c57791 100644 --- a/src/Images/ImageExpand.coffee +++ b/src/Images/ImageExpand.coffee @@ -302,3 +302,5 @@ ImageExpand = $.event 'change', null, input $.on input, 'change', $.cb.checked el: label + +return ImageExpand diff --git a/src/Images/ImageHover.coffee b/src/Images/ImageHover.coffee index 6845812f4..75008e6f3 100644 --- a/src/Images/ImageHover.coffee +++ b/src/Images/ImageHover.coffee @@ -72,3 +72,5 @@ ImageHover = @src = URL + if @src is URL then '?' + Date.now() else '' else $.rm @ + +return ImageHover diff --git a/src/Images/ImageLoader.coffee b/src/Images/ImageLoader.coffee index 4362f6d19..306eddbb6 100644 --- a/src/Images/ImageLoader.coffee +++ b/src/Images/ImageLoader.coffee @@ -89,3 +89,5 @@ ImageLoader = {thumb} = post.file if Header.isNodeVisible(thumb) or post.nodes.root is qpClone then thumb.play() else thumb.pause() return + +return ImageLoader diff --git a/src/Images/Metadata.coffee b/src/Images/Metadata.coffee index c0581e9ee..19b67a1ac 100644 --- a/src/Images/Metadata.coffee +++ b/src/Images/Metadata.coffee @@ -60,3 +60,5 @@ Metadata = else unless element in [0x8538067, 0x549A966] # Segment, Info i += size null + +return Metadata diff --git a/src/Images/RevealSpoilers.coffee b/src/Images/RevealSpoilers.coffee index e0687ed27..b63163b69 100644 --- a/src/Images/RevealSpoilers.coffee +++ b/src/Images/RevealSpoilers.coffee @@ -17,3 +17,5 @@ RevealSpoilers = thumb.src = @file.thumbURL else thumb.dataset.src = @file.thumbURL + +return RevealSpoilers diff --git a/src/Images/Sauce.coffee b/src/Images/Sauce.coffee index 8c0a2c708..4fa7d75aa 100644 --- a/src/Images/Sauce.coffee +++ b/src/Images/Sauce.coffee @@ -87,3 +87,5 @@ Sauce = name: (post) -> post.file.name '%': -> '%' semi: -> ';' + +return Sauce diff --git a/src/Images/Volume.coffee b/src/Images/Volume.coffee index c13831a15..eb767d6d4 100644 --- a/src/Images/Volume.coffee +++ b/src/Images/Volume.coffee @@ -78,3 +78,5 @@ Volume = volume /= 1.1 if e.deltaY > 0 el.volume = $.minmax volume - 0.1, 0, 1 e.preventDefault() + +return Volume diff --git a/src/Linkification/Embedding.coffee b/src/Linkification/Embedding.coffee index 23b78600f..c5f5126cf 100644 --- a/src/Linkification/Embedding.coffee +++ b/src/Linkification/Embedding.coffee @@ -395,3 +395,5 @@ Embedding = src: a.dataset.href loop: /^https?:\/\/i\.4cdn\.org\//.test a.dataset.href ] + +return Embedding diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index 1b24db01c..2f81a9593 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -155,3 +155,5 @@ Linkify = range.insertNode a a + +return Linkify diff --git a/src/Menu/ArchiveLink.coffee b/src/Menu/ArchiveLink.coffee index 3f75dec91..b5c6fe912 100644 --- a/src/Menu/ArchiveLink.coffee +++ b/src/Menu/ArchiveLink.coffee @@ -51,3 +51,5 @@ ArchiveLink = el: el open: open } + +return ArchiveLink diff --git a/src/Menu/DeleteLink.coffee b/src/Menu/DeleteLink.coffee index 870fc9ddf..3033e515f 100644 --- a/src/Menu/DeleteLink.coffee +++ b/src/Menu/DeleteLink.coffee @@ -132,3 +132,5 @@ DeleteLink = for fileOnly in [false, true] when DeleteLink.auto[+fileOnly][post.fullID] DeleteLink.delete post, fileOnly return + +return DeleteLink diff --git a/src/Menu/DownloadLink.coffee b/src/Menu/DownloadLink.coffee index f5973ae78..3b787d8da 100644 --- a/src/Menu/DownloadLink.coffee +++ b/src/Menu/DownloadLink.coffee @@ -17,3 +17,5 @@ DownloadLink = a.href = file.url a.download = file.name true + +return DownloadLink diff --git a/src/Menu/Menu.coffee b/src/Menu/Menu.coffee index b1b2d7552..b46c03368 100644 --- a/src/Menu/Menu.coffee +++ b/src/Menu/Menu.coffee @@ -31,3 +31,5 @@ Menu = $.on button, 'click', (e) -> Menu.menu.toggle e, @, post button + +return Menu diff --git a/src/Menu/ReportLink.coffee b/src/Menu/ReportLink.coffee index cb666a535..590767032 100644 --- a/src/Menu/ReportLink.coffee +++ b/src/Menu/ReportLink.coffee @@ -32,3 +32,5 @@ ReportLink = id = Date.now() set = "toolbar=0,scrollbars=1,location=0,status=1,menubar=0,resizable=1,#{dims}" window.open url, id, set + +return ReportLink diff --git a/src/Miscellaneous/AntiAutoplay.coffee b/src/Miscellaneous/AntiAutoplay.coffee index a8354e0e3..60d3308ab 100644 --- a/src/Miscellaneous/AntiAutoplay.coffee +++ b/src/Miscellaneous/AntiAutoplay.coffee @@ -31,3 +31,5 @@ AntiAutoplay = object.data = object.data.replace(/\?autoplay=1&?/, '?').replace('&autoplay=1', '') $.addClass object, 'autoplay-removed' return + +return AntiAutoplay diff --git a/src/Miscellaneous/Banner.coffee b/src/Miscellaneous/Banner.coffee index 3bfbf7022..50a2ea594 100644 --- a/src/Miscellaneous/Banner.coffee +++ b/src/Miscellaneous/Banner.coffee @@ -107,3 +107,5 @@ Banner = child.textContent = data.title else Banner.db.delete {boardID: g.BOARD.ID, threadID: className} + +return Banner diff --git a/src/Miscellaneous/CatalogLinks.coffee b/src/Miscellaneous/CatalogLinks.coffee index 72155a6a0..5f23fe174 100644 --- a/src/Miscellaneous/CatalogLinks.coffee +++ b/src/Miscellaneous/CatalogLinks.coffee @@ -86,3 +86,5 @@ CatalogLinks = if g.BOARD.ID is board and g.VIEW is 'index' then '#index' else "/#{board}/#index" else "/#{board}/" + +return CatalogLinks diff --git a/src/Miscellaneous/CustomCSS.coffee b/src/Miscellaneous/CustomCSS.coffee index a6f621793..67e8d0057 100644 --- a/src/Miscellaneous/CustomCSS.coffee +++ b/src/Miscellaneous/CustomCSS.coffee @@ -15,3 +15,5 @@ CustomCSS = unless @style return @addStyle() @style.textContent = Conf['usercss'] + +return CustomCSS diff --git a/src/Miscellaneous/ExpandComment.coffee b/src/Miscellaneous/ExpandComment.coffee index 4935e7ac4..263c99c91 100644 --- a/src/Miscellaneous/ExpandComment.coffee +++ b/src/Miscellaneous/ExpandComment.coffee @@ -71,3 +71,5 @@ ExpandComment = for callback in ExpandComment.callbacks callback.call post return + +return ExpandComment diff --git a/src/Miscellaneous/ExpandThread.coffee b/src/Miscellaneous/ExpandThread.coffee index 344544c7b..738842881 100644 --- a/src/Miscellaneous/ExpandThread.coffee +++ b/src/Miscellaneous/ExpandThread.coffee @@ -103,3 +103,5 @@ ExpandThread = postsCount = postsRoot.length a.textContent = Build.summaryText '-', postsCount, filesCount + +return ExpandThread diff --git a/src/Miscellaneous/FileInfo.coffee b/src/Miscellaneous/FileInfo.coffee index 40cb3fce2..8b98dadb4 100644 --- a/src/Miscellaneous/FileInfo.coffee +++ b/src/Miscellaneous/FileInfo.coffee @@ -48,3 +48,5 @@ FileInfo = r: -> <%= html('${this.file.dimensions || "PDF"}') %> g: -> <%= html('?{this.file.tag}{, ${this.file.tag}}{}') %> '%': -> <%= html('%') %> + +return FileInfo diff --git a/src/Miscellaneous/Flash.coffee b/src/Miscellaneous/Flash.coffee index 22f98ac08..02ed6a4af 100644 --- a/src/Miscellaneous/Flash.coffee +++ b/src/Miscellaneous/Flash.coffee @@ -10,3 +10,5 @@ Flash = if g.VIEW is 'thread' $.global -> window.Main.tid = location.pathname.split(/\/+/)[3] $.global -> window.SWFEmbed.init() + +return Flash diff --git a/src/Miscellaneous/Fourchan.coffee b/src/Miscellaneous/Fourchan.coffee index 9629e3a74..a75086683 100644 --- a/src/Miscellaneous/Fourchan.coffee +++ b/src/Miscellaneous/Fourchan.coffee @@ -73,3 +73,5 @@ Fourchan = $.event 'mathjax', null, @nodes.comment $.on d, 'PostsInserted', cb cb() + +return Fourchan diff --git a/src/Miscellaneous/IDColor.coffee b/src/Miscellaneous/IDColor.coffee index 9d956c3fe..515c48c7b 100644 --- a/src/Miscellaneous/IDColor.coffee +++ b/src/Miscellaneous/IDColor.coffee @@ -47,3 +47,5 @@ IDColor = while i < 8 msg = (msg << 5) - msg + uid.charCodeAt i++ msg + +return IDColor diff --git a/src/Miscellaneous/IDHighlight.coffee b/src/Miscellaneous/IDHighlight.coffee index 759a8b607..52ddcb47b 100644 --- a/src/Miscellaneous/IDHighlight.coffee +++ b/src/Miscellaneous/IDHighlight.coffee @@ -21,3 +21,5 @@ IDHighlight = uniqueID = post.info.uniqueID or post.info.capcode IDHighlight.uniqueID = if IDHighlight.uniqueID is uniqueID then null else uniqueID g.posts.forEach IDHighlight.set + +return IDHighlight diff --git a/src/Miscellaneous/Keybinds.coffee b/src/Miscellaneous/Keybinds.coffee index d9c1adda3..c5db8ef23 100644 --- a/src/Miscellaneous/Keybinds.coffee +++ b/src/Miscellaneous/Keybinds.coffee @@ -324,3 +324,5 @@ Keybinds = focus: (post) -> $.addClass post, 'highlight' + +return Keybinds diff --git a/src/Miscellaneous/Nav.coffee b/src/Miscellaneous/Nav.coffee index 71227374b..1aaabee28 100644 --- a/src/Miscellaneous/Nav.coffee +++ b/src/Miscellaneous/Nav.coffee @@ -77,3 +77,5 @@ Nav = d.body.style.marginBottom = null delete Nav.haveExtra $.off d, 'scroll', Nav.removeExtra + +return Nav diff --git a/src/Miscellaneous/NormalizeURL.coffee b/src/Miscellaneous/NormalizeURL.coffee index f059ef72a..a0ff418f8 100644 --- a/src/Miscellaneous/NormalizeURL.coffee +++ b/src/Miscellaneous/NormalizeURL.coffee @@ -12,3 +12,5 @@ NormalizeURL = pathname = pathname.join '/' if location.pathname isnt pathname history.replaceState history.state, '', "#{location.protocol}//#{location.host}#{pathname}#{location.hash}" + +return NormalizeURL diff --git a/src/Miscellaneous/PSAHiding.coffee b/src/Miscellaneous/PSAHiding.coffee index cd55720d3..6945e7f6e 100644 --- a/src/Miscellaneous/PSAHiding.coffee +++ b/src/Miscellaneous/PSAHiding.coffee @@ -54,3 +54,5 @@ PSAHiding = $.after $.id('globalToggle'), psa PSAHiding.hr?.hidden = PSAHiding.hidden return + +return PSAHiding diff --git a/src/Miscellaneous/RelativeDates.coffee b/src/Miscellaneous/RelativeDates.coffee index e7b1106e2..89e00d2ac 100644 --- a/src/Miscellaneous/RelativeDates.coffee +++ b/src/Miscellaneous/RelativeDates.coffee @@ -119,3 +119,5 @@ RelativeDates = return if data in RelativeDates.stale # We can call RelativeDates.update() multiple times. return if data instanceof Post and !g.posts[data.fullID] # collected post. RelativeDates.stale.push data + +return RelativeDates diff --git a/src/Miscellaneous/RemoveSpoilers.coffee b/src/Miscellaneous/RemoveSpoilers.coffee index 47ee75a8d..f15c8516f 100644 --- a/src/Miscellaneous/RemoveSpoilers.coffee +++ b/src/Miscellaneous/RemoveSpoilers.coffee @@ -26,3 +26,5 @@ RemoveSpoilers = $.replace spoiler, span $.add span, [spoiler.childNodes...] return + +return RemoveSpoilers diff --git a/src/Miscellaneous/Report.coffee b/src/Miscellaneous/Report.coffee index 3910fb7f2..a81e25984 100644 --- a/src/Miscellaneous/Report.coffee +++ b/src/Miscellaneous/Report.coffee @@ -65,3 +65,5 @@ Report = if types = $.id('reportTypes') $.on types, 'change', (e) -> $('form').action = if e.target.value is 'illegal' then '#redirect' else '' + +return Report diff --git a/src/Miscellaneous/ThreadLinks.coffee b/src/Miscellaneous/ThreadLinks.coffee index fcaa01998..36a701e3a 100644 --- a/src/Miscellaneous/ThreadLinks.coffee +++ b/src/Miscellaneous/ThreadLinks.coffee @@ -18,3 +18,5 @@ ThreadLinks = process: (link) -> link.target = '_blank' + +return ThreadLinks diff --git a/src/Miscellaneous/Time.coffee b/src/Miscellaneous/Time.coffee index 8e9128ea6..3b195e61c 100644 --- a/src/Miscellaneous/Time.coffee +++ b/src/Miscellaneous/Time.coffee @@ -62,3 +62,5 @@ Time = y: -> @getFullYear().toString()[2..] Y: -> @getFullYear() '%': -> '%' + +return Time diff --git a/src/Monitoring/Favicon.coffee b/src/Monitoring/Favicon.coffee index 34886e467..fe3aa800b 100644 --- a/src/Monitoring/Favicon.coffee +++ b/src/Monitoring/Favicon.coffee @@ -80,3 +80,5 @@ Favicon = dead: 'data:image/gif;base64,<%= readBase64("src/Monitoring/Favicon/dead.gif") %>' logo: 'data:image/png;base64,<%= readBase64("src/meta/icon128.png") %>' + +return Favicon diff --git a/src/Monitoring/MarkNewIPs.coffee b/src/Monitoring/MarkNewIPs.coffee index f9c52b4c8..6f6bcdfa2 100644 --- a/src/Monitoring/MarkNewIPs.coffee +++ b/src/Monitoring/MarkNewIPs.coffee @@ -40,3 +40,5 @@ MarkNewIPs = markOld: (post) -> post.nodes.nameBlock.title = 'Not the first post from this IP.' $.addClass post.nodes.root, 'old-ip' + +return MarkNewIPs diff --git a/src/Monitoring/ReplyPruning.coffee b/src/Monitoring/ReplyPruning.coffee index 491362d0e..1cf4199fa 100644 --- a/src/Monitoring/ReplyPruning.coffee +++ b/src/Monitoring/ReplyPruning.coffee @@ -119,3 +119,5 @@ ReplyPruning = else Build.summaryText '-', ReplyPruning.total, ReplyPruning.totalFiles ReplyPruning.summary.hidden = (ReplyPruning.total <= +Conf["Max Replies"]) + +return ReplyPruning diff --git a/src/Monitoring/ThreadExcerpt.coffee b/src/Monitoring/ThreadExcerpt.coffee index f0f4ca545..b002648ad 100644 --- a/src/Monitoring/ThreadExcerpt.coffee +++ b/src/Monitoring/ThreadExcerpt.coffee @@ -6,3 +6,5 @@ ThreadExcerpt = name: 'Thread Excerpt' cb: @node node: -> d.title = Get.threadExcerpt @ + +return ThreadExcerpt diff --git a/src/Monitoring/ThreadStats.coffee b/src/Monitoring/ThreadStats.coffee index e579bc542..216b0b22c 100644 --- a/src/Monitoring/ThreadStats.coffee +++ b/src/Monitoring/ThreadStats.coffee @@ -103,3 +103,5 @@ ThreadStats = if g.BOARD.ID isnt 'f' and ThreadStats.lastPost > ThreadStats.lastPageUpdate and ThreadStats.pageCountEl?.textContent isnt '1' clearTimeout ThreadStats.timeout ThreadStats.timeout = setTimeout ThreadStats.fetchPage, 5 * $.SECOND + +return ThreadStats diff --git a/src/Monitoring/ThreadUpdater.coffee b/src/Monitoring/ThreadUpdater.coffee index f3f8a5714..f8bd6655a 100644 --- a/src/Monitoring/ThreadUpdater.coffee +++ b/src/Monitoring/ThreadUpdater.coffee @@ -356,3 +356,5 @@ ThreadUpdater = postCount: OP.replies + 1 fileCount: OP.images + !!OP.fsize ipCount: OP.unique_ips + +return ThreadUpdater diff --git a/src/Monitoring/ThreadWatcher.coffee b/src/Monitoring/ThreadWatcher.coffee index 3b8ddc122..2546c9815 100644 --- a/src/Monitoring/ThreadWatcher.coffee +++ b/src/Monitoring/ThreadWatcher.coffee @@ -482,3 +482,5 @@ ThreadWatcher = $.on input, 'change', ThreadWatcher.refresh if name in ['Current Board', 'Show Unread Count'] $.on input, 'change', ThreadWatcher.fetchAuto if name in ['Show Unread Count', 'Auto Update Thread Watcher'] entry + +return ThreadWatcher diff --git a/src/Monitoring/Unread.coffee b/src/Monitoring/Unread.coffee index 43f7f4693..ae9918aa3 100644 --- a/src/Monitoring/Unread.coffee +++ b/src/Monitoring/Unread.coffee @@ -252,3 +252,5 @@ Unread = Favicon[if isDead then 'dead' else 'default'] # `favicon.href = href` doesn't work on Firefox. $.add d.head, Favicon.el + +return Unread diff --git a/src/Posting/Captcha.coffee b/src/Posting/Captcha.coffee deleted file mode 100644 index 5bcab40bb..000000000 --- a/src/Posting/Captcha.coffee +++ /dev/null @@ -1 +0,0 @@ -Captcha = {} diff --git a/src/Posting/Captcha.js b/src/Posting/Captcha.js new file mode 100644 index 000000000..50b0d7038 --- /dev/null +++ b/src/Posting/Captcha.js @@ -0,0 +1 @@ +Captcha = {}; diff --git a/src/Posting/PassLink.coffee b/src/Posting/PassLink.coffee index e518e86bb..7f5bbe8bc 100644 --- a/src/Posting/PassLink.coffee +++ b/src/Posting/PassLink.coffee @@ -14,3 +14,5 @@ PassLink = Date.now() 'width=500,height=280,toolbar=0' $.before styleSelector.previousSibling, [passLink, $.tn('\u00A0\u00A0')] + +return PassLink diff --git a/src/Posting/PostSuccessful.coffee b/src/Posting/PostSuccessful.coffee index ca791b7e5..982341c83 100644 --- a/src/Posting/PostSuccessful.coffee +++ b/src/Posting/PostSuccessful.coffee @@ -16,3 +16,5 @@ PostSuccessful = threadID: threadID postID: postID val: true + +return PostSuccessful diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 8eef9cf60..ef23864f6 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -827,3 +827,5 @@ QR = QR.cooldown.auto = false QR.notifications.push new Notice 'info', 'QR upload aborted.', 5 QR.status() + +return QR diff --git a/src/Quotelinks/QuoteBacklink.coffee b/src/Quotelinks/QuoteBacklink.coffee index 1250ac728..ed5e3c73c 100644 --- a/src/Quotelinks/QuoteBacklink.coffee +++ b/src/Quotelinks/QuoteBacklink.coffee @@ -58,3 +58,5 @@ QuoteBacklink = getContainer: (id) -> @containers[id] or= $.el 'span', className: 'container' + +return QuoteBacklink diff --git a/src/Quotelinks/QuoteCT.coffee b/src/Quotelinks/QuoteCT.coffee index 97563787c..076865fc7 100644 --- a/src/Quotelinks/QuoteCT.coffee +++ b/src/Quotelinks/QuoteCT.coffee @@ -23,3 +23,5 @@ QuoteCT = if boardID is board.ID and threadID isnt thread.ID $.add quotelink, $.tn QuoteCT.text return + +return QuoteCT diff --git a/src/Quotelinks/QuoteInline.coffee b/src/Quotelinks/QuoteInline.coffee index b62e87cbc..7f9162de0 100644 --- a/src/Quotelinks/QuoteInline.coffee +++ b/src/Quotelinks/QuoteInline.coffee @@ -110,3 +110,5 @@ QuoteInline = QuoteInline.rm inlined, boardID, threadID, postID, context $.rmClass inlined, 'inlined' return + +return QuoteInline diff --git a/src/Quotelinks/QuoteOP.coffee b/src/Quotelinks/QuoteOP.coffee index 7a4a02612..482993ab9 100644 --- a/src/Quotelinks/QuoteOP.coffee +++ b/src/Quotelinks/QuoteOP.coffee @@ -34,3 +34,5 @@ QuoteOP = if "#{boardID}.#{postID}" is fullID $.add quotelink, $.tn QuoteOP.text return + +return QuoteOP diff --git a/src/Quotelinks/QuotePreview.coffee b/src/Quotelinks/QuotePreview.coffee index b443f7d0c..3e8e5a271 100644 --- a/src/Quotelinks/QuotePreview.coffee +++ b/src/Quotelinks/QuotePreview.coffee @@ -53,3 +53,5 @@ QuotePreview = for post in [post].concat post.clones $.rmClass post.nodes.post, 'qphl' return + +return QuotePreview diff --git a/src/Quotelinks/QuoteStrikeThrough.coffee b/src/Quotelinks/QuoteStrikeThrough.coffee index e566da9bf..a22afbb86 100644 --- a/src/Quotelinks/QuoteStrikeThrough.coffee +++ b/src/Quotelinks/QuoteStrikeThrough.coffee @@ -14,3 +14,5 @@ QuoteStrikeThrough = if g.posts["#{boardID}.#{postID}"]?.isHidden $.addClass quotelink, 'filtered' return + +return QuoteStrikeThrough diff --git a/src/Quotelinks/QuoteThreading.coffee b/src/Quotelinks/QuoteThreading.coffee index 3f30297a4..a1da9d1d4 100644 --- a/src/Quotelinks/QuoteThreading.coffee +++ b/src/Quotelinks/QuoteThreading.coffee @@ -146,3 +146,5 @@ QuoteThreading = Unread.setLine true Unread.read() Unread.update() + +return QuoteThreading diff --git a/src/Quotelinks/QuoteYou.coffee b/src/Quotelinks/QuoteYou.coffee index 7041382b4..989cad04a 100644 --- a/src/Quotelinks/QuoteYou.coffee +++ b/src/Quotelinks/QuoteYou.coffee @@ -72,3 +72,5 @@ QuoteYou = Header.scrollTo post $.addClass post, 'highlight' return true + +return QuoteYou diff --git a/src/Quotelinks/Quotify.coffee b/src/Quotelinks/Quotify.coffee index 50a3cec8b..958597c33 100644 --- a/src/Quotelinks/Quotify.coffee +++ b/src/Quotelinks/Quotify.coffee @@ -84,3 +84,5 @@ Quotify = $.before deadlink, green $.add green, deadlink $.replace deadlink, [deadlink.childNodes...] + +return Quotify diff --git a/src/classes/Board.coffee b/src/classes/Board.coffee index 7f811d463..270171533 100644 --- a/src/classes/Board.coffee +++ b/src/classes/Board.coffee @@ -6,3 +6,5 @@ class Board @posts = new SimpleDict() g.boards[@] = @ + +return Board diff --git a/src/classes/Callbacks.coffee b/src/classes/Callbacks.coffee index d5292175a..38c556bc5 100644 --- a/src/classes/Callbacks.coffee +++ b/src/classes/Callbacks.coffee @@ -21,3 +21,5 @@ class Callbacks error: err Main.handleErrors errors if errors + +return Callbacks diff --git a/src/classes/CatalogThread.coffee b/src/classes/CatalogThread.coffee index 041692a67..ba2c3ce6f 100644 --- a/src/classes/CatalogThread.coffee +++ b/src/classes/CatalogThread.coffee @@ -13,3 +13,5 @@ class CatalogThread pageCount: $ '.page-count', root comment: $ '.comment', root @thread.catalogView = @ + +return CatalogThread diff --git a/src/classes/Connection.coffee b/src/classes/Connection.coffee index fc2c001be..810f3341e 100644 --- a/src/classes/Connection.coffee +++ b/src/classes/Connection.coffee @@ -20,3 +20,5 @@ class Connection for type, value of data @cb[type]? value return + +return Connection diff --git a/src/classes/DataBoard.coffee b/src/classes/DataBoard.coffee index d810a3071..1890a4234 100644 --- a/src/classes/DataBoard.coffee +++ b/src/classes/DataBoard.coffee @@ -105,3 +105,5 @@ class DataBoard onSync: (data) => @data = data or boards: {} @sync?() + +return DataBoard diff --git a/src/classes/Fetcher.coffee b/src/classes/Fetcher.coffee index 938745798..25a48de91 100644 --- a/src/classes/Fetcher.coffee +++ b/src/classes/Fetcher.coffee @@ -200,3 +200,5 @@ class Fetcher '[/moot]': <%= html('') %> '[banned]': <%= html('') %> '[/banned]': <%= html('') %> + +return Fetcher diff --git a/src/classes/Notice.coffee b/src/classes/Notice.coffee index 6478c1e94..fea553941 100644 --- a/src/classes/Notice.coffee +++ b/src/classes/Notice.coffee @@ -30,3 +30,5 @@ class Notice $.off d, 'visibilitychange', @add $.rm @el @onclose?() + +return Notice diff --git a/src/classes/Post.coffee b/src/classes/Post.coffee index ebd7a2f5e..9bda3a6e5 100644 --- a/src/classes/Post.coffee +++ b/src/classes/Post.coffee @@ -268,3 +268,5 @@ class Post for clone in @clones[index..] clone.nodes.root.dataset.clone = index++ return + +return Post diff --git a/src/classes/RandomAccessList.coffee b/src/classes/RandomAccessList.coffee index b37fe246a..7143d6aba 100644 --- a/src/classes/RandomAccessList.coffee +++ b/src/classes/RandomAccessList.coffee @@ -87,3 +87,5 @@ class RandomAccessList next.prev = prev else @last = prev + +return RandomAccessList diff --git a/src/classes/ShimSet.coffee b/src/classes/ShimSet.coffee index b48d6e160..599834c75 100644 --- a/src/classes/ShimSet.coffee +++ b/src/classes/ShimSet.coffee @@ -14,3 +14,5 @@ class ShimSet @size-- window.Set = ShimSet unless 'Set' of window + +return ShimSet diff --git a/src/classes/SimpleDict.coffee b/src/classes/SimpleDict.coffee index 6c6b3edfd..f9c354e09 100644 --- a/src/classes/SimpleDict.coffee +++ b/src/classes/SimpleDict.coffee @@ -16,3 +16,5 @@ class SimpleDict forEach: (fn) -> fn @[key] for key in [@keys...] return + +return SimpleDict diff --git a/src/classes/Thread.coffee b/src/classes/Thread.coffee index d142a39f4..1330e8240 100644 --- a/src/classes/Thread.coffee +++ b/src/classes/Thread.coffee @@ -76,3 +76,5 @@ class Thread @posts.forEach (post) -> post.collect() g.threads.rm @fullID @board.threads.rm @ + +return Thread diff --git a/src/config/Config.coffee b/src/config/Config.coffee index 89f514fc8..4a4191f7a 100644 --- a/src/config/Config.coffee +++ b/src/config/Config.coffee @@ -1022,3 +1022,5 @@ Config = 'Max Replies': 1000 'Autohiding Scrollbar': false + +return Config diff --git a/src/main/Main.coffee b/src/main/Main.coffee index 00779148e..c9f335e51 100644 --- a/src/main/Main.coffee +++ b/src/main/Main.coffee @@ -470,4 +470,4 @@ Main = <% } %> ] -Main.init() +return Main diff --git a/src/main/Main.init.js b/src/main/Main.init.js new file mode 100644 index 000000000..3685b061a --- /dev/null +++ b/src/main/Main.init.js @@ -0,0 +1 @@ +Main.init(); diff --git a/src/platform/$$.coffee b/src/platform/$$.coffee index 4c54223ab..8f7b773a6 100644 --- a/src/platform/$$.coffee +++ b/src/platform/$$.coffee @@ -1,2 +1,2 @@ -$$ = (selector, root=d.body) -> +return (selector, root=d.body) -> [root.querySelectorAll(selector)...] diff --git a/src/platform/$.coffee b/src/platform/$.coffee index 0d661d064..8efc55ad3 100644 --- a/src/platform/$.coffee +++ b/src/platform/$.coffee @@ -593,3 +593,5 @@ $.clear = (cb) -> $.delete $.listValues().map (key) -> key.replace g.NAMESPACE, '' cb?() <% } %> + +return $ diff --git a/src/platform/CrossOrigin.coffee b/src/platform/CrossOrigin.coffee index 920f7cc28..65419f977 100644 --- a/src/platform/CrossOrigin.coffee +++ b/src/platform/CrossOrigin.coffee @@ -1,15 +1,15 @@ -CrossOrigin = do -> - <% if (type === 'crx') { %> - eventPageRequest = do -> - callbacks = [] - chrome.runtime.onMessage.addListener (data) -> - callbacks[data.id] data - delete callbacks[data.id] - (url, responseType, cb) -> - chrome.runtime.sendMessage {url, responseType}, (id) -> - callbacks[id] = cb - <% } %> +<% if (type === 'crx') { %> +eventPageRequest = do -> + callbacks = [] + chrome.runtime.onMessage.addListener (data) -> + callbacks[data.id] data + delete callbacks[data.id] + (url, responseType, cb) -> + chrome.runtime.sendMessage {url, responseType}, (id) -> + callbacks[id] = cb +<% } %> +CrossOrigin = binary: (url, cb, headers={}) -> # XXX https://forums.lanik.us/viewtopic.php?f=64&t=24173&p=78310 url = url.replace /^((?:https?:)?\/\/(?:\w+\.)?4c(?:ha|d)n\.org)\/adv\//, '$1//adv/' @@ -126,3 +126,5 @@ CrossOrigin = do -> delete callbacks[url] responses[url] = response <% } %> + +return CrossOrigin diff --git a/tools/chain.js b/tools/chain.js index bcce51f2a..dc2452221 100644 --- a/tools/chain.js +++ b/tools/chain.js @@ -1,7 +1,6 @@ var fs = require('fs'); var template = require('./template'); var coffee = require('coffee-script'); -var globalize = require('./globalize'); for (var name of process.argv.slice(2)) { try { @@ -12,8 +11,8 @@ for (var name of process.argv.slice(2)) { script = template(script, {type: parts[2]}); if (/\.coffee$/.test(basename)) { script = coffee.compile(script); - if (/^([$A-Z][$\w]*)\.coffee$/.test(basename)) { - script = globalize.globalize(script, [parts[3]]); + if (/^[$A-Z][$\w]*$/.test(parts[3])) { + script = `${parts[3]} = ${script}`; } } fs.writeFileSync(name, script); diff --git a/tools/globalize.js b/tools/globalize.js deleted file mode 100644 index 2802fac11..000000000 --- a/tools/globalize.js +++ /dev/null @@ -1,57 +0,0 @@ -var fs = require('fs'); - -function getNames(part) { - var basename = part.split('_')[0]; // e.g. template_crx -> template - var sources = fs.readdirSync(`src/${basename}`); - - // Extract variables to be made global from source file list - // e.g. ImageExpand from src/Images/ImageExpand.coffee - // but not QR.post or eventPage - var names = []; - for (var f of sources) { - var m = f.match(/^([$A-Z][$\w]*)\.coffee$/); - if (m) names.push(m[1]); - } - return names; -} - -function globalize(script, names) { - var replaced = 0; - - script = script.replace( - - // matches declaration at the start of the function, not including helper function assignments - /^( *var )(.*)(,\n *|;\n)/m, - - function(declaration, v, n, e) { - replaced++; - var n0 = names.sort().join(', '); - if (n0 !== n) throw new Error(`expected variables (${n0}) found (${n})`); - return (e[0] === ',') ? v : ''; - } - - ); - - if (replaced !== 1) { - throw new Error(`no declaration found`); - } - - return script; -} - -module.exports = { - getNames: getNames, - globalize: globalize -}; - -if (require.main === module) { - (function() { - for (var part of process.argv.slice(2)) { - var filename = `tmp/${part}.js`; - var names = getNames(part); - var script = fs.readFileSync(filename, 'utf8').replace(/\r\n/g, '\n'); - script = globalize(script, names); - fs.writeFileSync(filename, script); - } - })(); -}