Merge branch 'v3'
Conflicts: builds/appchan-x.user.js builds/crx/script.js src/General/Main.coffee
This commit is contained in:
commit
7cf2bfc607
@ -3901,19 +3901,6 @@
|
||||
}
|
||||
};
|
||||
|
||||
RandomAccessList.prototype.closest = function(ID) {
|
||||
var item, prev;
|
||||
item = this.first;
|
||||
while (item) {
|
||||
if (item.ID > ID) {
|
||||
prev = item.prev;
|
||||
break;
|
||||
}
|
||||
item = item.next;
|
||||
}
|
||||
return (prev ? prev.ID : -1);
|
||||
};
|
||||
|
||||
return RandomAccessList;
|
||||
|
||||
})();
|
||||
@ -7234,16 +7221,18 @@
|
||||
});
|
||||
},
|
||||
setup: function() {
|
||||
var ID, post, _ref;
|
||||
$.off(d, '4chanXInitFinished', QuoteThreading.setup);
|
||||
return QuoteThreading.force();
|
||||
},
|
||||
force: function() {
|
||||
var ID, post, _ref;
|
||||
_ref = g.posts;
|
||||
for (ID in _ref) {
|
||||
post = _ref[ID];
|
||||
if (post.cb) {
|
||||
post.cb();
|
||||
post.cb(true);
|
||||
}
|
||||
}
|
||||
return QuoteThreading.hasRun = true;
|
||||
},
|
||||
node: function() {
|
||||
var keys, len, post, posts, quote, _i, _len, _ref;
|
||||
@ -7272,82 +7261,78 @@
|
||||
this.threaded = keys[0];
|
||||
return this.cb = QuoteThreading.nodeinsert;
|
||||
},
|
||||
nodeinsert: function() {
|
||||
var ID, bottom, height, post, posts, root, threadContainer, top, _ref;
|
||||
nodeinsert: function(force) {
|
||||
var bottom, height, post, posts, root, threadContainer, top, _ref;
|
||||
post = g.posts[this.threaded];
|
||||
posts = Unread.posts;
|
||||
if (this.thread.OP === post) {
|
||||
return false;
|
||||
}
|
||||
if (QuoteThreading.hasRun) {
|
||||
posts = Unread.posts;
|
||||
root = post.nodes.root;
|
||||
if (!force) {
|
||||
height = doc.clientHeight;
|
||||
_ref = post.nodes.root.getBoundingClientRect(), bottom = _ref.bottom, top = _ref.top;
|
||||
if (!((posts != null ? posts[post.ID] : void 0) || ((bottom < height) && (top > 0)))) {
|
||||
_ref = root.getBoundingClientRect(), bottom = _ref.bottom, top = _ref.top;
|
||||
if (!((Conf['Unread Count'] && posts[post.ID]) || ((bottom < height) && (top > 0)))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
root = post.nodes.root;
|
||||
if (!$.hasClass(root, 'threadOP')) {
|
||||
$.addClass(root, 'threadOP');
|
||||
if ($.hasClass(root, 'threadOP')) {
|
||||
threadContainer = root.nextElementSibling;
|
||||
post = Get.postFromRoot($.x('descendant::div[contains(@class,"postContainer")][last()]', threadContainer));
|
||||
$.add(threadContainer, this.nodes.root);
|
||||
} else {
|
||||
threadContainer = $.el('div', {
|
||||
className: 'threadContainer'
|
||||
});
|
||||
$.add(threadContainer, this.nodes.root);
|
||||
$.after(root, threadContainer);
|
||||
} else {
|
||||
threadContainer = root.nextSibling;
|
||||
post = Get.postFromRoot($.x('descendant::div[contains(@class,"postContainer")][last()]', threadContainer));
|
||||
$.addClass(root, 'threadOP');
|
||||
}
|
||||
$.add(threadContainer, this.nodes.root);
|
||||
if (!Conf['Unread Count']) {
|
||||
return true;
|
||||
}
|
||||
if (posts[post.ID]) {
|
||||
posts.after(post, this);
|
||||
return true;
|
||||
}
|
||||
if ((ID = posts.closest(post.ID)) !== -1) {
|
||||
posts.after(posts[ID], this);
|
||||
} else {
|
||||
posts.prepend(this);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
toggle: function() {
|
||||
var container, containers, post, replies, reply, thread, _i, _j, _k, _len, _len1, _len2, _ref;
|
||||
if (Conf['Unread Count']) {
|
||||
Unread.posts = new RandomAccessList;
|
||||
Unread.ready();
|
||||
}
|
||||
thread = $('.thread');
|
||||
replies = $$('.thread > .replyContainer, .threadContainer > .replyContainer', thread);
|
||||
var ID, container, containers, nodes, post, posts, thread, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _results;
|
||||
if (QuoteThreading.enabled = this.checked) {
|
||||
QuoteThreading.hasRun = false;
|
||||
for (_i = 0, _len = replies.length; _i < _len; _i++) {
|
||||
reply = replies[_i];
|
||||
post = Get.postFromRoot(reply);
|
||||
if (post.cb) {
|
||||
post.cb();
|
||||
return QuoteThreading.force();
|
||||
} else {
|
||||
thread = $('.thread');
|
||||
posts = [];
|
||||
nodes = [];
|
||||
_ref = g.posts;
|
||||
for (ID in _ref) {
|
||||
post = _ref[ID];
|
||||
if (!(post === post.thread.OP || post.isClone)) {
|
||||
posts.push(post);
|
||||
}
|
||||
}
|
||||
QuoteThreading.hasRun = true;
|
||||
} else {
|
||||
replies.sort(function(a, b) {
|
||||
return Number(a.id.slice(2)) - Number(b.id.slice(2));
|
||||
posts.sort(function(a, b) {
|
||||
return a.ID - b.ID;
|
||||
});
|
||||
$.add(thread, replies);
|
||||
for (_i = 0, _len = posts.length; _i < _len; _i++) {
|
||||
post = posts[_i];
|
||||
nodes.push(post.nodes.root);
|
||||
}
|
||||
$.add(thread, nodes);
|
||||
containers = $$('.threadContainer', thread);
|
||||
for (_j = 0, _len1 = containers.length; _j < _len1; _j++) {
|
||||
container = containers[_j];
|
||||
$.rm(container);
|
||||
}
|
||||
_ref = $$('.threadOP');
|
||||
for (_k = 0, _len2 = _ref.length; _k < _len2; _k++) {
|
||||
post = _ref[_k];
|
||||
$.rmClass(post, 'threadOP');
|
||||
_ref1 = $$('.threadOP');
|
||||
_results = [];
|
||||
for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
|
||||
post = _ref1[_k];
|
||||
_results.push($.rmClass(post, 'threadOP'));
|
||||
}
|
||||
}
|
||||
if (Conf['Unread Count']) {
|
||||
return Unread.read();
|
||||
return _results;
|
||||
}
|
||||
},
|
||||
kb: function() {
|
||||
@ -11852,7 +11837,7 @@
|
||||
}
|
||||
Unread.addPosts(posts);
|
||||
if (Conf['Quote Threading']) {
|
||||
QuoteThreading.setup();
|
||||
QuoteThreading.force();
|
||||
}
|
||||
if (Conf['Scroll to Last Read Post']) {
|
||||
return Unread.scroll();
|
||||
@ -16495,7 +16480,25 @@
|
||||
|
||||
Main = {
|
||||
init: function() {
|
||||
var db, flatten, _i, _len, _ref;
|
||||
var db, flatten, pathname, _i, _len, _ref, _ref1;
|
||||
pathname = location.pathname.split('/');
|
||||
g.BOARD = new Board(pathname[1]);
|
||||
if ((_ref = g.BOARD.ID) === 'z' || _ref === 'fk') {
|
||||
return;
|
||||
}
|
||||
g.VIEW = (function() {
|
||||
switch (pathname[2]) {
|
||||
case 'res':
|
||||
return 'thread';
|
||||
case 'catalog':
|
||||
return 'catalog';
|
||||
default:
|
||||
return 'index';
|
||||
}
|
||||
})();
|
||||
if (g.VIEW === 'thread') {
|
||||
g.THREADID = +pathname[3];
|
||||
}
|
||||
flatten = function(parent, obj) {
|
||||
var key, val;
|
||||
if (obj instanceof Array) {
|
||||
@ -16510,9 +16513,9 @@
|
||||
}
|
||||
};
|
||||
flatten(null, Config);
|
||||
_ref = DataBoard.keys;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
db = _ref[_i];
|
||||
_ref1 = DataBoard.keys;
|
||||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
||||
db = _ref1[_i];
|
||||
Conf[db] = {
|
||||
boards: {}
|
||||
};
|
||||
@ -16540,22 +16543,7 @@
|
||||
});
|
||||
},
|
||||
initFeatures: function() {
|
||||
var init, pathname, _ref, _ref1;
|
||||
pathname = location.pathname.split('/');
|
||||
g.BOARD = new Board(pathname[1]);
|
||||
g.VIEW = (function() {
|
||||
switch (pathname[2]) {
|
||||
case 'res':
|
||||
return 'thread';
|
||||
case 'catalog':
|
||||
return 'catalog';
|
||||
default:
|
||||
return 'index';
|
||||
}
|
||||
})();
|
||||
if (g.VIEW === 'thread') {
|
||||
g.THREADID = +pathname[3];
|
||||
}
|
||||
var init, _ref, _ref1;
|
||||
g.TYPE = (_ref = g.BOARD.ID) === 'b' || _ref === 'd' || _ref === 'e' || _ref === 'gif' || _ref === 'h' || _ref === 'hc' || _ref === 'hm' || _ref === 'hr' || _ref === 'pol' || _ref === 'r' || _ref === 'r9k' || _ref === 'rs' || _ref === 's' || _ref === 's4s' || _ref === 'soc' || _ref === 't' || _ref === 'u' || _ref === 'y' ? 'nsfw' : 'sfw';
|
||||
$.extend(Themes, Conf["userThemes"]);
|
||||
$.extend(Mascots, Conf["userMascots"]);
|
||||
@ -16585,7 +16573,7 @@
|
||||
return;
|
||||
case 'i.4cdn.org':
|
||||
$.ready(function() {
|
||||
var URL, _ref2;
|
||||
var URL, pathname, _ref2;
|
||||
if (Conf['404 Redirect'] && ((_ref2 = d.title) === '4chan - Temporarily Offline' || _ref2 === '4chan - 404 Not Found')) {
|
||||
Redirect.init();
|
||||
pathname = location.pathname.split('/');
|
||||
|
||||
@ -3908,19 +3908,6 @@
|
||||
}
|
||||
};
|
||||
|
||||
RandomAccessList.prototype.closest = function(ID) {
|
||||
var item, prev;
|
||||
item = this.first;
|
||||
while (item) {
|
||||
if (item.ID > ID) {
|
||||
prev = item.prev;
|
||||
break;
|
||||
}
|
||||
item = item.next;
|
||||
}
|
||||
return (prev ? prev.ID : -1);
|
||||
};
|
||||
|
||||
return RandomAccessList;
|
||||
|
||||
})();
|
||||
@ -7238,16 +7225,18 @@
|
||||
});
|
||||
},
|
||||
setup: function() {
|
||||
var ID, post, _ref;
|
||||
$.off(d, '4chanXInitFinished', QuoteThreading.setup);
|
||||
return QuoteThreading.force();
|
||||
},
|
||||
force: function() {
|
||||
var ID, post, _ref;
|
||||
_ref = g.posts;
|
||||
for (ID in _ref) {
|
||||
post = _ref[ID];
|
||||
if (post.cb) {
|
||||
post.cb();
|
||||
post.cb(true);
|
||||
}
|
||||
}
|
||||
return QuoteThreading.hasRun = true;
|
||||
},
|
||||
node: function() {
|
||||
var keys, len, post, posts, quote, _i, _len, _ref;
|
||||
@ -7276,82 +7265,78 @@
|
||||
this.threaded = keys[0];
|
||||
return this.cb = QuoteThreading.nodeinsert;
|
||||
},
|
||||
nodeinsert: function() {
|
||||
var ID, bottom, height, post, posts, root, threadContainer, top, _ref;
|
||||
nodeinsert: function(force) {
|
||||
var bottom, height, post, posts, root, threadContainer, top, _ref;
|
||||
post = g.posts[this.threaded];
|
||||
posts = Unread.posts;
|
||||
if (this.thread.OP === post) {
|
||||
return false;
|
||||
}
|
||||
if (QuoteThreading.hasRun) {
|
||||
posts = Unread.posts;
|
||||
root = post.nodes.root;
|
||||
if (!force) {
|
||||
height = doc.clientHeight;
|
||||
_ref = post.nodes.root.getBoundingClientRect(), bottom = _ref.bottom, top = _ref.top;
|
||||
if (!((posts != null ? posts[post.ID] : void 0) || ((bottom < height) && (top > 0)))) {
|
||||
_ref = root.getBoundingClientRect(), bottom = _ref.bottom, top = _ref.top;
|
||||
if (!((Conf['Unread Count'] && posts[post.ID]) || ((bottom < height) && (top > 0)))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
root = post.nodes.root;
|
||||
if (!$.hasClass(root, 'threadOP')) {
|
||||
$.addClass(root, 'threadOP');
|
||||
if ($.hasClass(root, 'threadOP')) {
|
||||
threadContainer = root.nextElementSibling;
|
||||
post = Get.postFromRoot($.x('descendant::div[contains(@class,"postContainer")][last()]', threadContainer));
|
||||
$.add(threadContainer, this.nodes.root);
|
||||
} else {
|
||||
threadContainer = $.el('div', {
|
||||
className: 'threadContainer'
|
||||
});
|
||||
$.add(threadContainer, this.nodes.root);
|
||||
$.after(root, threadContainer);
|
||||
} else {
|
||||
threadContainer = root.nextSibling;
|
||||
post = Get.postFromRoot($.x('descendant::div[contains(@class,"postContainer")][last()]', threadContainer));
|
||||
$.addClass(root, 'threadOP');
|
||||
}
|
||||
$.add(threadContainer, this.nodes.root);
|
||||
if (!Conf['Unread Count']) {
|
||||
return true;
|
||||
}
|
||||
if (posts[post.ID]) {
|
||||
posts.after(post, this);
|
||||
return true;
|
||||
}
|
||||
if ((ID = posts.closest(post.ID)) !== -1) {
|
||||
posts.after(posts[ID], this);
|
||||
} else {
|
||||
posts.prepend(this);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
toggle: function() {
|
||||
var container, containers, post, replies, reply, thread, _i, _j, _k, _len, _len1, _len2, _ref;
|
||||
if (Conf['Unread Count']) {
|
||||
Unread.posts = new RandomAccessList;
|
||||
Unread.ready();
|
||||
}
|
||||
thread = $('.thread');
|
||||
replies = $$('.thread > .replyContainer, .threadContainer > .replyContainer', thread);
|
||||
var ID, container, containers, nodes, post, posts, thread, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _results;
|
||||
if (QuoteThreading.enabled = this.checked) {
|
||||
QuoteThreading.hasRun = false;
|
||||
for (_i = 0, _len = replies.length; _i < _len; _i++) {
|
||||
reply = replies[_i];
|
||||
post = Get.postFromRoot(reply);
|
||||
if (post.cb) {
|
||||
post.cb();
|
||||
return QuoteThreading.force();
|
||||
} else {
|
||||
thread = $('.thread');
|
||||
posts = [];
|
||||
nodes = [];
|
||||
_ref = g.posts;
|
||||
for (ID in _ref) {
|
||||
post = _ref[ID];
|
||||
if (!(post === post.thread.OP || post.isClone)) {
|
||||
posts.push(post);
|
||||
}
|
||||
}
|
||||
QuoteThreading.hasRun = true;
|
||||
} else {
|
||||
replies.sort(function(a, b) {
|
||||
return Number(a.id.slice(2)) - Number(b.id.slice(2));
|
||||
posts.sort(function(a, b) {
|
||||
return a.ID - b.ID;
|
||||
});
|
||||
$.add(thread, replies);
|
||||
for (_i = 0, _len = posts.length; _i < _len; _i++) {
|
||||
post = posts[_i];
|
||||
nodes.push(post.nodes.root);
|
||||
}
|
||||
$.add(thread, nodes);
|
||||
containers = $$('.threadContainer', thread);
|
||||
for (_j = 0, _len1 = containers.length; _j < _len1; _j++) {
|
||||
container = containers[_j];
|
||||
$.rm(container);
|
||||
}
|
||||
_ref = $$('.threadOP');
|
||||
for (_k = 0, _len2 = _ref.length; _k < _len2; _k++) {
|
||||
post = _ref[_k];
|
||||
$.rmClass(post, 'threadOP');
|
||||
_ref1 = $$('.threadOP');
|
||||
_results = [];
|
||||
for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {
|
||||
post = _ref1[_k];
|
||||
_results.push($.rmClass(post, 'threadOP'));
|
||||
}
|
||||
}
|
||||
if (Conf['Unread Count']) {
|
||||
return Unread.read();
|
||||
return _results;
|
||||
}
|
||||
},
|
||||
kb: function() {
|
||||
@ -11836,7 +11821,7 @@
|
||||
}
|
||||
Unread.addPosts(posts);
|
||||
if (Conf['Quote Threading']) {
|
||||
QuoteThreading.setup();
|
||||
QuoteThreading.force();
|
||||
}
|
||||
if (Conf['Scroll to Last Read Post']) {
|
||||
return Unread.scroll();
|
||||
@ -16483,7 +16468,25 @@
|
||||
|
||||
Main = {
|
||||
init: function() {
|
||||
var db, flatten, _i, _len, _ref;
|
||||
var db, flatten, pathname, _i, _len, _ref, _ref1;
|
||||
pathname = location.pathname.split('/');
|
||||
g.BOARD = new Board(pathname[1]);
|
||||
if ((_ref = g.BOARD.ID) === 'z' || _ref === 'fk') {
|
||||
return;
|
||||
}
|
||||
g.VIEW = (function() {
|
||||
switch (pathname[2]) {
|
||||
case 'res':
|
||||
return 'thread';
|
||||
case 'catalog':
|
||||
return 'catalog';
|
||||
default:
|
||||
return 'index';
|
||||
}
|
||||
})();
|
||||
if (g.VIEW === 'thread') {
|
||||
g.THREADID = +pathname[3];
|
||||
}
|
||||
flatten = function(parent, obj) {
|
||||
var key, val;
|
||||
if (obj instanceof Array) {
|
||||
@ -16498,9 +16501,9 @@
|
||||
}
|
||||
};
|
||||
flatten(null, Config);
|
||||
_ref = DataBoard.keys;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
db = _ref[_i];
|
||||
_ref1 = DataBoard.keys;
|
||||
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
||||
db = _ref1[_i];
|
||||
Conf[db] = {
|
||||
boards: {}
|
||||
};
|
||||
@ -16528,22 +16531,7 @@
|
||||
});
|
||||
},
|
||||
initFeatures: function() {
|
||||
var init, pathname, _ref, _ref1;
|
||||
pathname = location.pathname.split('/');
|
||||
g.BOARD = new Board(pathname[1]);
|
||||
g.VIEW = (function() {
|
||||
switch (pathname[2]) {
|
||||
case 'res':
|
||||
return 'thread';
|
||||
case 'catalog':
|
||||
return 'catalog';
|
||||
default:
|
||||
return 'index';
|
||||
}
|
||||
})();
|
||||
if (g.VIEW === 'thread') {
|
||||
g.THREADID = +pathname[3];
|
||||
}
|
||||
var init, _ref, _ref1;
|
||||
g.TYPE = (_ref = g.BOARD.ID) === 'b' || _ref === 'd' || _ref === 'e' || _ref === 'gif' || _ref === 'h' || _ref === 'hc' || _ref === 'hm' || _ref === 'hr' || _ref === 'pol' || _ref === 'r' || _ref === 'r9k' || _ref === 'rs' || _ref === 's' || _ref === 's4s' || _ref === 'soc' || _ref === 't' || _ref === 'u' || _ref === 'y' ? 'nsfw' : 'sfw';
|
||||
$.extend(Themes, Conf["userThemes"]);
|
||||
$.extend(Mascots, Conf["userMascots"]);
|
||||
@ -16573,7 +16561,7 @@
|
||||
return;
|
||||
case 'i.4cdn.org':
|
||||
$.ready(function() {
|
||||
var URL, _ref2;
|
||||
var URL, pathname, _ref2;
|
||||
if (Conf['404 Redirect'] && ((_ref2 = d.title) === '4chan - Temporarily Offline' || _ref2 === '4chan - 404 Not Found')) {
|
||||
Redirect.init();
|
||||
pathname = location.pathname.split('/');
|
||||
|
||||
@ -1,5 +1,19 @@
|
||||
Main =
|
||||
init: ->
|
||||
pathname = location.pathname.split '/'
|
||||
g.BOARD = new Board pathname[1]
|
||||
return if g.BOARD.ID in ['z', 'fk']
|
||||
g.VIEW =
|
||||
switch pathname[2]
|
||||
when 'res'
|
||||
'thread'
|
||||
when 'catalog'
|
||||
'catalog'
|
||||
else
|
||||
'index'
|
||||
if g.VIEW is 'thread'
|
||||
g.THREADID = +pathname[3]
|
||||
|
||||
# flatten Config into Conf
|
||||
# and get saved or default values
|
||||
flatten = (parent, obj) ->
|
||||
@ -36,20 +50,6 @@ Main =
|
||||
Main.initFeatures()
|
||||
|
||||
initFeatures: ->
|
||||
|
||||
pathname = location.pathname.split '/'
|
||||
g.BOARD = new Board pathname[1]
|
||||
g.VIEW =
|
||||
switch pathname[2]
|
||||
when 'res'
|
||||
'thread'
|
||||
when 'catalog'
|
||||
'catalog'
|
||||
else
|
||||
'index'
|
||||
if g.VIEW is 'thread'
|
||||
g.THREADID = +pathname[3]
|
||||
|
||||
# Check if the current board we're on is SFW or not, so we can handle options that need to know that.
|
||||
g.TYPE =
|
||||
if g.BOARD.ID in ['b', 'd', 'e', 'gif', 'h', 'hc', 'hm', 'hr', 'pol', 'r', 'r9k', 'rs', 's', 's4s', 'soc', 't', 'u', 'y']
|
||||
|
||||
@ -55,13 +55,4 @@ class RandomAccessList
|
||||
if next
|
||||
next.prev = prev
|
||||
else
|
||||
@last = prev
|
||||
|
||||
closest: (ID) ->
|
||||
item = @first
|
||||
while item
|
||||
if item.ID > ID
|
||||
{prev} = item
|
||||
break
|
||||
item = item.next
|
||||
return (if prev then prev.ID else -1)
|
||||
@last = prev
|
||||
@ -39,7 +39,7 @@ Unread =
|
||||
posts = []
|
||||
posts.push post for ID, post of Unread.thread.posts when post.isReply
|
||||
Unread.addPosts posts
|
||||
QuoteThreading.setup() if Conf['Quote Threading']
|
||||
QuoteThreading.force() if Conf['Quote Threading']
|
||||
Unread.scroll() if Conf['Scroll to Last Read Post']
|
||||
|
||||
scroll: ->
|
||||
|
||||
@ -26,9 +26,11 @@ QuoteThreading =
|
||||
|
||||
setup: ->
|
||||
$.off d, '4chanXInitFinished', QuoteThreading.setup
|
||||
QuoteThreading.force()
|
||||
|
||||
post.cb() for ID, post of g.posts when post.cb
|
||||
QuoteThreading.hasRun = true
|
||||
force: ->
|
||||
post.cb true for ID, post of g.posts when post.cb
|
||||
return
|
||||
|
||||
node: ->
|
||||
{posts} = g
|
||||
@ -46,69 +48,61 @@ QuoteThreading =
|
||||
@threaded = keys[0]
|
||||
@cb = QuoteThreading.nodeinsert
|
||||
|
||||
nodeinsert: ->
|
||||
post = g.posts[@threaded]
|
||||
{posts} = Unread
|
||||
nodeinsert: (force) ->
|
||||
post = g.posts[@threaded]
|
||||
|
||||
return false if @thread.OP is post
|
||||
|
||||
if QuoteThreading.hasRun
|
||||
{posts} = Unread
|
||||
{root} = post.nodes
|
||||
|
||||
unless force
|
||||
height = doc.clientHeight
|
||||
{bottom, top} = post.nodes.root.getBoundingClientRect()
|
||||
{bottom, top} = root.getBoundingClientRect()
|
||||
|
||||
# Post is unread or is fully visible.
|
||||
return false unless posts?[post.ID] or ((bottom < height) and (top > 0))
|
||||
return false unless (Conf['Unread Count'] and posts[post.ID]) or ((bottom < height) and (top > 0))
|
||||
|
||||
{root} = post.nodes
|
||||
unless $.hasClass root, 'threadOP'
|
||||
$.addClass root, 'threadOP'
|
||||
if $.hasClass root, 'threadOP'
|
||||
threadContainer = root.nextElementSibling
|
||||
post = Get.postFromRoot $.x 'descendant::div[contains(@class,"postContainer")][last()]', threadContainer
|
||||
$.add threadContainer, @nodes.root
|
||||
|
||||
else
|
||||
threadContainer = $.el 'div',
|
||||
className: 'threadContainer'
|
||||
$.add threadContainer, @nodes.root
|
||||
$.after root, threadContainer
|
||||
else
|
||||
threadContainer = root.nextSibling
|
||||
post = Get.postFromRoot $.x 'descendant::div[contains(@class,"postContainer")][last()]', threadContainer
|
||||
|
||||
$.add threadContainer, @nodes.root
|
||||
$.addClass root, 'threadOP'
|
||||
|
||||
return true unless Conf['Unread Count']
|
||||
|
||||
if posts[post.ID]
|
||||
posts.after post, @
|
||||
return true
|
||||
|
||||
if (ID = posts.closest post.ID) isnt -1
|
||||
posts.after posts[ID], @
|
||||
else
|
||||
posts.prepend @
|
||||
|
||||
return true
|
||||
|
||||
toggle: ->
|
||||
if Conf['Unread Count']
|
||||
Unread.posts = new RandomAccessList
|
||||
Unread.ready()
|
||||
|
||||
thread = $ '.thread'
|
||||
replies = $$ '.thread > .replyContainer, .threadContainer > .replyContainer', thread
|
||||
|
||||
if QuoteThreading.enabled = @checked
|
||||
QuoteThreading.hasRun = false
|
||||
for reply in replies
|
||||
post = Get.postFromRoot reply
|
||||
# QuoteThreading calculates whether or not posts should be threaded based on content
|
||||
# and then threads them based on thread context, so regardless of whether or not it
|
||||
# actually threads them all eligible posts WILL have a cb. Magic.
|
||||
post.cb() if post.cb
|
||||
QuoteThreading.hasRun = true
|
||||
QuoteThreading.force()
|
||||
|
||||
else
|
||||
replies.sort (a, b) -> Number(a.id[2..]) - Number(b.id[2..])
|
||||
$.add thread, replies
|
||||
thread = $('.thread')
|
||||
posts = []
|
||||
nodes = []
|
||||
|
||||
posts.push post for ID, post of g.posts when not (post is post.thread.OP or post.isClone)
|
||||
posts.sort (a, b) -> a.ID - b.ID
|
||||
|
||||
nodes.push post.nodes.root for post in posts
|
||||
$.add thread, nodes
|
||||
|
||||
containers = $$ '.threadContainer', thread
|
||||
$.rm container for container in containers
|
||||
$.rmClass post, 'threadOP' for post in $$ '.threadOP'
|
||||
Unread.read() if Conf['Unread Count']
|
||||
|
||||
kb: ->
|
||||
control = $.id 'threadingControl'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user