Fix ExpandThread without JSON Navigation
This commit is contained in:
parent
b7585d9cd4
commit
7c28da181b
@ -1878,7 +1878,7 @@
|
|||||||
|
|
||||||
SimpleDict.prototype.forEach = function(fn) {
|
SimpleDict.prototype.forEach = function(fn) {
|
||||||
var key, _i, _len, _ref, _results;
|
var key, _i, _len, _ref, _results;
|
||||||
_ref = __slice.call(this.keys);
|
_ref = this.keys;
|
||||||
_results = [];
|
_results = [];
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
key = _ref[_i];
|
key = _ref[_i];
|
||||||
@ -11304,17 +11304,26 @@
|
|||||||
if (g.VIEW === 'thread' || !Conf['Thread Expansion']) {
|
if (g.VIEW === 'thread' || !Conf['Thread Expansion']) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return $.on(d, 'IndexRefresh', this.onIndexRefresh);
|
return $.on(d, (Conf['JSON Navigation'] ? 'IndexRefresh' : '4chanXInitFinished'), this.onIndexRefresh);
|
||||||
},
|
},
|
||||||
setButton: function(thread) {
|
setButton: function(thread) {
|
||||||
var a;
|
var a, summary;
|
||||||
if (!(a = $.x('following-sibling::a[contains(@class,"summary")][1]', thread.OP.nodes.root))) {
|
if (!(summary = $.x('following-sibling::*[contains(@class,"summary")][1]', thread.OP.nodes.root))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
a.textContent = ExpandThread.text.apply(ExpandThread, ['+'].concat(__slice.call(a.textContent.match(/\d+/g))));
|
a = $.el('a', {
|
||||||
return $.on(a, 'click', ExpandThread.cbToggle);
|
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;
|
var status, threadID, _ref, _ref1;
|
||||||
if (g.VIEW === 'thread' || !Conf['Thread Expansion']) {
|
if (g.VIEW === 'thread' || !Conf['Thread Expansion']) {
|
||||||
return;
|
return;
|
||||||
@ -11327,12 +11336,9 @@
|
|||||||
}
|
}
|
||||||
delete ExpandThread.statuses[threadID];
|
delete ExpandThread.statuses[threadID];
|
||||||
}
|
}
|
||||||
if (!refresh) {
|
|
||||||
return $.off(d, 'IndexRefresh', this.onIndexRefresh);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onIndexRefresh: function() {
|
onIndexRefresh: function() {
|
||||||
ExpandThread.disconnect(true);
|
ExpandThread.refresh();
|
||||||
return g.BOARD.threads.forEach(function(thread) {
|
return g.BOARD.threads.forEach(function(thread) {
|
||||||
return ExpandThread.setButton(thread);
|
return ExpandThread.setButton(thread);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1933,7 +1933,7 @@
|
|||||||
|
|
||||||
SimpleDict.prototype.forEach = function(fn) {
|
SimpleDict.prototype.forEach = function(fn) {
|
||||||
var key, _i, _len, _ref, _results;
|
var key, _i, _len, _ref, _results;
|
||||||
_ref = __slice.call(this.keys);
|
_ref = this.keys;
|
||||||
_results = [];
|
_results = [];
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
key = _ref[_i];
|
key = _ref[_i];
|
||||||
@ -11318,17 +11318,26 @@
|
|||||||
if (g.VIEW === 'thread' || !Conf['Thread Expansion']) {
|
if (g.VIEW === 'thread' || !Conf['Thread Expansion']) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return $.on(d, 'IndexRefresh', this.onIndexRefresh);
|
return $.on(d, (Conf['JSON Navigation'] ? 'IndexRefresh' : '4chanXInitFinished'), this.onIndexRefresh);
|
||||||
},
|
},
|
||||||
setButton: function(thread) {
|
setButton: function(thread) {
|
||||||
var a;
|
var a, summary;
|
||||||
if (!(a = $.x('following-sibling::a[contains(@class,"summary")][1]', thread.OP.nodes.root))) {
|
if (!(summary = $.x('following-sibling::*[contains(@class,"summary")][1]', thread.OP.nodes.root))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
a.textContent = ExpandThread.text.apply(ExpandThread, ['+'].concat(__slice.call(a.textContent.match(/\d+/g))));
|
a = $.el('a', {
|
||||||
return $.on(a, 'click', ExpandThread.cbToggle);
|
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;
|
var status, threadID, _ref, _ref1;
|
||||||
if (g.VIEW === 'thread' || !Conf['Thread Expansion']) {
|
if (g.VIEW === 'thread' || !Conf['Thread Expansion']) {
|
||||||
return;
|
return;
|
||||||
@ -11341,12 +11350,9 @@
|
|||||||
}
|
}
|
||||||
delete ExpandThread.statuses[threadID];
|
delete ExpandThread.statuses[threadID];
|
||||||
}
|
}
|
||||||
if (!refresh) {
|
|
||||||
return $.off(d, 'IndexRefresh', this.onIndexRefresh);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
onIndexRefresh: function() {
|
onIndexRefresh: function() {
|
||||||
ExpandThread.disconnect(true);
|
ExpandThread.refresh();
|
||||||
return g.BOARD.threads.forEach(function(thread) {
|
return g.BOARD.threads.forEach(function(thread) {
|
||||||
return ExpandThread.setButton(thread);
|
return ExpandThread.setButton(thread);
|
||||||
});
|
});
|
||||||
|
|||||||
@ -13,4 +13,4 @@ class SimpleDict
|
|||||||
@keys.splice i, 1
|
@keys.splice i, 1
|
||||||
delete @[key]
|
delete @[key]
|
||||||
|
|
||||||
forEach: (fn) -> fn @[key] for key in [@keys...]
|
forEach: (fn) -> fn @[key] for key in @keys
|
||||||
|
|||||||
@ -2,23 +2,30 @@ ExpandThread =
|
|||||||
statuses: {}
|
statuses: {}
|
||||||
init: ->
|
init: ->
|
||||||
return if g.VIEW is 'thread' or !Conf['Thread Expansion']
|
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) ->
|
setButton: (thread) ->
|
||||||
return unless a = $.x 'following-sibling::a[contains(@class,"summary")][1]', thread.OP.nodes.root
|
return unless summary = $.x 'following-sibling::*[contains(@class,"summary")][1]', thread.OP.nodes.root
|
||||||
a.textContent = ExpandThread.text '+', a.textContent.match(/\d+/g)...
|
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
|
$.on a, 'click', ExpandThread.cbToggle
|
||||||
|
$.replace summary, a
|
||||||
disconnect: (refresh) ->
|
|
||||||
|
disconnect: ->
|
||||||
|
@refresh()
|
||||||
|
$.off d, 'IndexRefresh', @onIndexRefresh
|
||||||
|
|
||||||
|
refresh: (disconnect) ->
|
||||||
return if g.VIEW is 'thread' or !Conf['Thread Expansion']
|
return if g.VIEW is 'thread' or !Conf['Thread Expansion']
|
||||||
for threadID, status of ExpandThread.statuses
|
for threadID, status of ExpandThread.statuses
|
||||||
status.req?.abort()
|
status.req?.abort()
|
||||||
delete ExpandThread.statuses[threadID]
|
delete ExpandThread.statuses[threadID]
|
||||||
|
return
|
||||||
$.off d, 'IndexRefresh', @onIndexRefresh unless refresh
|
|
||||||
|
|
||||||
onIndexRefresh: ->
|
onIndexRefresh: ->
|
||||||
ExpandThread.disconnect true
|
ExpandThread.refresh()
|
||||||
g.BOARD.threads.forEach (thread) ->
|
g.BOARD.threads.forEach (thread) ->
|
||||||
ExpandThread.setButton thread
|
ExpandThread.setButton thread
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user