diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index fda0e0e1b..05b2836cc 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -1878,7 +1878,7 @@ SimpleDict.prototype.forEach = function(fn) { var key, _i, _len, _ref, _results; - _ref = __slice.call(this.keys); + _ref = this.keys; _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { key = _ref[_i]; @@ -11304,17 +11304,26 @@ if (g.VIEW === 'thread' || !Conf['Thread Expansion']) { return; } - return $.on(d, 'IndexRefresh', this.onIndexRefresh); + return $.on(d, (Conf['JSON Navigation'] ? 'IndexRefresh' : '4chanXInitFinished'), this.onIndexRefresh); }, setButton: function(thread) { - var a; - if (!(a = $.x('following-sibling::a[contains(@class,"summary")][1]', thread.OP.nodes.root))) { + var a, summary; + if (!(summary = $.x('following-sibling::*[contains(@class,"summary")][1]', thread.OP.nodes.root))) { return; } - a.textContent = ExpandThread.text.apply(ExpandThread, ['+'].concat(__slice.call(a.textContent.match(/\d+/g)))); - return $.on(a, 'click', ExpandThread.cbToggle); + a = $.el('a', { + textContent: ExpandThread.text.apply(ExpandThread, ['+'].concat(__slice.call(summary.textContent.match(/\d+/g)))), + href: "" + thread.board.ID + "/res/" + thread.ID, + className: 'summary' + }); + $.on(a, 'click', ExpandThread.cbToggle); + return $.replace(summary, a); }, - disconnect: function(refresh) { + disconnect: function() { + this.refresh(); + return $.off(d, 'IndexRefresh', this.onIndexRefresh); + }, + refresh: function(disconnect) { var status, threadID, _ref, _ref1; if (g.VIEW === 'thread' || !Conf['Thread Expansion']) { return; @@ -11327,12 +11336,9 @@ } delete ExpandThread.statuses[threadID]; } - if (!refresh) { - return $.off(d, 'IndexRefresh', this.onIndexRefresh); - } }, onIndexRefresh: function() { - ExpandThread.disconnect(true); + ExpandThread.refresh(); return g.BOARD.threads.forEach(function(thread) { return ExpandThread.setButton(thread); }); diff --git a/builds/crx/script.js b/builds/crx/script.js index 6b4c8da19..cdf3f7e00 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1933,7 +1933,7 @@ SimpleDict.prototype.forEach = function(fn) { var key, _i, _len, _ref, _results; - _ref = __slice.call(this.keys); + _ref = this.keys; _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { key = _ref[_i]; @@ -11318,17 +11318,26 @@ if (g.VIEW === 'thread' || !Conf['Thread Expansion']) { return; } - return $.on(d, 'IndexRefresh', this.onIndexRefresh); + return $.on(d, (Conf['JSON Navigation'] ? 'IndexRefresh' : '4chanXInitFinished'), this.onIndexRefresh); }, setButton: function(thread) { - var a; - if (!(a = $.x('following-sibling::a[contains(@class,"summary")][1]', thread.OP.nodes.root))) { + var a, summary; + if (!(summary = $.x('following-sibling::*[contains(@class,"summary")][1]', thread.OP.nodes.root))) { return; } - a.textContent = ExpandThread.text.apply(ExpandThread, ['+'].concat(__slice.call(a.textContent.match(/\d+/g)))); - return $.on(a, 'click', ExpandThread.cbToggle); + a = $.el('a', { + textContent: ExpandThread.text.apply(ExpandThread, ['+'].concat(__slice.call(summary.textContent.match(/\d+/g)))), + href: "" + thread.board.ID + "/res/" + thread.ID, + className: 'summary' + }); + $.on(a, 'click', ExpandThread.cbToggle); + return $.replace(summary, a); }, - disconnect: function(refresh) { + disconnect: function() { + this.refresh(); + return $.off(d, 'IndexRefresh', this.onIndexRefresh); + }, + refresh: function(disconnect) { var status, threadID, _ref, _ref1; if (g.VIEW === 'thread' || !Conf['Thread Expansion']) { return; @@ -11341,12 +11350,9 @@ } delete ExpandThread.statuses[threadID]; } - if (!refresh) { - return $.off(d, 'IndexRefresh', this.onIndexRefresh); - } }, onIndexRefresh: function() { - ExpandThread.disconnect(true); + ExpandThread.refresh(); return g.BOARD.threads.forEach(function(thread) { return ExpandThread.setButton(thread); }); diff --git a/src/General/lib/simpledict.class b/src/General/lib/simpledict.class index 48baac2af..229e27ba0 100644 --- a/src/General/lib/simpledict.class +++ b/src/General/lib/simpledict.class @@ -13,4 +13,4 @@ class SimpleDict @keys.splice i, 1 delete @[key] - forEach: (fn) -> fn @[key] for key in [@keys...] + forEach: (fn) -> fn @[key] for key in @keys diff --git a/src/Miscellaneous/ExpandThread.coffee b/src/Miscellaneous/ExpandThread.coffee index 7a6866f52..c01e9e7bb 100755 --- a/src/Miscellaneous/ExpandThread.coffee +++ b/src/Miscellaneous/ExpandThread.coffee @@ -2,23 +2,30 @@ ExpandThread = statuses: {} init: -> return if g.VIEW is 'thread' or !Conf['Thread Expansion'] - $.on d, 'IndexRefresh', @onIndexRefresh + $.on d, (if Conf['JSON Navigation'] then 'IndexRefresh' else '4chanXInitFinished'), @onIndexRefresh setButton: (thread) -> - return unless a = $.x 'following-sibling::a[contains(@class,"summary")][1]', thread.OP.nodes.root - a.textContent = ExpandThread.text '+', a.textContent.match(/\d+/g)... + return unless summary = $.x 'following-sibling::*[contains(@class,"summary")][1]', thread.OP.nodes.root + a = $.el 'a', + textContent: ExpandThread.text '+', summary.textContent.match(/\d+/g)... + href: "#{thread.board.ID}/res/#{thread.ID}" + className: 'summary' $.on a, 'click', ExpandThread.cbToggle - - disconnect: (refresh) -> + $.replace summary, a + + disconnect: -> + @refresh() + $.off d, 'IndexRefresh', @onIndexRefresh + + refresh: (disconnect) -> return if g.VIEW is 'thread' or !Conf['Thread Expansion'] for threadID, status of ExpandThread.statuses status.req?.abort() delete ExpandThread.statuses[threadID] - - $.off d, 'IndexRefresh', @onIndexRefresh unless refresh + return onIndexRefresh: -> - ExpandThread.disconnect true + ExpandThread.refresh() g.BOARD.threads.forEach (thread) -> ExpandThread.setButton thread