This commit is contained in:
Nicolas Stepien 2012-09-06 01:13:09 +02:00
parent c9f6bd50dc
commit 606875c292
2 changed files with 42 additions and 39 deletions

View File

@ -909,7 +909,7 @@
},
initHeaderReady: function() {
var header, nav, settings, _ref, _ref1, _ref2;
if (!$.id('navtopr')) {
if (!$.id('navtopright')) {
return;
}
header = Main.header;
@ -981,7 +981,7 @@
}
return;
}
if (!$.id('navtopr')) {
if (!$.id('navtopright')) {
return;
}
threads = [];
@ -1371,7 +1371,11 @@
return root;
},
fetchedPost: function(req, board, threadID, postID, root) {
var clone, doc, href, inBoard, inThread, link, pc, post, quote, status, url, _i, _len, _ref;
var doc, href, inBoard, inThread, link, pc, post, quote, status, url, _i, _len, _ref;
if (post = g.posts["" + board + "." + postID]) {
Get.insert(post, root);
return;
}
status = req.status;
if (status !== 200) {
if (url = Redirect.post(board, postID)) {
@ -1412,19 +1416,16 @@
link.nextSibling.href = "/" + board + "/res/" + threadID + "#q" + postID;
inBoard = g.boards[board] || new Board(board);
inThread = g.threads["" + board + "." + threadID] || new Thread(threadID, inBoard);
if (!(post = g.posts["" + board + "." + postID])) {
post = new Post(postContainer, thread, board);
Main.callbackNodes(Post, [post]);
}
if (!root.parentNode) {
return;
}
clone = post.addClone();
Main.callbackNodes(Post, [clone]);
return $.replace(root.firstChild, Get.cleanRoot(clone));
post = new Post(postContainer, thread, board);
Main.callbackNodes(Post, [post]);
return Get.insert(post, root);
},
archivedPost: function(req, board, postID, root) {
var bq, clone, comment, data, post, postContainer, thread, threadID;
var bq, comment, data, post, postContainer, thread, threadID;
if (post = g.posts["" + board + "." + postID]) {
Get.insert(post, root);
return;
}
data = JSON.parse(req.response);
if (data.error) {
$.addClass(root, 'warning');
@ -1492,12 +1493,14 @@
});
board = g.boards[board] || new Board(board);
thread = g.threads["" + board + "." + threadID] || new Thread(threadID, board);
if (!(post = g.posts["" + board + "." + postID])) {
post = new Post(postContainer, thread, board, {
isArchived: true
});
Main.callbackNodes(Post, [post]);
}
post = new Post(postContainer, thread, board, {
isArchived: true
});
Main.callbackNodes(Post, [post]);
return Get.insert(post, root);
},
insert: function(post, root) {
var clone;
if (!root.parentNode) {
return;
}

View File

@ -714,7 +714,7 @@ Main =
localStorage.setItem '4chan_settings', false
$.ready Main.initHeaderReady
initHeaderReady: ->
return unless $.id 'navtopr'
return unless $.id 'navtopright'
header = Main.header
$.prepend d.body, header
@ -780,7 +780,7 @@ Main =
location.href = Redirect.thread g.BOARD, g.THREAD, location.hash
return
return unless $.id 'navtopr'
return unless $.id 'navtopright'
threads = []
posts = []
@ -1160,6 +1160,11 @@ Get =
$.rm child unless child is post
root
fetchedPost: (req, board, threadID, postID, root) ->
# In case of multiple callbacks for the same request,
# don't parse the same original post more than once.
if post = g.posts["#{board}.#{postID}"]
Get.insert post, root
return
{status} = req
if status isnt 200
# The thread can die by the time we check a quote.
@ -1201,18 +1206,15 @@ Get =
new Board board
inThread = g.threads["#{board}.#{threadID}"] or
new Thread threadID, inBoard
post = new Post postContainer, thread, board
Main.callbackNodes Post, [post]
Get.insert post, root
archivedPost: (req, board, postID, root) ->
# In case of multiple callbacks for the same request,
# don't parse the same original post more than once.
unless post = g.posts["#{board}.#{postID}"]
post = new Post postContainer, thread, board
Main.callbackNodes Post, [post]
# Stop here if the container has been removed while loading.
return unless root.parentNode
clone = post.addClone()
Main.callbackNodes Post, [clone]
$.replace root.firstChild, Get.cleanRoot clone
archivedPost: (req, board, postID, root) ->
if post = g.posts["#{board}.#{postID}"]
Get.insert post, root
return
data = JSON.parse req.response
if data.error
$.addClass root, 'warning'
@ -1293,13 +1295,11 @@ Get =
new Board board
thread = g.threads["#{board}.#{threadID}"] or
new Thread threadID, board
# In case of multiple callbacks for the same request,
# don't parse the same original post more than once.
unless post = g.posts["#{board}.#{postID}"]
post = new Post postContainer, thread, board,
isArchived: true
Main.callbackNodes Post, [post]
post = new Post postContainer, thread, board,
isArchived: true
Main.callbackNodes Post, [post]
Get.insert post, root
insert: (post, root) ->
# Stop here if the container has been removed while loading.
return unless root.parentNode
clone = post.addClone()