Build a clean thread node

This commit is contained in:
Zixaphir 2014-01-09 17:14:46 -07:00
parent 84cbff8a77
commit 55763f4404
3 changed files with 31 additions and 11 deletions

View File

@ -2965,8 +2965,8 @@
href: "/" + boardID + "/res/" + threadID
});
},
thread: function(board, data) {
var OP, files, nodes, posts, root, _ref;
thread: function(board, data, full) {
var OP, root;
Build.spoilerRange[board] = data.custom_spoiler;
if ((OP = board.posts[data.no]) && (root = OP.nodes.root.parentNode)) {
$.rmAll(root);
@ -2976,6 +2976,11 @@
id: "t" + data.no
});
}
$.add(root, Build[full ? 'fullThread' : 'excerptThread'](board, data, OP));
return root;
},
excerptThread: function(board, data, OP) {
var files, nodes, posts, _ref;
nodes = [OP ? OP.nodes.root : Build.postFromObject(data, board.ID)];
if (data.omitted_posts || !Conf['Show Replies'] && data.replies) {
_ref = Conf['Show Replies'] ? [data.omitted_posts, data.omitted_images] : [
@ -2985,8 +2990,10 @@
], posts = _ref[0], files = _ref[1];
nodes.push(Build.summary(board.ID, data.no, posts, files));
}
$.add(root, nodes);
return root;
return nodes;
},
fullThread: function(board, data) {
return [Build.postFromObject(data, board.ID)];
}
};

View File

@ -2975,8 +2975,8 @@
href: "/" + boardID + "/res/" + threadID
});
},
thread: function(board, data) {
var OP, files, nodes, posts, root, _ref;
thread: function(board, data, full) {
var OP, root;
Build.spoilerRange[board] = data.custom_spoiler;
if ((OP = board.posts[data.no]) && (root = OP.nodes.root.parentNode)) {
$.rmAll(root);
@ -2986,6 +2986,11 @@
id: "t" + data.no
});
}
$.add(root, Build[full ? 'fullThread' : 'excerptThread'](board, data, OP));
return root;
},
excerptThread: function(board, data, OP) {
var files, nodes, posts, _ref;
nodes = [OP ? OP.nodes.root : Build.postFromObject(data, board.ID)];
if (data.omitted_posts || !Conf['Show Replies'] && data.replies) {
_ref = Conf['Show Replies'] ? [data.omitted_posts, data.omitted_images] : [
@ -2995,8 +3000,10 @@
], posts = _ref[0], files = _ref[1];
nodes.push(Build.summary(board.ID, data.no, posts, files));
}
$.add(root, nodes);
return root;
return nodes;
},
fullThread: function(board, data) {
return [Build.postFromObject(data, board.ID)];
}
};

View File

@ -208,7 +208,8 @@ Build =
className: 'summary'
textContent: text.join ' '
href: "/#{boardID}/res/#{threadID}"
thread: (board, data) ->
thread: (board, data, full) ->
Build.spoilerRange[board] = data.custom_spoiler
if (OP = board.posts[data.no]) and root = OP.nodes.root.parentNode
@ -218,6 +219,10 @@ Build =
className: 'thread'
id: "t#{data.no}"
$.add root, Build[if full then 'fullThread' else 'excerptThread'] board, data, OP
root
excerptThread: (board, data, OP) ->
nodes = [if OP then OP.nodes.root else Build.postFromObject data, board.ID]
if data.omitted_posts or !Conf['Show Replies'] and data.replies
[posts, files] = if Conf['Show Replies']
@ -226,6 +231,7 @@ Build =
# XXX data.images is not accurate.
[data.replies, data.omitted_images + data.last_replies.filter((data) -> !!data.ext).length]
nodes.push Build.summary board.ID, data.no, posts, files
nodes
$.add root, nodes
root
fullThread: (board, data) ->
[Build.postFromObject data, board.ID]