From 298bed63363fd660c5552122580f4b75ee44f07c Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sun, 2 Mar 2014 21:04:14 -0700 Subject: [PATCH] Reflow a ton of navigate and index shit to fix broken shit Conflicts: builds/4chan-X.user.js builds/crx/script.js src/General/Index.coffee src/General/Navigate.coffee src/Posting/QR.coffee --- src/General/Navigate.coffee | 39 ++++++++++++++++++------------------- src/Posting/QR.coffee | 18 ++++++++--------- 2 files changed, 27 insertions(+), 30 deletions(-) diff --git a/src/General/Navigate.coffee b/src/General/Navigate.coffee index 5ca08e206..75182e89f 100644 --- a/src/General/Navigate.coffee +++ b/src/General/Navigate.coffee @@ -84,31 +84,26 @@ Navigate = error: err ] Main.handleErrors error if error - QR.generatePostableThreadsList() updateContext: (view) -> - g.DEAD = false + g.DEAD = false + g.THREADID = +window.location.pathname.split('/')[3] if view is 'thread' - unless view is g.VIEW - $.rmClass doc, g.VIEW - $.addClass doc, view + return if view is g.VIEW + + $.rmClass doc, g.VIEW + $.addClass doc, view - oldView = g.VIEW - g.VIEW = view { index: -> - return if oldView is g.VIEW delete g.THREADID QR.link.textContent = 'Start a Thread' - $.off d, 'ThreadUpdate', QR.statusCheck - $.on d, 'IndexRefresh', QR.generatePostableThreadsList + thread: -> - g.THREADID = +window.location.pathname.split('/')[3] - return if oldView is g.VIEW QR.link.textContent = 'Reply to Thread' - $.on d, 'ThreadUpdate', QR.statusCheck - $.off d, 'IndexRefresh', QR.generatePostableThreadsList - }[g.VIEW]() + }[view]() + + g.VIEW = view updateBoard: (boardID) -> fullBoardList = $ '#full-board-list', Header.boardList @@ -138,14 +133,16 @@ Navigate = Navigate.updateSFW !!board.ws_board updateSFW: (sfw) -> - # TODO: think of a better name for this. Changes style, too. - Favicon.el.href = "//s.4cdn.org/image/favicon#{if sfw then '-ws' else ''}.ico" - $.add d.head, Favicon.el # Changing the href alone doesn't update the icon on Firefox + Favicon.el.href = Favicon.default = "//s.4cdn.org/image/favicon#{if sfw then '-ws' else ''}.ico" + + # Changing the href alone doesn't update the icon on Firefox + $.add d.head, Favicon.el return if Favicon.SFW is sfw # Board SFW status hasn't changed Favicon.SFW = sfw Favicon.update() + findStyle = (type, base) -> style = d.cookie.match new RegExp "\b#{type}\_style\=([^;]+);\b" return ["#{type}_style", (if style then style[1] else base)] @@ -207,11 +204,12 @@ Navigate = g.BOARD = new Board boardID Navigate.title = -> Navigate.updateBoard boardID + Navigate.updateSFW Favicon.SFW + if view is 'index' return Index.update pageNum - + # Moving from index to thread or thread to thread - Navigate.updateSFW Favicon.SFW {load} = Navigate Navigate.req = $.ajax "//a.4cdn.org/#{boardID}/thread/#{threadID}.json", onabort: load @@ -283,6 +281,7 @@ Navigate = Navigate.ready 'Quote Threading', QuoteThreading.force, Conf['Quote Threading'] and not Conf['Unread Count'] Navigate.buildThread() + QR.generatePostableThreadsList() Header.hashScroll.call window buildThread: -> diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index c943a72b1..8c215b6a6 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -15,7 +15,6 @@ QR = href: 'javascript:;' $.on sc, 'click', -> if Conf['Persistent QR'] or !QR.nodes or QR.nodes.el.hidden - $.event 'CloseMenu' QR.open() QR.nodes.com.focus() $.rmClass @, 'disabled' @@ -70,15 +69,14 @@ QR = $.on d, 'dragover', QR.dragOver $.on d, 'drop', QR.dropFile $.on d, 'dragstart dragend', QR.drag - { - catalog: -> - QR.open() if Conf["Persistent QR"] - QR.hide() if Conf['Auto Hide QR'] - index: -> - $.on d, 'IndexRefresh', QR.generatePostableThreadsList - thread: -> - $.on d, 'ThreadUpdate', QR.statusCheck - }[g.VIEW]() + + # We can thread update and index refresh without loading a new page, so... + $.on d, 'IndexRefresh', QR.generatePostableThreadsList + $.on d, 'ThreadUpdate', QR.statusCheck + + return if !Conf['Persistent QR'] + QR.open() + QR.hide() if Conf['Auto-Hide QR'] statusCheck: -> if g.DEAD