Make more use of Get.dataFromLink
This commit is contained in:
parent
df6bff1b12
commit
5b399388f6
@ -793,7 +793,7 @@
|
|||||||
}
|
}
|
||||||
for (_l = 0, _len3 = quotelinks.length; _l < _len3; _l++) {
|
for (_l = 0, _len3 = quotelinks.length; _l < _len3; _l++) {
|
||||||
quotelink = quotelinks[_l];
|
quotelink = quotelinks[_l];
|
||||||
if (+quotelink.hash.slice(2) === this.ID) {
|
if (Get.postDataFromLink(quotelink).postID === this.ID) {
|
||||||
$.add(quotelink, $.tn('\u00A0(Dead)'));
|
$.add(quotelink, $.tn('\u00A0(Dead)'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1447,12 +1447,12 @@
|
|||||||
if (link.host === 'boards.4chan.org') {
|
if (link.host === 'boards.4chan.org') {
|
||||||
path = link.pathname.split('/');
|
path = link.pathname.split('/');
|
||||||
board = path[1];
|
board = path[1];
|
||||||
threadID = path[3];
|
threadID = +path[3];
|
||||||
postID = link.hash.slice(2);
|
postID = +link.hash.slice(2);
|
||||||
} else {
|
} else {
|
||||||
board = link.dataset.board;
|
board = link.dataset.board;
|
||||||
threadID = '';
|
threadID = +link.dataset.threadid || '';
|
||||||
postID = link.dataset.postid;
|
postID = +link.dataset.postid;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
board: board,
|
board: board,
|
||||||
@ -1521,7 +1521,7 @@
|
|||||||
if (post.no > postID) {
|
if (post.no > postID) {
|
||||||
if (url = Redirect.post(board, postID)) {
|
if (url = Redirect.post(board, postID)) {
|
||||||
$.cache(url, function() {
|
$.cache(url, function() {
|
||||||
return Get.parseArchivedPost(this, board, postID, root, context);
|
return Get.archivedPost(this, board, postID, root, context);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$.addClass(root, 'warning');
|
$.addClass(root, 'warning');
|
||||||
@ -1580,8 +1580,8 @@
|
|||||||
comment = bq.innerHTML.replace(/(^|>)(>[^<$]+)(<|$)/g, '$1<span class=quote>$2</span>$3');
|
comment = bq.innerHTML.replace(/(^|>)(>[^<$]+)(<|$)/g, '$1<span class=quote>$2</span>$3');
|
||||||
threadID = data.thread_num;
|
threadID = data.thread_num;
|
||||||
o = {
|
o = {
|
||||||
postID: postID,
|
postID: "" + postID,
|
||||||
threadID: threadID,
|
threadID: "" + threadID,
|
||||||
board: board,
|
board: board,
|
||||||
name: data.name_processed,
|
name: data.name_processed,
|
||||||
capcode: (function() {
|
capcode: (function() {
|
||||||
@ -1667,6 +1667,7 @@
|
|||||||
target: '_blank'
|
target: '_blank'
|
||||||
});
|
});
|
||||||
a.setAttribute('data-board', board);
|
a.setAttribute('data-board', board);
|
||||||
|
a.setAttribute('data-threadid', post.thread.ID);
|
||||||
a.setAttribute('data-postid', ID);
|
a.setAttribute('data-postid', ID);
|
||||||
} else {
|
} else {
|
||||||
a = $.el('a', {
|
a = $.el('a', {
|
||||||
@ -1769,7 +1770,7 @@
|
|||||||
}
|
}
|
||||||
post = g.posts["" + board + "." + postID];
|
post = g.posts["" + board + "." + postID];
|
||||||
post.rmClone(el.dataset.clone);
|
post.rmClone(el.dataset.clone);
|
||||||
inThreadID = $.x('ancestor::div[@class="thread"]', quotelink).id.slice(1);
|
inThreadID = +$.x('ancestor::div[@class="thread"]', quotelink).id.slice(1);
|
||||||
if (Conf['Forward Hiding'] && board === g.BOARD.ID && threadID === inThreadID && $.hasClass(quotelink, 'backlink')) {
|
if (Conf['Forward Hiding'] && board === g.BOARD.ID && threadID === inThreadID && $.hasClass(quotelink, 'backlink')) {
|
||||||
if (!--post.forwarded) {
|
if (!--post.forwarded) {
|
||||||
delete post.forwarded;
|
delete post.forwarded;
|
||||||
@ -1966,7 +1967,7 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
node: function() {
|
node: function() {
|
||||||
var board, op, quote, quotelinks, quotes, thread, _i, _j, _len, _len1, _ref;
|
var board, op, postID, quote, quotelinks, quotes, thread, _i, _j, _len, _len1, _ref, _ref1;
|
||||||
if (this.isClone && this.thread === this.context.thread) {
|
if (this.isClone && this.thread === this.context.thread) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1987,7 +1988,8 @@
|
|||||||
}
|
}
|
||||||
for (_j = 0, _len1 = quotelinks.length; _j < _len1; _j++) {
|
for (_j = 0, _len1 = quotelinks.length; _j < _len1; _j++) {
|
||||||
quote = quotelinks[_j];
|
quote = quotelinks[_j];
|
||||||
if (("" + (quote.pathname.split('/')[1]) + "." + quote.hash.slice(2)) === op) {
|
_ref1 = Get.postDataFromLink(quote), board = _ref1.board, postID = _ref1.postID;
|
||||||
|
if (("" + board + "." + postID) === op) {
|
||||||
$.add(quote, $.tn(QuoteOP.text));
|
$.add(quote, $.tn(QuoteOP.text));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2003,7 +2005,7 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
node: function() {
|
node: function() {
|
||||||
var board, path, qBoard, qThread, quote, quotelinks, quotes, thread, _i, _len, _ref;
|
var board, data, quote, quotelinks, quotes, thread, _i, _len, _ref;
|
||||||
if (this.isClone && this.thread === this.context.thread) {
|
if (this.isClone && this.thread === this.context.thread) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2014,16 +2016,14 @@
|
|||||||
_ref = this.isClone ? this.context : this, board = _ref.board, thread = _ref.thread;
|
_ref = this.isClone ? this.context : this, board = _ref.board, thread = _ref.thread;
|
||||||
for (_i = 0, _len = quotelinks.length; _i < _len; _i++) {
|
for (_i = 0, _len = quotelinks.length; _i < _len; _i++) {
|
||||||
quote = quotelinks[_i];
|
quote = quotelinks[_i];
|
||||||
if ($.hasClass(quote, 'deadlink')) {
|
data = Get.postDataFromLink(quote);
|
||||||
|
if (data.threadID === '') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
path = quote.pathname.split('/');
|
if (this.isClone) {
|
||||||
qBoard = path[1];
|
|
||||||
qThread = path[3];
|
|
||||||
if (this.isClone && qBoard === this.board.ID && +qThread !== this.thread.ID) {
|
|
||||||
quote.textContent = quote.textContent.replace(QuoteCT.text, '');
|
quote.textContent = quote.textContent.replace(QuoteCT.text, '');
|
||||||
}
|
}
|
||||||
if (qBoard === board.ID && +qThread !== thread.ID) {
|
if (data.board === board.ID && data.threadID !== thread.ID) {
|
||||||
$.add(quote, $.tn(QuoteCT.text));
|
$.add(quote, $.tn(QuoteCT.text));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -636,7 +636,7 @@ class Post
|
|||||||
for post in [post].concat post.clones
|
for post in [post].concat post.clones
|
||||||
quotelinks.push.apply quotelinks, Array::slice.call post.nodes.backlinks
|
quotelinks.push.apply quotelinks, Array::slice.call post.nodes.backlinks
|
||||||
for quotelink in quotelinks
|
for quotelink in quotelinks
|
||||||
if +quotelink.hash[2..] is @ID
|
if Get.postDataFromLink(quotelink).postID is @ID
|
||||||
$.add quotelink, $.tn '\u00A0(Dead)'
|
$.add quotelink, $.tn '\u00A0(Dead)'
|
||||||
return
|
return
|
||||||
addClone: (context) ->
|
addClone: (context) ->
|
||||||
@ -1395,12 +1395,12 @@ Get =
|
|||||||
if link.host is 'boards.4chan.org'
|
if link.host is 'boards.4chan.org'
|
||||||
path = link.pathname.split '/'
|
path = link.pathname.split '/'
|
||||||
board = path[1]
|
board = path[1]
|
||||||
threadID = path[3]
|
threadID = +path[3]
|
||||||
postID = link.hash[2..]
|
postID = +link.hash[2..]
|
||||||
else # resurrected quote
|
else # resurrected quote
|
||||||
board = link.dataset.board
|
board = link.dataset.board
|
||||||
threadID = ''
|
threadID = +link.dataset.threadid or ''
|
||||||
postID = link.dataset.postid
|
postID = +link.dataset.postid
|
||||||
return {
|
return {
|
||||||
board: board
|
board: board
|
||||||
threadID: threadID
|
threadID: threadID
|
||||||
@ -1462,7 +1462,7 @@ Get =
|
|||||||
# The post can be deleted by the time we check a quote.
|
# The post can be deleted by the time we check a quote.
|
||||||
if url = Redirect.post board, postID
|
if url = Redirect.post board, postID
|
||||||
$.cache url, ->
|
$.cache url, ->
|
||||||
Get.parseArchivedPost @, board, postID, root, context
|
Get.archivedPost @, board, postID, root, context
|
||||||
else
|
else
|
||||||
$.addClass root, 'warning'
|
$.addClass root, 'warning'
|
||||||
root.textContent = "Post No.#{postID} was not found."
|
root.textContent = "Post No.#{postID} was not found."
|
||||||
@ -1528,8 +1528,8 @@ Get =
|
|||||||
threadID = data.thread_num
|
threadID = data.thread_num
|
||||||
o =
|
o =
|
||||||
# id
|
# id
|
||||||
postID: postID
|
postID: "#{postID}"
|
||||||
threadID: threadID
|
threadID: "#{threadID}"
|
||||||
board: board
|
board: board
|
||||||
# info
|
# info
|
||||||
name: data.name_processed
|
name: data.name_processed
|
||||||
@ -1614,8 +1614,9 @@ Quotify =
|
|||||||
className: 'quotelink deadlink'
|
className: 'quotelink deadlink'
|
||||||
textContent: "#{quote}\u00A0(Dead)"
|
textContent: "#{quote}\u00A0(Dead)"
|
||||||
target: '_blank'
|
target: '_blank'
|
||||||
a.setAttribute 'data-board', board
|
a.setAttribute 'data-board', board
|
||||||
a.setAttribute 'data-postid', ID
|
a.setAttribute 'data-threadid', post.thread.ID
|
||||||
|
a.setAttribute 'data-postid', ID
|
||||||
else
|
else
|
||||||
# Don't (Dead) when quotifying in an archived post,
|
# Don't (Dead) when quotifying in an archived post,
|
||||||
# and we know the post still exists.
|
# and we know the post still exists.
|
||||||
@ -1717,7 +1718,7 @@ QuoteInline =
|
|||||||
post = g.posts["#{board}.#{postID}"]
|
post = g.posts["#{board}.#{postID}"]
|
||||||
post.rmClone el.dataset.clone
|
post.rmClone el.dataset.clone
|
||||||
|
|
||||||
inThreadID = $.x('ancestor::div[@class="thread"]', quotelink).id[1..]
|
inThreadID = +$.x('ancestor::div[@class="thread"]', quotelink).id[1..]
|
||||||
|
|
||||||
# Decrease forward count and unhide.
|
# Decrease forward count and unhide.
|
||||||
if Conf['Forward Hiding'] and
|
if Conf['Forward Hiding'] and
|
||||||
@ -1896,7 +1897,8 @@ QuoteOP =
|
|||||||
# add (OP) to quotes quoting this context's OP.
|
# add (OP) to quotes quoting this context's OP.
|
||||||
return unless -1 < quotes.indexOf op
|
return unless -1 < quotes.indexOf op
|
||||||
for quote in quotelinks
|
for quote in quotelinks
|
||||||
if "#{quote.pathname.split('/')[1]}.#{quote.hash[2..]}" is op
|
{board, postID} = Get.postDataFromLink quote
|
||||||
|
if "#{board}.#{postID}" is op
|
||||||
$.add quote, $.tn QuoteOP.text
|
$.add quote, $.tn QuoteOP.text
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -1916,13 +1918,11 @@ QuoteCT =
|
|||||||
|
|
||||||
{board, thread} = if @isClone then @context else @
|
{board, thread} = if @isClone then @context else @
|
||||||
for quote in quotelinks
|
for quote in quotelinks
|
||||||
continue if $.hasClass quote, 'deadlink'
|
data = Get.postDataFromLink quote
|
||||||
path = quote.pathname.split '/'
|
continue if data.threadID is '' # deadlink
|
||||||
qBoard = path[1]
|
if @isClone
|
||||||
qThread = path[3]
|
|
||||||
if @isClone and qBoard is @board.ID and +qThread isnt @thread.ID
|
|
||||||
quote.textContent = quote.textContent.replace QuoteCT.text, ''
|
quote.textContent = quote.textContent.replace QuoteCT.text, ''
|
||||||
if qBoard is board.ID and +qThread isnt thread.ID
|
if data.board is board.ID and data.threadID isnt thread.ID
|
||||||
$.add quote, $.tn QuoteCT.text
|
$.add quote, $.tn QuoteCT.text
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user