From 720998721b63bc2923722248d0644f20a08dc771 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Fri, 20 Nov 2015 00:06:18 -0800 Subject: [PATCH] Parenthesize assignments in if conditions. --- src/Posting/Captcha.replace.coffee | 8 ++++---- src/Posting/Captcha.v2.coffee | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Posting/Captcha.replace.coffee b/src/Posting/Captcha.replace.coffee index d3e46d1d9..cbd58269d 100644 --- a/src/Posting/Captcha.replace.coffee +++ b/src/Posting/Captcha.replace.coffee @@ -32,7 +32,7 @@ Captcha.replace = v1: -> return unless $.id 'g-recaptcha' Captcha.v1.replace() - if link = $.id 'form-link' + if (link = $.id 'form-link') $.on link, 'click', -> Captcha.v1.create() else if location.hostname is 'boards.4chan.org' form = $.id 'postForm' @@ -41,7 +41,7 @@ Captcha.replace = Captcha.v1.create() v2: -> - return unless old = $.id 'captchaContainerAlt' + return unless (old = $.id 'captchaContainerAlt') container = $.el 'div', className: 'g-recaptcha' $.extend container.dataset, @@ -49,14 +49,14 @@ Captcha.replace = tabindex: 3 $.replace old, container url = 'https://www.google.com/recaptcha/api.js' - if lang = Conf['captchaLanguage'].trim() + if (lang = Conf['captchaLanguage'].trim()) url += "?hl=#{encodeURIComponent lang}" script = $.el 'script', src: url $.add d.head, script iframe: (el) -> - return unless lang = Conf['captchaLanguage'].trim() + return unless (lang = Conf['captchaLanguage'].trim()) src = if /[?&]hl=/.test el.src el.src.replace(/([?&]hl=)[^&]*/, '$1' + encodeURIComponent lang) else diff --git a/src/Posting/Captcha.v2.coffee b/src/Posting/Captcha.v2.coffee index 5153d21b4..0541a1c46 100644 --- a/src/Posting/Captcha.v2.coffee +++ b/src/Posting/Captcha.v2.coffee @@ -3,9 +3,9 @@ Captcha.v2 = init: -> return if d.cookie.indexOf('pass_enabled=1') >= 0 - return unless @isEnabled = !!$ '#g-recaptcha, #captchaContainerAlt' + return unless (@isEnabled = !!$ '#g-recaptcha, #captchaContainerAlt') - if @noscript = Conf['Force Noscript Captcha'] or not Main.jsEnabled + if (@noscript = Conf['Force Noscript Captcha'] or not Main.jsEnabled) @conn = new Connection null, "#{location.protocol}//www.google.com", token: (token) => @save true, token $.addClass QR.nodes.el, 'noscript-captcha' @@ -38,7 +38,7 @@ Captcha.v2 = childList: true initFrame: -> - if token = $('.fbc-verification-token > textarea')?.value + if (token = $('.fbc-verification-token > textarea')?.value) conn = new Connection window.parent, "#{location.protocol}//boards.4chan.org" conn.send {token} @@ -47,7 +47,7 @@ Captcha.v2 = noscriptURL: -> url = '//www.google.com/recaptcha/api/fallback?k=<%= meta.recaptchaKey %>' - if lang = Conf['captchaLanguage'].trim() + if (lang = Conf['captchaLanguage'].trim()) url += "&hl=#{encodeURIComponent lang}" url @@ -131,8 +131,8 @@ Captcha.v2 = afterSetup: (mutations) -> for mutation in mutations for node in mutation.addedNodes - @setupIFrame iframe if iframe = $.x './descendant-or-self::iframe', node - @setupTextArea textarea if textarea = $.x './descendant-or-self::textarea', node + @setupIFrame iframe if (iframe = $.x './descendant-or-self::iframe', node) + @setupTextArea textarea if (textarea = $.x './descendant-or-self::textarea', node) return setupIFrame: (iframe) -> @@ -171,7 +171,7 @@ Captcha.v2 = getOne: -> @clear() - if captcha = @captchas.shift() + if (captcha = @captchas.shift()) $.set 'captchas', @captchas @count() captcha @@ -240,7 +240,7 @@ Captcha.v2 = new MutationObserver(@fixBubble.bind(@, node)).observe node, attributes: true # Prevent Recaptcha from keeping focus when popup dismissed. - if overlay = $ 'div[style*="position: fixed;"]', node + if (overlay = $ 'div[style*="position: fixed;"]', node) $.on overlay, 'click', -> $('#qr iframe')?.blur() fixBubble: (node) ->