Simplify stuff.

This commit is contained in:
Nicolas Stepien 2012-09-23 19:10:28 +02:00
parent b38bad6c63
commit 9037ad32da
2 changed files with 31 additions and 29 deletions

View File

@ -760,7 +760,7 @@
};
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.board = board;
if (that == null) {
@ -838,9 +838,10 @@
if ((file = $('.file', post)) && (thumb = $('img[data-md5]', file))) {
alt = thumb.alt;
anchor = thumb.parentNode;
fileInfo = file.firstElementChild;
this.file = {
info: $('.fileInfo', file),
text: $('.fileText', file),
info: fileInfo,
text: fileInfo.firstElementChild,
thumb: thumb,
URL: anchor.href,
MD5: thumb.dataset.md5,
@ -853,7 +854,7 @@
}
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.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)) {
this.file.dimensions = this.file.text.textContent.match(/\d+x\d+/)[0];
}
@ -1007,8 +1008,8 @@
this.file[key] = val;
}
file = $('.file', post);
this.file.info = $('.fileInfo', file);
this.file.text = $('.fileText', file);
this.file.info = file.firstElementChild;
this.file.text = this.file.info.firstElementChild;
this.file.thumb = $('img[data-md5]', file);
}
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>") : '';
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) {
ext = file.name.slice(-3);
if (!file.twidth && !file.theight && ext === 'gif') {
@ -1570,17 +1571,17 @@
if (link.host === 'boards.4chan.org') {
path = link.pathname.split('/');
board = path[1];
threadID = +path[3];
postID = +link.hash.slice(2);
threadID = path[3];
postID = link.hash.slice(2);
} else {
board = link.dataset.board;
threadID = +link.dataset.threadid || '';
postID = +link.dataset.postid;
threadID = link.dataset.threadid || 0;
postID = link.dataset.postid;
}
return {
board: board,
threadID: threadID,
postID: postID
threadID: +threadID,
postID: +postID
};
},
contextFromLink: function(quotelink) {
@ -2135,13 +2136,13 @@
for (_i = 0, _len = quotelinks.length; _i < _len; _i++) {
quote = quotelinks[_i];
data = Get.postDataFromLink(quote);
if (data.threadID === '') {
if (!data.threadID) {
continue;
}
if (this.isClone) {
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));
}
}

View File

@ -643,9 +643,10 @@ class Post
# Flash files are not supported.
alt = thumb.alt
anchor = thumb.parentNode
fileInfo = file.firstElementChild
@file =
info: $ '.fileInfo', file
text: $ '.fileText', file
info: fileInfo
text: fileInfo.firstElementChild
thumb: thumb
URL: anchor.href
MD5: thumb.dataset.md5
@ -665,7 +666,7 @@ class Post
# webk.it/62107
# https://www.w3.org/Bugs/Public/show_bug.cgi?id=16909
# 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
@file.dimensions = @file.text.textContent.match(/\d+x\d+/)[0]
@ -779,8 +780,8 @@ class Clone extends Post
for key, val of origin.file
@file[key] = val
file = $ '.file', post
@file.info = $ '.fileInfo', file
@file.text = $ '.fileText', file
@file.info = file.firstElementChild
@file.text = @file.info.firstElementChild
@file.thumb = $ 'img[data-md5]', file
@isDead = true if origin.isDead
@ -1348,7 +1349,7 @@ Build =
if file?.isDeleted
fileHTML =
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.'>" +
"</span></div>"
else
@ -1496,16 +1497,16 @@ Get =
if link.host is 'boards.4chan.org'
path = link.pathname.split '/'
board = path[1]
threadID = +path[3]
postID = +link.hash[2..]
threadID = path[3]
postID = link.hash[2..]
else # resurrected quote
board = link.dataset.board
threadID = +link.dataset.threadid or ''
postID = +link.dataset.postid
threadID = link.dataset.threadid or 0
postID = link.dataset.postid
return {
board: board
threadID: threadID
postID: postID
threadID: +threadID
postID: +postID
}
contextFromLink: (quotelink) ->
Get.postFromRoot $.x 'ancestor::div[parent::div[@class="thread"]][1]', quotelink
@ -1999,10 +2000,10 @@ QuoteCT =
{board, thread} = if @isClone then @context else @
for quote in quotelinks
data = Get.postDataFromLink quote
continue if data.threadID is '' # deadlink
continue unless data.threadID # deadlink
if @isClone
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
return