get thread expansion working

This commit is contained in:
ccd0 2014-04-07 03:32:47 -07:00
parent d3397a952c
commit aedaac2b24
4 changed files with 35 additions and 9 deletions

View File

@ -1,5 +1,5 @@
/*
* 4chan X - Version 1.7.1 - 2014-04-06
* 4chan X - Version 1.7.1 - 2014-04-07
*
* Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE

View File

@ -24,7 +24,7 @@
// ==/UserScript==
/*
* 4chan X - Version 1.7.1 - 2014-04-06
* 4chan X - Version 1.7.1 - 2014-04-07
*
* Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE
@ -10996,14 +10996,24 @@
if (g.VIEW === 'thread' || !Conf['Thread Expansion']) {
return;
}
return $.on(d, 'IndexRefresh', this.onIndexRefresh);
if (Conf['JSON Navigation']) {
return $.on(d, 'IndexRefresh', this.onIndexRefresh);
} else {
return Thread.callbacks.push({
name: 'Expand Thread',
cb: function() {
return ExpandThread.setButton(this);
}
});
}
},
setButton: function(thread) {
var a;
if (!(a = $.x('following-sibling::a[contains(@class,"summary")][1]', thread.OP.nodes.root))) {
if (!(a = $.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))));
a.style.cursor = 'pointer';
return $.on(a, 'click', ExpandThread.cbToggle);
},
disconnect: function(refresh) {

View File

@ -1,6 +1,6 @@
// Generated by CoffeeScript
/*
* 4chan X - Version 1.7.1 - 2014-04-06
* 4chan X - Version 1.7.1 - 2014-04-07
*
* Licensed under the MIT license.
* https://github.com/ccd0/4chan-x/blob/master/LICENSE
@ -10999,14 +10999,24 @@
if (g.VIEW === 'thread' || !Conf['Thread Expansion']) {
return;
}
return $.on(d, 'IndexRefresh', this.onIndexRefresh);
if (Conf['JSON Navigation']) {
return $.on(d, 'IndexRefresh', this.onIndexRefresh);
} else {
return Thread.callbacks.push({
name: 'Expand Thread',
cb: function() {
return ExpandThread.setButton(this);
}
});
}
},
setButton: function(thread) {
var a;
if (!(a = $.x('following-sibling::a[contains(@class,"summary")][1]', thread.OP.nodes.root))) {
if (!(a = $.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))));
a.style.cursor = 'pointer';
return $.on(a, 'click', ExpandThread.cbToggle);
},
disconnect: function(refresh) {

View File

@ -2,11 +2,17 @@ ExpandThread =
statuses: {}
init: ->
return if g.VIEW is 'thread' or !Conf['Thread Expansion']
$.on d, 'IndexRefresh', @onIndexRefresh
if Conf['JSON Navigation']
$.on d, 'IndexRefresh', @onIndexRefresh
else
Thread.callbacks.push
name: 'Expand Thread'
cb: -> ExpandThread.setButton @
setButton: (thread) ->
return unless a = $.x 'following-sibling::a[contains(@class,"summary")][1]', thread.OP.nodes.root
return unless a = $.x 'following-sibling::*[contains(@class,"summary")][1]', thread.OP.nodes.root
a.textContent = ExpandThread.text '+', a.textContent.match(/\d+/g)...
a.style.cursor = 'pointer'
$.on a, 'click', ExpandThread.cbToggle
disconnect: (refresh) ->