Simplify stuff.
This commit is contained in:
parent
b38bad6c63
commit
9037ad32da
@ -760,7 +760,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
function Post(root, thread, board, that) {
|
function Post(root, thread, board, that) {
|
||||||
var alt, anchor, bq, capcode, data, date, email, file, flag, i, info, name, node, nodes, post, quotelink, quotes, size, subject, text, thumb, tripcode, uniqueID, unit, _i, _j, _k, _len, _len1, _ref, _ref1, _ref2;
|
var alt, anchor, bq, capcode, data, date, email, file, fileInfo, flag, i, info, name, node, nodes, post, quotelink, quotes, size, subject, text, thumb, tripcode, uniqueID, unit, _i, _j, _k, _len, _len1, _ref, _ref1, _ref2;
|
||||||
this.thread = thread;
|
this.thread = thread;
|
||||||
this.board = board;
|
this.board = board;
|
||||||
if (that == null) {
|
if (that == null) {
|
||||||
@ -838,9 +838,10 @@
|
|||||||
if ((file = $('.file', post)) && (thumb = $('img[data-md5]', file))) {
|
if ((file = $('.file', post)) && (thumb = $('img[data-md5]', file))) {
|
||||||
alt = thumb.alt;
|
alt = thumb.alt;
|
||||||
anchor = thumb.parentNode;
|
anchor = thumb.parentNode;
|
||||||
|
fileInfo = file.firstElementChild;
|
||||||
this.file = {
|
this.file = {
|
||||||
info: $('.fileInfo', file),
|
info: fileInfo,
|
||||||
text: $('.fileText', file),
|
text: fileInfo.firstElementChild,
|
||||||
thumb: thumb,
|
thumb: thumb,
|
||||||
URL: anchor.href,
|
URL: anchor.href,
|
||||||
MD5: thumb.dataset.md5,
|
MD5: thumb.dataset.md5,
|
||||||
@ -853,7 +854,7 @@
|
|||||||
}
|
}
|
||||||
this.file.size = size;
|
this.file.size = size;
|
||||||
this.file.thumbURL = that.isArchived ? thumb.src : "" + location.protocol + "//thumbs.4chan.org/" + board + "/thumb/" + (this.file.URL.match(/(\d+)\./)[1]) + "s.jpg";
|
this.file.thumbURL = that.isArchived ? thumb.src : "" + location.protocol + "//thumbs.4chan.org/" + board + "/thumb/" + (this.file.URL.match(/(\d+)\./)[1]) + "s.jpg";
|
||||||
this.file.name = $('span[title]', this.file.info).title.replace(/%22/g, '"');
|
this.file.name = $('span[title]', fileInfo).title.replace(/%22/g, '"');
|
||||||
if (this.file.isImage = /(jpg|png|gif)$/i.test(this.file.name)) {
|
if (this.file.isImage = /(jpg|png|gif)$/i.test(this.file.name)) {
|
||||||
this.file.dimensions = this.file.text.textContent.match(/\d+x\d+/)[0];
|
this.file.dimensions = this.file.text.textContent.match(/\d+x\d+/)[0];
|
||||||
}
|
}
|
||||||
@ -1007,8 +1008,8 @@
|
|||||||
this.file[key] = val;
|
this.file[key] = val;
|
||||||
}
|
}
|
||||||
file = $('.file', post);
|
file = $('.file', post);
|
||||||
this.file.info = $('.fileInfo', file);
|
this.file.info = file.firstElementChild;
|
||||||
this.file.text = $('.fileText', file);
|
this.file.text = this.file.info.firstElementChild;
|
||||||
this.file.thumb = $('img[data-md5]', file);
|
this.file.thumb = $('img[data-md5]', file);
|
||||||
}
|
}
|
||||||
if (origin.isDead) {
|
if (origin.isDead) {
|
||||||
@ -1495,7 +1496,7 @@
|
|||||||
}
|
}
|
||||||
flag = flagCode ? (" <img src='" + staticPath + "/image/country/" + (board === 'pol' ? 'troll/' : '')) + flagCode.toLowerCase() + (".gif' alt=" + flagCode + " title='" + flagName + "' class=countryFlag>") : '';
|
flag = flagCode ? (" <img src='" + staticPath + "/image/country/" + (board === 'pol' ? 'troll/' : '')) + flagCode.toLowerCase() + (".gif' alt=" + flagCode + " title='" + flagName + "' class=countryFlag>") : '';
|
||||||
if (file != null ? file.isDeleted : void 0) {
|
if (file != null ? file.isDeleted : void 0) {
|
||||||
fileHTML = isOP ? ("<div class=file id=f" + postID + "><div class=fileInfo></div><span class=fileThumb>") + ("<img src='" + staticPath + "/image/filedeleted.gif' alt='File deleted.'>") + "</span></div>" : ("<div id=f" + postID + " class=file><span class=fileThumb>") + ("<img src='" + staticPath + "/image/filedeleted-res.gif' alt='File deleted.'>") + "</span></div>";
|
fileHTML = isOP ? ("<div id=f" + postID + " class=file><div class=fileInfo></div><span class=fileThumb>") + ("<img src='" + staticPath + "/image/filedeleted.gif' alt='File deleted.'>") + "</span></div>" : ("<div id=f" + postID + " class=file><span class=fileThumb>") + ("<img src='" + staticPath + "/image/filedeleted-res.gif' alt='File deleted.'>") + "</span></div>";
|
||||||
} else if (file) {
|
} else if (file) {
|
||||||
ext = file.name.slice(-3);
|
ext = file.name.slice(-3);
|
||||||
if (!file.twidth && !file.theight && ext === 'gif') {
|
if (!file.twidth && !file.theight && ext === 'gif') {
|
||||||
@ -1570,17 +1571,17 @@
|
|||||||
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 = +link.dataset.threadid || '';
|
threadID = link.dataset.threadid || 0;
|
||||||
postID = +link.dataset.postid;
|
postID = link.dataset.postid;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
board: board,
|
board: board,
|
||||||
threadID: threadID,
|
threadID: +threadID,
|
||||||
postID: postID
|
postID: +postID
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
contextFromLink: function(quotelink) {
|
contextFromLink: function(quotelink) {
|
||||||
@ -2135,13 +2136,13 @@
|
|||||||
for (_i = 0, _len = quotelinks.length; _i < _len; _i++) {
|
for (_i = 0, _len = quotelinks.length; _i < _len; _i++) {
|
||||||
quote = quotelinks[_i];
|
quote = quotelinks[_i];
|
||||||
data = Get.postDataFromLink(quote);
|
data = Get.postDataFromLink(quote);
|
||||||
if (data.threadID === '') {
|
if (!data.threadID) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (this.isClone) {
|
if (this.isClone) {
|
||||||
quote.textContent = quote.textContent.replace(QuoteCT.text, '');
|
quote.textContent = quote.textContent.replace(QuoteCT.text, '');
|
||||||
}
|
}
|
||||||
if (data.board === board.ID && data.threadID !== thread.ID) {
|
if (data.board === this.board.ID && data.threadID !== thread.ID) {
|
||||||
$.add(quote, $.tn(QuoteCT.text));
|
$.add(quote, $.tn(QuoteCT.text));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -643,9 +643,10 @@ class Post
|
|||||||
# Flash files are not supported.
|
# Flash files are not supported.
|
||||||
alt = thumb.alt
|
alt = thumb.alt
|
||||||
anchor = thumb.parentNode
|
anchor = thumb.parentNode
|
||||||
|
fileInfo = file.firstElementChild
|
||||||
@file =
|
@file =
|
||||||
info: $ '.fileInfo', file
|
info: fileInfo
|
||||||
text: $ '.fileText', file
|
text: fileInfo.firstElementChild
|
||||||
thumb: thumb
|
thumb: thumb
|
||||||
URL: anchor.href
|
URL: anchor.href
|
||||||
MD5: thumb.dataset.md5
|
MD5: thumb.dataset.md5
|
||||||
@ -665,7 +666,7 @@ class Post
|
|||||||
# webk.it/62107
|
# webk.it/62107
|
||||||
# https://www.w3.org/Bugs/Public/show_bug.cgi?id=16909
|
# https://www.w3.org/Bugs/Public/show_bug.cgi?id=16909
|
||||||
# http://www.whatwg.org/specs/web-apps/current-work/#multipart-form-data
|
# http://www.whatwg.org/specs/web-apps/current-work/#multipart-form-data
|
||||||
@file.name = $('span[title]', @file.info).title.replace /%22/g, '"'
|
@file.name = $('span[title]', fileInfo).title.replace /%22/g, '"'
|
||||||
if @file.isImage = /(jpg|png|gif)$/i.test @file.name
|
if @file.isImage = /(jpg|png|gif)$/i.test @file.name
|
||||||
@file.dimensions = @file.text.textContent.match(/\d+x\d+/)[0]
|
@file.dimensions = @file.text.textContent.match(/\d+x\d+/)[0]
|
||||||
|
|
||||||
@ -779,8 +780,8 @@ class Clone extends Post
|
|||||||
for key, val of origin.file
|
for key, val of origin.file
|
||||||
@file[key] = val
|
@file[key] = val
|
||||||
file = $ '.file', post
|
file = $ '.file', post
|
||||||
@file.info = $ '.fileInfo', file
|
@file.info = file.firstElementChild
|
||||||
@file.text = $ '.fileText', file
|
@file.text = @file.info.firstElementChild
|
||||||
@file.thumb = $ 'img[data-md5]', file
|
@file.thumb = $ 'img[data-md5]', file
|
||||||
|
|
||||||
@isDead = true if origin.isDead
|
@isDead = true if origin.isDead
|
||||||
@ -1348,7 +1349,7 @@ Build =
|
|||||||
if file?.isDeleted
|
if file?.isDeleted
|
||||||
fileHTML =
|
fileHTML =
|
||||||
if isOP
|
if isOP
|
||||||
"<div class=file id=f#{postID}><div class=fileInfo></div><span class=fileThumb>" +
|
"<div id=f#{postID} class=file><div class=fileInfo></div><span class=fileThumb>" +
|
||||||
"<img src='#{staticPath}/image/filedeleted.gif' alt='File deleted.'>" +
|
"<img src='#{staticPath}/image/filedeleted.gif' alt='File deleted.'>" +
|
||||||
"</span></div>"
|
"</span></div>"
|
||||||
else
|
else
|
||||||
@ -1496,16 +1497,16 @@ 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 = +link.dataset.threadid or ''
|
threadID = link.dataset.threadid or 0
|
||||||
postID = +link.dataset.postid
|
postID = link.dataset.postid
|
||||||
return {
|
return {
|
||||||
board: board
|
board: board
|
||||||
threadID: threadID
|
threadID: +threadID
|
||||||
postID: postID
|
postID: +postID
|
||||||
}
|
}
|
||||||
contextFromLink: (quotelink) ->
|
contextFromLink: (quotelink) ->
|
||||||
Get.postFromRoot $.x 'ancestor::div[parent::div[@class="thread"]][1]', quotelink
|
Get.postFromRoot $.x 'ancestor::div[parent::div[@class="thread"]][1]', quotelink
|
||||||
@ -1999,10 +2000,10 @@ QuoteCT =
|
|||||||
{board, thread} = if @isClone then @context else @
|
{board, thread} = if @isClone then @context else @
|
||||||
for quote in quotelinks
|
for quote in quotelinks
|
||||||
data = Get.postDataFromLink quote
|
data = Get.postDataFromLink quote
|
||||||
continue if data.threadID is '' # deadlink
|
continue unless data.threadID # deadlink
|
||||||
if @isClone
|
if @isClone
|
||||||
quote.textContent = quote.textContent.replace QuoteCT.text, ''
|
quote.textContent = quote.textContent.replace QuoteCT.text, ''
|
||||||
if data.board is board.ID and data.threadID 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