From 6760d4b948fb0aa4cd0b48d75a5c69c225735b73 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Mon, 3 Mar 2014 00:03:55 -0700 Subject: [PATCH] Fix some issues causing Navigation functions to fail. --- builds/4chan-X.user.js | 20 +++++++++++--------- builds/crx/script.js | 20 +++++++++++--------- src/General/Index.coffee | 1 + src/General/Main.coffee | 2 ++ src/General/Navigate.coffee | 8 +++----- 5 files changed, 28 insertions(+), 23 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 2c3550f7c..03216080a 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -12666,14 +12666,13 @@ $.addClass($("a[href*='/" + boardID + "/']", fullBoardList), 'current'); Header.generateBoardList(Conf['boardnav'].replace(/(\r\n|\n|\r)/g, ' ')); QR.flagsInput(); - return $.cache('//a.4cdn.org/boards.json', function(_arg) { - var aboard, board, err, target, _i, _len, _ref; - target = _arg.target; - if (target.status !== 200) { - return; - } + return $.cache('//a.4cdn.org/boards.json', function() { + var aboard, board, err, _i, _len, _ref; try { - _ref = target.response.boards; + if (this.status !== 200) { + return; + } + _ref = this.response.boards; for (_i = 0, _len = _ref.length; _i < _len; _i++) { aboard = _ref[_i]; if (!(aboard.board === boardID)) { @@ -12690,7 +12689,6 @@ error: err } ]); - return false; } if (!board) { return; @@ -13573,7 +13571,7 @@ return $.ready(Main.initReady); }, initStyle: function() { - var mainStyleSheet, setStyle, style, styleSheets, _ref; + var _ref; $.off(d, '4chanMainInit', Main.initStyle); if (!Main.isThisPageLegit() || $.hasClass(doc, 'fourchan-x')) { return; @@ -13583,6 +13581,10 @@ } $.addClass(doc, 'fourchan-x', 'seaweedchan', g.VIEW, 'gecko'); $.addStyle(Main.css); + return Main.setClass(); + }, + setClass: function() { + var mainStyleSheet, setStyle, style, styleSheets; style = 'yotsuba-b'; mainStyleSheet = $('link[title=switch]', d.head); styleSheets = $$('link[rel="alternate stylesheet"]', d.head); diff --git a/builds/crx/script.js b/builds/crx/script.js index 5658c25a9..ec1adaf25 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -12680,14 +12680,13 @@ $.addClass($("a[href*='/" + boardID + "/']", fullBoardList), 'current'); Header.generateBoardList(Conf['boardnav'].replace(/(\r\n|\n|\r)/g, ' ')); QR.flagsInput(); - return $.cache('//a.4cdn.org/boards.json', function(_arg) { - var aboard, board, err, target, _i, _len, _ref; - target = _arg.target; - if (target.status !== 200) { - return; - } + return $.cache('//a.4cdn.org/boards.json', function() { + var aboard, board, err, _i, _len, _ref; try { - _ref = target.response.boards; + if (this.status !== 200) { + return; + } + _ref = this.response.boards; for (_i = 0, _len = _ref.length; _i < _len; _i++) { aboard = _ref[_i]; if (!(aboard.board === boardID)) { @@ -12704,7 +12703,6 @@ error: err } ]); - return false; } if (!board) { return; @@ -13585,7 +13583,7 @@ return $.ready(Main.initReady); }, initStyle: function() { - var mainStyleSheet, setStyle, style, styleSheets, _ref; + var _ref; $.off(d, '4chanMainInit', Main.initStyle); if (!Main.isThisPageLegit() || $.hasClass(doc, 'fourchan-x')) { return; @@ -13595,6 +13593,10 @@ } $.addClass(doc, 'fourchan-x', 'seaweedchan', g.VIEW, 'blink'); $.addStyle(Main.css); + return Main.setClass(); + }, + setClass: function() { + var mainStyleSheet, setStyle, style, styleSheets; style = 'yotsuba-b'; mainStyleSheet = $('link[title=switch]', d.head); styleSheets = $$('link[rel="alternate stylesheet"]', d.head); diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 270956ed0..76cf3f469 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -526,6 +526,7 @@ Index = return Navigate.title() + Index.board = "#{g.BOARD}" try diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 75c6f67e6..9a7c189d6 100755 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -84,7 +84,9 @@ Main = $('link[href*=mobile]', d.head)?.disabled = true $.addClass doc, 'fourchan-x', 'seaweedchan', g.VIEW, '<% if (type === 'crx') { %>blink<% } else { %>gecko<% } %>' $.addStyle Main.css + Main.setClass() + setClass: -> style = 'yotsuba-b' mainStyleSheet = $ 'link[title=switch]', d.head styleSheets = $$ 'link[rel="alternate stylesheet"]', d.head diff --git a/src/General/Navigate.coffee b/src/General/Navigate.coffee index 335d6b187..19707eb97 100644 --- a/src/General/Navigate.coffee +++ b/src/General/Navigate.coffee @@ -114,11 +114,10 @@ Navigate = QR.flagsInput() - $.cache '//a.4cdn.org/boards.json', ({target}) -> - return unless target.status is 200 - + $.cache '//a.4cdn.org/boards.json', -> try - for aboard in target.response.boards when aboard.board is boardID + return unless @status is 200 + for aboard in @response.boards when aboard.board is boardID board = aboard break @@ -127,7 +126,6 @@ Navigate = message: "Navigation failed to update board name." error: err ] - return false return unless board Navigate.updateTitle board