From eb116cf476809247d797fe8b9a4e37c8f8782ff9 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sat, 18 Jul 2015 10:45:09 -0700 Subject: [PATCH] Simplify usage of Redirect.navigate. --- src/Archive/Redirect.coffee | 12 +++++++----- src/General/Main.coffee | 11 ++++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Archive/Redirect.coffee b/src/Archive/Redirect.coffee index e43889109..d34c3f73c 100755 --- a/src/Archive/Redirect.coffee +++ b/src/Archive/Redirect.coffee @@ -95,11 +95,13 @@ Redirect = location.protocol is 'http:' or Conf['Except Archives from Encryption'] - navigate: (URL, alternative) -> - if URL and ( - Redirect.securityCheck(URL) or - confirm "Redirect to #{URL}?\n\nYour connection will not be encrypted." + navigate: (dest, data, alternative) -> + Redirect.init() unless Redirect.data + url = Redirect.to dest, data + if url and ( + Redirect.securityCheck(url) or + confirm "Redirect to #{url}?\n\nYour connection will not be encrypted." ) - location.replace URL + location.replace url else if alternative location.replace alternative diff --git a/src/General/Main.coffee b/src/General/Main.coffee index ee55361fb..d9ce6e848 100755 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -78,20 +78,17 @@ Main = if /\/imgboard\.php$/.test(location.pathname) and (match = location.search.match /\bres=(\d+)/) $.ready -> if $.id('errmsg')?.textContent is 'Error: Specified thread does not exist.' - Redirect.init() - Redirect.navigate Redirect.to 'thread', + Redirect.navigate 'thread', boardID: g.BOARD.ID postID: +match[1] return when 'i.4cdn.org' $.asap (-> d.readyState isnt 'loading'), -> if Conf['404 Redirect'] and d.title in ['4chan - Temporarily Offline', '4chan - 404 Not Found'] - Redirect.init() pathname = location.pathname.split '/' - URL = Redirect.to 'file', + Redirect.navigate 'file', boardID: g.BOARD.ID filename: pathname[pathname.length - 1] - Redirect.navigate URL else if video = $ 'video' if Conf['Volume in New Tab'] Volume.setup video @@ -169,11 +166,11 @@ Main = if g.VIEW is 'thread' ThreadWatcher.set404 g.BOARD.ID, g.THREADID, -> if Conf['404 Redirect'] - href = Redirect.to 'thread', + Redirect.navigate 'thread', boardID: g.BOARD.ID threadID: g.THREADID postID: +location.hash.match /\d+/ # post number or 0 - Redirect.navigate href, "/#{g.BOARD}/" + , "/#{g.BOARD}/" return # 4chan Pass Link