diff --git a/src/Archive/Redirect.coffee b/src/Archive/Redirect.coffee index 8d2e72dbe5..fb847bc842 100644 --- a/src/Archive/Redirect.coffee +++ b/src/Archive/Redirect.coffee @@ -139,7 +139,7 @@ Redirect = if type is 'capcode' value = {'Developer': 'dev'}[value] or value.toLowerCase() else if type is 'image' - value = value.replace /[+/=]/g, (c) -> {'+': '-', '/': '_', '=': ''}[c] + value = value.replace /[+/=]/g, (c) -> ({'+': '-', '/': '_', '=': ''})[c] value = encodeURIComponent value path = if archive.software is 'foolfuuka' "#{boardID}/search/#{type}/#{value}/" diff --git a/src/Filtering/Filter.coffee b/src/Filtering/Filter.coffee index 96b387a08a..d86817c902 100644 --- a/src/Filtering/Filter.coffee +++ b/src/Filtering/Filter.coffee @@ -11,7 +11,7 @@ Filter = for line in Conf[key].split '\n' continue if line[0] is '#' - unless regexp = line.match /\/(.+)\/(\w*)/ + if not (regexp = line.match /\/(.+)\/(\w*)/) continue # Don't mix up filter flags with the regular expression. diff --git a/src/Filtering/PostHiding.coffee b/src/Filtering/PostHiding.coffee index 3b64fa6617..3bcde4d1dc 100644 --- a/src/Filtering/PostHiding.coffee +++ b/src/Filtering/PostHiding.coffee @@ -84,7 +84,7 @@ PostHiding = open: (post) -> if !post.isReply or post.isClone or !post.isHidden return false - unless data = PostHiding.db.get {boardID: post.board.ID, threadID: post.thread.ID, postID: post.ID} + if not (data = PostHiding.db.get {boardID: post.board.ID, threadID: post.thread.ID, postID: post.ID}) return false PostHiding.menu.post = post thisPost.firstChild.checked = post.isHidden @@ -104,7 +104,7 @@ PostHiding = open: (post) -> if !post.isReply or post.isClone or !post.isHidden return false - unless data = PostHiding.db.get {boardID: post.board.ID, threadID: post.thread.ID, postID: post.ID} + if not (data = PostHiding.db.get {boardID: post.board.ID, threadID: post.thread.ID, postID: post.ID}) return false PostHiding.menu.post = post diff --git a/src/Filtering/Recursive.coffee b/src/Filtering/Recursive.coffee index 902fce8b7f..b0cb145fa9 100644 --- a/src/Filtering/Recursive.coffee +++ b/src/Filtering/Recursive.coffee @@ -14,14 +14,15 @@ Recursive = return add: (recursive, post, args...) -> - obj = Recursive.recursives[post.fullID] or= + obj = Recursive.recursives[post.fullID] or= { recursives: [] args: [] + } obj.recursives.push recursive obj.args.push args rm: (recursive, post) -> - return unless obj = Recursive.recursives[post.fullID] + return if not (obj = Recursive.recursives[post.fullID]) for rec, i in obj.recursives when rec is recursive obj.recursives.splice i, 1 obj.args.splice i, 1 diff --git a/src/Filtering/ThreadHiding.coffee b/src/Filtering/ThreadHiding.coffee index 908c52335b..a16939c309 100644 --- a/src/Filtering/ThreadHiding.coffee +++ b/src/Filtering/ThreadHiding.coffee @@ -22,10 +22,11 @@ ThreadHiding = @hiddenThreads = JSON.parse(localStorage.getItem "4chan-hide-t-#{g.BOARD}") or {} Main.ready -> # 4chan's catalog sets the style to "display: none;" when hiding or unhiding a thread. - new MutationObserver(ThreadHiding.catalogSave).observe $.id('threads'), + new MutationObserver(ThreadHiding.catalogSave).observe $.id('threads'), { attributes: true subtree: true attributeFilter: ['style'] + } catalogSave: -> hiddenThreads2 = JSON.parse(localStorage.getItem "4chan-hide-t-#{g.BOARD}") or {} @@ -78,7 +79,7 @@ ThreadHiding = return false ThreadHiding.menu.thread = thread true - subEntries: [el: apply; el: makeStub] + subEntries: [{el: apply}, {el: makeStub}] div = $.el 'a', className: 'show-thread-link' diff --git a/src/General/Build.Test.coffee b/src/General/Build.Test.coffee index 6142e65e00..9a9224edd8 100644 --- a/src/General/Build.Test.coffee +++ b/src/General/Build.Test.coffee @@ -105,7 +105,7 @@ Build.Test = testAll: -> g.posts.forEach (post) -> unless post.isClone or post.isFetchedQuote - unless (abbr = $ '.abbr', post.nodes.comment) and /Comment too long\./.test(abbr.textContent) + if not ((abbr = $ '.abbr', post.nodes.comment) and /Comment too long\./.test(abbr.textContent)) Build.Test.testOne post return diff --git a/src/General/Get.coffee b/src/General/Get.coffee index dceb0b36a9..004011645d 100644 --- a/src/General/Get.coffee +++ b/src/General/Get.coffee @@ -1,7 +1,7 @@ Get = threadExcerpt: (thread) -> {OP} = thread - excerpt = "/#{thread.board}/ - " + ( + excerpt = ("/#{thread.board}/ - ") + ( OP.info.subject?.trim() or OP.info.commentDisplay.replace(/\n+/g, ' // ') or OP.file?.name or diff --git a/src/General/Header.coffee b/src/General/Header.coffee index 9f589094b3..0789fa93fc 100644 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -246,7 +246,7 @@ Header = a.textContent = if /-title/.test(t) or /-replace/.test(t) and boardID is g.BOARD.ID a.title or a.textContent else if /-full/.test t - "/#{boardID}/" + (if a.title then " - #{a.title}" else '') + ("/#{boardID}/") + (if a.title then " - #{a.title}" else '') else text or boardID diff --git a/src/General/Index.coffee b/src/General/Index.coffee index c6ad914586..077198e383 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -638,7 +638,7 @@ Index = buildReplies: (threads) -> posts = [] for thread in threads - continue unless (lastReplies = Index.liveThreadDict[thread.ID].last_replies) + continue if not (lastReplies = Index.liveThreadDict[thread.ID].last_replies) nodes = [] for data in lastReplies if (post = thread.posts[data.no]) and not post.isFetchedQuote @@ -681,7 +681,7 @@ Index = buildCatalogReplies: (threads) -> for thread in threads {nodes} = thread.catalogView - continue unless (lastReplies = Index.liveThreadDict[thread.ID].last_replies) + continue if not (lastReplies = Index.liveThreadDict[thread.ID].last_replies) if nodes.replies # RelativeDates will stop updating elements if they go out of document. @@ -816,7 +816,7 @@ Index = Index.pageLoad false querySearch: (query) -> - return unless keywords = query.toLowerCase().match /\S+/g + return if not (keywords = query.toLowerCase().match /\S+/g) Index.sortedThreads.filter (thread) -> Index.searchMatch thread, keywords diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee index 9b36de87ba..4ade581205 100644 --- a/src/General/Settings.coffee +++ b/src/General/Settings.coffee @@ -206,7 +206,7 @@ Settings = $('input[type=file]', @parentNode).click() onImport: -> - return unless file = @files[0] + return if not (file = @files[0]) @value = null output = $('.imp-exp-result') unless confirm 'Your current settings will be entirely overwritten, are you sure?' @@ -530,10 +530,11 @@ Settings = for {uid, name, boards, files, software} in Conf['archives'] continue unless software in ['fuuka', 'foolfuuka'] for boardID in boards - o = archBoards[boardID] or= + o = archBoards[boardID] or= { thread: [] post: [] file: [] + } archive = [uid ? name, name] o.thread.push archive o.post.push archive if software is 'foolfuuka' @@ -546,10 +547,11 @@ Settings = className: "board-#{boardID}" row.hidden = boardID isnt g.BOARD.ID - boardOptions.push $.el 'option', + boardOptions.push $.el 'option', { textContent: "/#{boardID}/" value: "board-#{boardID}" selected: boardID is g.BOARD.ID + } o = archBoards[boardID] $.add row, Settings.addArchiveCell boardID, o, item for item in ['thread', 'post', 'file'] @@ -587,13 +589,14 @@ Settings = i = 0 while i < length archive = data[type][i++] - options.push $.el 'option', + options.push $.el 'option', { value: JSON.stringify archive[0] textContent: archive[1] + } $.extend td, <%= html('') %> select = td.firstElementChild - unless select.disabled = length is 1 + if not (select.disabled = (length is 1)) # XXX GM can't into datasets select.setAttribute 'data-boardid', boardID select.setAttribute 'data-type', type diff --git a/src/General/UI.coffee b/src/General/UI.coffee index 4c7ccd2b7a..1214619cc0 100644 --- a/src/General/UI.coffee +++ b/src/General/UI.coffee @@ -153,7 +153,7 @@ class Menu if next = @findNextEntry entry, +1 @focus next when 39 # Right - if (submenu = $ '.submenu', entry) and next = submenu.firstElementChild + if (submenu = $ '.submenu', entry) and (next = submenu.firstElementChild) while nextPrev = @findNextEntry next, -1 next = nextPrev @focus next @@ -178,7 +178,7 @@ class Menu $.addClass entry, 'focused' # Submenu positioning. - return unless submenu = $ '.submenu', entry + return if not (submenu = $ '.submenu', entry) sRect = submenu.getBoundingClientRect() eRect = entry.getBoundingClientRect() cHeight = doc.clientHeight diff --git a/src/Images/Gallery.coffee b/src/Images/Gallery.coffee index 46d2a1e3c8..aaf21bbbbf 100644 --- a/src/Images/Gallery.coffee +++ b/src/Images/Gallery.coffee @@ -1,6 +1,6 @@ Gallery = init: -> - return unless @enabled = Conf['Gallery'] and g.VIEW in ['index', 'thread'] and g.BOARD.ID isnt 'f' + return if not (@enabled = (Conf['Gallery'] and g.VIEW in ['index', 'thread'] and g.BOARD.ID isnt 'f')) @delay = Conf['Slide Delay'] @@ -236,7 +236,7 @@ Gallery = cb: keybinds: (e) -> - return unless key = Keybinds.keyCode e + return if not (key = Keybinds.keyCode e) cb = switch key when Conf['Close'], Conf['Open Gallery'] diff --git a/src/Images/ImageCommon.coffee b/src/Images/ImageCommon.coffee index 4ee9bb1328..4b8b7396fe 100644 --- a/src/Images/ImageCommon.coffee +++ b/src/Images/ImageCommon.coffee @@ -27,7 +27,7 @@ ImageCommon = decodeError: (file, post) -> return false unless file.error?.code is MediaError.MEDIA_ERR_DECODE - unless message = $ '.warning', post.file.thumb.parentNode + if not (message = $ '.warning', post.file.thumb.parentNode) message = $.el 'div', className: 'warning' $.after post.file.thumb, message message.textContent = 'Error: Corrupt or unplayable video' @@ -35,9 +35,10 @@ ImageCommon = error: (file, post, delay, cb) -> src = post.file.url.split '/' - URL = Redirect.to 'file', + URL = Redirect.to 'file', { boardID: post.board.ID filename: src[src.length - 1] + } unless Conf['404 Redirect'] and URL and Redirect.securityCheck URL URL = null diff --git a/src/Images/ImageExpand.coffee b/src/Images/ImageExpand.coffee index c7a0501f4d..52175374cb 100644 --- a/src/Images/ImageExpand.coffee +++ b/src/Images/ImageExpand.coffee @@ -1,6 +1,6 @@ ImageExpand = init: -> - return unless @enabled = Conf['Image Expansion'] and g.VIEW in ['index', 'thread'] and g.BOARD.ID isnt 'f' + return if not (@enabled = (Conf['Image Expansion'] and g.VIEW in ['index', 'thread'] and g.BOARD.ID isnt 'f')) @EAI = $.el 'a', className: 'expand-all-shortcut fa fa-expand' diff --git a/src/Images/Sauce.coffee b/src/Images/Sauce.coffee index f0b3cde66c..daf14d4b81 100644 --- a/src/Images/Sauce.coffee +++ b/src/Images/Sauce.coffee @@ -19,7 +19,7 @@ Sauce = cb: @node createSauceLink: (link, post) -> - return null unless link = link.trim() + return null if not (link = link.trim()) parts = {} for part, i in link.split /;(?=(?:text|boards|types|sandbox):?)/ @@ -60,7 +60,7 @@ Sauce = nodes = [] skipped = [] for link in Sauce.links - unless (node = Sauce.createSauceLink link, @) + if not (node = Sauce.createSauceLink link, @) node = Sauce.link.cloneNode false skipped.push [link, node] nodes.push $.tn(' '), node diff --git a/src/Images/Volume.coffee b/src/Images/Volume.coffee index ef5a7a498e..c2f8eb91c1 100644 --- a/src/Images/Volume.coffee +++ b/src/Images/Volume.coffee @@ -71,7 +71,7 @@ Volume = wheel: (e) -> return if e.shiftKey or e.altKey or e.ctrlKey or e.metaKey - return unless el = $ 'video:not([data-md5])', @ + return if not (el = $ 'video:not([data-md5])', @) return if el.muted or not $.hasAudio el volume = el.volume + 0.1 volume *= 1.1 if e.deltaY < 0 diff --git a/src/Linkification/Embedding.coffee b/src/Linkification/Embedding.coffee index c996a7c7ba..f1c8297cbc 100644 --- a/src/Linkification/Embedding.coffee +++ b/src/Linkification/Embedding.coffee @@ -91,7 +91,7 @@ Embedding = title: (data) -> {key, uid, options, link, post} = data - return unless service = Embedding.types[key].title + return if not (service = Embedding.types[key].title) $.addClass link, key.toLowerCase() if service.batchSize (service.queue or= []).push data @@ -117,7 +117,7 @@ Embedding = click: (e) -> e.preventDefault() if Conf['Floating Embeds'] or $.hasClass(doc, 'catalog-mode') - return unless div = Embedding.media.firstChild + return if not (div = Embedding.media.firstChild) $.replace div, Embedding.cb.embed @ Embedding.lastEmbed = Get.postFromNode(@).nodes.root $.rmClass Embedding.dialog, 'empty' diff --git a/src/Miscellaneous/ExpandComment.coffee b/src/Miscellaneous/ExpandComment.coffee index 4935e7ac4b..91cfe17dc3 100644 --- a/src/Miscellaneous/ExpandComment.coffee +++ b/src/Miscellaneous/ExpandComment.coffee @@ -24,7 +24,7 @@ ExpandComment = $.replace post.nodes.shortComment, post.nodes.longComment post.nodes.comment = post.nodes.longComment return - return unless a = $ '.abbr > a', post.nodes.comment + return if not (a = $ '.abbr > a', post.nodes.comment) a.textContent = "Post No.#{post} Loading..." $.cache "//a.4cdn.org#{a.pathname.split(/\/+/).splice(0,4).join('/')}.json", -> ExpandComment.parse @, a, post diff --git a/src/Miscellaneous/ExpandThread.coffee b/src/Miscellaneous/ExpandThread.coffee index 9fbee18c73..9bd383e8a7 100644 --- a/src/Miscellaneous/ExpandThread.coffee +++ b/src/Miscellaneous/ExpandThread.coffee @@ -1,7 +1,7 @@ ExpandThread = statuses: {} init: -> - return unless g.VIEW is 'index' and Conf['Thread Expansion'] + return if not (g.VIEW is 'index' and Conf['Thread Expansion']) if Conf['JSON Index'] $.on d, 'IndexRefreshInternal', @onIndexRefresh else @@ -10,7 +10,7 @@ ExpandThread = cb: -> ExpandThread.setButton @ setButton: (thread) -> - return unless thread.nodes.root and (a = $ '.summary', thread.nodes.root) + return if not (thread.nodes.root and (a = $ '.summary', thread.nodes.root)) a.textContent = Build.summaryText '+', a.textContent.match(/\d+/g)... a.style.cursor = 'pointer' $.on a, 'click', ExpandThread.cbToggle @@ -35,7 +35,7 @@ ExpandThread = toggle: (thread) -> threadRoot = thread.nodes.root - return unless a = $ '.summary', threadRoot + return if not (a = $ '.summary', threadRoot) if thread.ID of ExpandThread.statuses ExpandThread.contract thread, a, threadRoot else diff --git a/src/Miscellaneous/Fourchan.coffee b/src/Miscellaneous/Fourchan.coffee index 4557b8a563..5365c6f1ad 100644 --- a/src/Miscellaneous/Fourchan.coffee +++ b/src/Miscellaneous/Fourchan.coffee @@ -4,8 +4,8 @@ Fourchan = if g.BOARD.ID is 'g' $.on window, 'prettyprint:cb', (e) -> - return unless post = g.posts[e.detail.ID] - return unless pre = $$('.prettyprint', post.nodes.comment)[e.detail.i] + return if not (post = g.posts[e.detail.ID]) + return if not (pre = $$('.prettyprint', post.nodes.comment)[e.detail.i]) unless $.hasClass pre, 'prettyprinted' pre.innerHTML = e.detail.html $.addClass pre, 'prettyprinted' diff --git a/src/Miscellaneous/Keybinds.coffee b/src/Miscellaneous/Keybinds.coffee index 7dc4c14780..f1e3179318 100644 --- a/src/Miscellaneous/Keybinds.coffee +++ b/src/Miscellaneous/Keybinds.coffee @@ -17,7 +17,7 @@ Keybinds = Conf[hotkey] = key keydown: (e) -> - return unless key = Keybinds.keyCode e + return if not (key = Keybinds.keyCode e) {target} = e if target.nodeName in ['INPUT', 'TEXTAREA'] return unless /(Esc|Alt|Ctrl|Meta|Shift\+\w{2,})/.test(key) and not /^Alt\+(\d|Up|Down|Left|Right)$/.test(key) @@ -272,7 +272,7 @@ Keybinds = value[selEnd..] # Move the caret to the end of the selection. - range = "[#{tag}]".length + selEnd + range = ("[#{tag}]").length + selEnd ta.setSelectionRange range, range # Fire the 'input' event @@ -314,7 +314,7 @@ Keybinds = 'following' else 'preceding' - return unless next = $.x "#{axis}-sibling::div[contains(@class,'replyContainer') and not(@hidden) and not(child::div[@class='stub'])][1]/child::div[contains(@class,'reply')]", root + return if not (next = $.x "#{axis}-sibling::div[contains(@class,'replyContainer') and not(@hidden) and not(child::div[@class='stub'])][1]/child::div[contains(@class,'reply')]", root) Header.scrollToIfNeeded next, delta is +1 @focus next $.rmClass postEl, 'highlight' diff --git a/src/Miscellaneous/PSAHiding.coffee b/src/Miscellaneous/PSAHiding.coffee index cd55720d3c..b0947e4d21 100644 --- a/src/Miscellaneous/PSAHiding.coffee +++ b/src/Miscellaneous/PSAHiding.coffee @@ -5,7 +5,7 @@ PSAHiding = $.one d, '4chanXInitFinished', @setup setup: -> - unless psa = PSAHiding.psa = $.id 'globalMessage' + if not (psa = PSAHiding.psa = $.id 'globalMessage') $.rmClass doc, 'hide-announcement' return if (hr = $.id('globalToggle')?.previousElementSibling) and hr.nodeName is 'HR' diff --git a/src/Miscellaneous/Report.coffee b/src/Miscellaneous/Report.coffee index 83078b1106..79b21d58c4 100644 --- a/src/Miscellaneous/Report.coffee +++ b/src/Miscellaneous/Report.coffee @@ -1,6 +1,6 @@ Report = init: -> - return unless (match = location.search.match /\bno=(\d+)/) + return if not (match = location.search.match /\bno=(\d+)/) Captcha.replace.init() @postID = +match[1] $.ready @ready @@ -20,6 +20,6 @@ Report = Report.fit 'body' fit: (selector) -> - return unless (el = $ selector, doc) and getComputedStyle(el).visibility isnt 'hidden' + return if not ((el = $ selector, doc) and getComputedStyle(el).visibility isnt 'hidden') dy = el.getBoundingClientRect().bottom - doc.clientHeight + 8 window.resizeBy 0, dy if dy > 0 diff --git a/src/Monitoring/Favicon.coffee b/src/Monitoring/Favicon.coffee index 467ccf7ad5..e108b0dbc7 100644 --- a/src/Monitoring/Favicon.coffee +++ b/src/Monitoring/Favicon.coffee @@ -1,6 +1,6 @@ Favicon = init: -> - $.asap (-> d.head and Favicon.el = $ 'link[rel="shortcut icon"]', d.head), Favicon.initAsap + $.asap (-> d.head and (Favicon.el = $ 'link[rel="shortcut icon"]', d.head)), Favicon.initAsap initAsap: -> Favicon.el.type = 'image/x-icon' diff --git a/src/Posting/Captcha.replace.coffee b/src/Posting/Captcha.replace.coffee index db691b7b4d..d5aa5a6fa6 100644 --- a/src/Posting/Captcha.replace.coffee +++ b/src/Posting/Captcha.replace.coffee @@ -26,7 +26,7 @@ Captcha.replace = $.onExists doc, 'iframe', Captcha.replace.iframe noscript: -> - return unless (original = $ '#g-recaptcha, #captchaContainerAlt') and (noscript = $ 'noscript') + return if not ((original = $ '#g-recaptcha, #captchaContainerAlt') and (noscript = $ 'noscript')) span = $.el 'span', id: 'captcha-forced-noscript' $.replace noscript, span diff --git a/src/Posting/Captcha.v1.coffee b/src/Posting/Captcha.v1.coffee index 3a7f33d75d..0647921b09 100644 --- a/src/Posting/Captcha.v1.coffee +++ b/src/Posting/Captcha.v1.coffee @@ -3,7 +3,7 @@ Captcha.v1 = init: -> return if d.cookie.indexOf('pass_enabled=1') >= 0 - return unless @isEnabled = !!$ '#g-recaptcha, #captchaContainerAlt' + return if not (@isEnabled = !!$ '#g-recaptcha, #captchaContainerAlt') imgContainer = $.el 'div', className: 'captcha-img' @@ -40,7 +40,7 @@ Captcha.v1 = replace: -> return if @script - unless @script = $ 'script[src="//www.google.com/recaptcha/api/js/recaptcha_ajax.js"]', d.head + if not (@script = $ 'script[src="//www.google.com/recaptcha/api/js/recaptcha_ajax.js"]', d.head) @script = $.el 'script', src: '//www.google.com/recaptcha/api/js/recaptcha_ajax.js' $.add d.head, @script @@ -113,7 +113,7 @@ Captcha.v1 = @nodes.input.focus() afterSetup: -> - return unless challenge = $.id 'recaptcha_challenge_field_holder' + return if not (challenge = $.id 'recaptcha_challenge_field_holder') return if challenge is QR.captcha.nodes.challenge setLifetime = (e) -> QR.captcha.lifetime = e.detail @@ -192,7 +192,7 @@ Captcha.v1 = @nodes.img.src = @blank return return unless @nodes.challenge.firstChild - return unless challenge_image = $.id 'recaptcha_challenge_image' + return if not (challenge_image = $.id 'recaptcha_challenge_image') # -1 minute to give upload some time. @timeout = Date.now() + @lifetime * $.SECOND - $.MINUTE challenge = @nodes.challenge.firstChild.value diff --git a/src/Posting/Captcha.v2.coffee b/src/Posting/Captcha.v2.coffee index ebedfeb5b6..95513c578e 100644 --- a/src/Posting/Captcha.v2.coffee +++ b/src/Posting/Captcha.v2.coffee @@ -3,7 +3,7 @@ Captcha.v2 = init: -> return if d.cookie.indexOf('pass_enabled=1') >= 0 - return unless (@isEnabled = !!$ '#g-recaptcha, #captchaContainerAlt, #captcha-forced-noscript') + return if not (@isEnabled = !!$ '#g-recaptcha, #captchaContainerAlt, #captcha-forced-noscript') if (@noscript = Conf['Force Noscript Captcha'] or not Main.jsEnabled) $.addClass QR.nodes.el, 'noscript-captcha' diff --git a/src/Posting/PassLink.coffee b/src/Posting/PassLink.coffee index e518e86bb2..a95ca92d58 100644 --- a/src/Posting/PassLink.coffee +++ b/src/Posting/PassLink.coffee @@ -4,7 +4,7 @@ PassLink = Main.ready @ready ready: -> - return unless (styleSelector = $.id 'styleSelector') + return if not (styleSelector = $.id 'styleSelector') passLink = $.el 'span', className: 'brackets-wrap pass-link-container' diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index af80ea9c87..a4b8d4a899 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -536,7 +536,7 @@ QR = i = 0 save = -> QR.selected.save @ while name = items[i++] - continue unless node = nodes[name] + continue if not (node = nodes[name]) event = if node.nodeName is 'SELECT' then 'change' else 'input' $.on nodes[name], event, save diff --git a/src/Posting/QR.oekaki.coffee b/src/Posting/QR.oekaki.coffee index df476febce..f1daaf97d5 100644 --- a/src/Posting/QR.oekaki.coffee +++ b/src/Posting/QR.oekaki.coffee @@ -51,9 +51,10 @@ QR.oekaki = window.Tegaki.flatten().toBlob (file) -> source = "oekaki-#{Date.now()}" FCX.oekakiLatest = source - document.dispatchEvent new CustomEvent 'QRSetFile', + document.dispatchEvent new CustomEvent 'QRSetFile', { bubbles: true detail: {file, name: FCX.oekakiName, source} + } if window.Tegaki document.querySelector('#qr .oekaki').hidden = false @@ -101,9 +102,10 @@ QR.oekaki = name = document.getElementById('qr-filename').value.replace(/\.\w+$/, '') + '.png' {source} = document.getElementById('file-n-submit').dataset error = (content) -> - document.dispatchEvent new CustomEvent 'CreateNotification', + document.dispatchEvent new CustomEvent 'CreateNotification', { bubbles: true detail: {type: 'warning', content, lifetime: 20} + } cb = (e) -> document.removeEventListener 'QRFile', cb, false return error 'No file to edit.' unless e.detail diff --git a/src/Posting/QR.persona.coffee b/src/Posting/QR.persona.coffee index f15a05363f..5bf9c9123a 100644 --- a/src/Posting/QR.persona.coffee +++ b/src/Posting/QR.persona.coffee @@ -13,7 +13,7 @@ QR.persona = parseItem: (item) -> return if item[0] is '#' - return unless match = item.match /(name|options|email|subject|password):"(.*)"/i + return if not (match = item.match /(name|options|email|subject|password):"(.*)"/i) [match, type, val] = match # Don't mix up item settings with val. diff --git a/src/Posting/QR.post.coffee b/src/Posting/QR.post.coffee index f77596d06e..1a0ca443b9 100644 --- a/src/Posting/QR.post.coffee +++ b/src/Posting/QR.post.coffee @@ -104,7 +104,7 @@ QR.post = class # Load this post's values. for name in ['thread', 'name', 'email', 'sub', 'com', 'filename'] - continue unless node = QR.nodes[name] + continue if not (node = QR.nodes[name]) node.value = @[name] or node.dataset.default or '' (if @thread isnt 'new' then $.addClass else $.rmClass) QR.nodes.el, 'reply-to-thread' @@ -140,7 +140,7 @@ QR.post = class # Do this in case people use extensions # that do not trigger the `input` event. for name in ['thread', 'name', 'email', 'sub', 'com', 'filename', 'spoiler'] - continue unless node = QR.nodes[name] + continue if not (node = QR.nodes[name]) @save node return diff --git a/src/Quotelinks/QuoteBacklink.coffee b/src/Quotelinks/QuoteBacklink.coffee index 995cc568dd..1b11de07c0 100644 --- a/src/Quotelinks/QuoteBacklink.coffee +++ b/src/Quotelinks/QuoteBacklink.coffee @@ -26,7 +26,7 @@ QuoteBacklink = a = $.el 'a', href: Build.postURL @board.ID, @thread.ID, @ID className: if @isHidden then 'filtered backlink' else 'backlink' - textContent: Conf['backlink'].replace(/%(?:id|%)/g, (x) => {'%id': @ID, '%%': '%'}[x]) + textContent: Conf['backlink'].replace(/%(?:id|%)/g, (x) => ({'%id': @ID, '%%': '%'})[x]) $.add a, QuoteYou.mark.cloneNode(true) if markYours for quote in @quotes containers = [QuoteBacklink.getContainer quote] diff --git a/src/Quotelinks/QuoteInline.coffee b/src/Quotelinks/QuoteInline.coffee index f9c44aa9a4..f690d4b2ea 100644 --- a/src/Quotelinks/QuoteInline.coffee +++ b/src/Quotelinks/QuoteInline.coffee @@ -65,8 +65,10 @@ QuoteInline = $.addClass qroot, 'hasInline' new Fetcher boardID, threadID, postID, inline, quoter - return unless (post = g.posts["#{boardID}.#{postID}"]) and + return if not ( + (post = g.posts["#{boardID}.#{postID}"]) and context.thread is post.thread + ) # Hide forward post if it's a backlink of a post in this thread. # Will only unhide if there's no inlined backlinks of it anymore. @@ -91,7 +93,7 @@ QuoteInline = $.rmClass qroot, 'hasInline' # Stop if it only contains text. - return unless el = root.firstElementChild + return if not (el = root.firstElementChild) # Dereference clone. post = g.posts["#{boardID}.#{postID}"] diff --git a/src/Quotelinks/QuotePreview.coffee b/src/Quotelinks/QuotePreview.coffee index 3f38568b21..d06a99114c 100644 --- a/src/Quotelinks/QuotePreview.coffee +++ b/src/Quotelinks/QuotePreview.coffee @@ -43,7 +43,7 @@ QuotePreview = mouseout: -> # Stop if it only contains text. - return unless root = @el.firstElementChild + return if not (root = @el.firstElementChild) clone = Get.postFromRoot root post = clone.origin diff --git a/src/Quotelinks/QuoteThreading.coffee b/src/Quotelinks/QuoteThreading.coffee index 600aeb636a..6149d8faf9 100644 --- a/src/Quotelinks/QuoteThreading.coffee +++ b/src/Quotelinks/QuoteThreading.coffee @@ -77,9 +77,11 @@ QuoteThreading = posts insert: (post) -> - return false unless Conf['Thread Quotes'] and + return false if not ( + Conf['Thread Quotes'] and (parent = QuoteThreading.parent[post.fullID]) and !QuoteThreading.inserted[post.fullID] + ) descendants = QuoteThreading.descendants post if !Unread.posts.has(parent.ID) diff --git a/src/Quotelinks/QuoteYou.coffee b/src/Quotelinks/QuoteYou.coffee index c6d9ad9c33..6952509891 100644 --- a/src/Quotelinks/QuoteYou.coffee +++ b/src/Quotelinks/QuoteYou.coffee @@ -49,7 +49,7 @@ QuoteYou = $.rmClass highlight, 'highlight' if highlight = $ '.highlight' unless QuoteYou.lastRead and doc.contains(QuoteYou.lastRead) and $.hasClass(QuoteYou.lastRead, 'quotesYou') - unless (post = QuoteYou.lastRead = $ '.quotesYou') + if not (post = QuoteYou.lastRead = $ '.quotesYou') new Notice 'warning', 'No posts are currently quoting you, loser.', 20 return return if QuoteYou.cb.scroll post diff --git a/src/Quotelinks/Quotify.coffee b/src/Quotelinks/Quotify.coffee index 407bd8b2b2..9595678946 100644 --- a/src/Quotelinks/Quotify.coffee +++ b/src/Quotelinks/Quotify.coffee @@ -22,7 +22,7 @@ Quotify = return parseArchivelink: (link) -> - return unless (m = link.pathname.match /^\/([^/]+)\/thread\/S?(\d+)\/?$/) + return if not (m = link.pathname.match /^\/([^/]+)\/thread\/S?(\d+)\/?$/) return if link.hostname is 'boards.4chan.org' boardID = m[1] threadID = m[2] @@ -43,7 +43,7 @@ Quotify = return quote = deadlink.textContent - return unless postID = quote.match(/\d+$/)?[0] + return if not (postID = quote.match(/\d+$/)?[0]) if postID[0] is '0' # Fix quotelinks that start with a `0`. Quotify.fixDeadlink deadlink diff --git a/src/classes/Fetcher.coffee b/src/classes/Fetcher.coffee index 46f8d59aaa..1b5f825c37 100644 --- a/src/classes/Fetcher.coffee +++ b/src/classes/Fetcher.coffee @@ -92,7 +92,7 @@ class Fetcher archivedPost: -> return false unless Conf['Resurrect Quotes'] - return false unless url = Redirect.to 'post', {@boardID, @postID} + return false if not (url = Redirect.to 'post', {@boardID, @postID}) archive = Redirect.data.post[@boardID] if /^https:\/\//.test(url) or location.protocol is 'http:' $.cache url, (e) => diff --git a/src/classes/Post.coffee b/src/classes/Post.coffee index ca863a7035..f5d546ed06 100644 --- a/src/classes/Post.coffee +++ b/src/classes/Post.coffee @@ -14,7 +14,7 @@ class Post @nodes = @parseNodes root - unless (@isReply = $.hasClass @nodes.post, 'reply') + if not (@isReply = $.hasClass @nodes.post, 'reply') @thread.OP = @ @thread.isArchived = !!$ '.archivedIcon', @nodes.info @thread.isSticky = !!$ '.stickyIcon', @nodes.info @@ -163,9 +163,9 @@ class Post parseFile: -> {fileRoot} = @nodes - return unless fileRoot - return unless (link = $ '.fileText > a, .fileText-original > a', fileRoot) - return unless (info = link.nextSibling?.textContent.match /\(([\d.]+ [KMG]?B).*\)/) + return if not fileRoot + return if not (link = $ '.fileText > a, .fileText-original > a', fileRoot) + return if not (info = link.nextSibling?.textContent.match /\(([\d.]+ [KMG]?B).*\)/) fileText = fileRoot.firstElementChild @file = text: fileText @@ -206,7 +206,7 @@ class Post $.rmClass @nodes.root, 'deleted-file' $.addClass @nodes.root, 'deleted-post' - unless (strong = $ 'strong.warning', @nodes.info) + if not (strong = $ 'strong.warning', @nodes.info) strong = $.el 'strong', className: 'warning' $.after $('input', @nodes.info), strong diff --git a/src/classes/Thread.coffee b/src/classes/Thread.coffee index 6e3541fbdc..8bd91a8754 100644 --- a/src/classes/Thread.coffee +++ b/src/classes/Thread.coffee @@ -26,7 +26,7 @@ class Thread setPage: (pageNum) -> {info, reply} = @OP.nodes - unless (icon = $ '.page-num', info) + if not (icon = $ '.page-num', info) icon = $.el 'span', className: 'page-num' $.replace reply.parentNode.previousSibling, [$.tn(' '), icon, $.tn(' ')] icon.title = "This thread is on page #{pageNum} in the original index." diff --git a/src/platform/$.coffee b/src/platform/$.coffee index 59bb4f932e..5179e0275c 100644 --- a/src/platform/$.coffee +++ b/src/platform/$.coffee @@ -4,10 +4,13 @@ $ = (selector, root=d.body) -> root.querySelector selector -$.DAY = 24 * - $.HOUR = 60 * - $.MINUTE = 60 * +$.DAY = 24 * ( + $.HOUR = 60 * ( + $.MINUTE = 60 * ( $.SECOND = 1000 + ) + ) +) $.id = (id) -> d.getElementById id @@ -81,7 +84,7 @@ do -> return req rm = -> delete reqs[url] try - return unless req = $.ajax url, options + return if not (req = $.ajax url, options) catch err return $.on req, 'load', (e) -> @@ -544,7 +547,7 @@ else if GM_deleteValue? or $.hasStorage do -> onChange = ({key, newValue}) -> - return unless cb = $.syncing[key] + return if not (cb = $.syncing[key]) if newValue? return if newValue is $.oldValue[key] $.oldValue[key] = newValue