Use document.implementation.createHTMLDocument() for Quote Inlining and Quote Previewing too.

This commit is contained in:
Nicolas Stepien 2012-03-11 05:51:30 +01:00
parent 8514eae046
commit 4db82feca5
2 changed files with 34 additions and 64 deletions

View File

@ -3186,32 +3186,19 @@
}
},
parse: function(req, pathname, id, threadID, inline) {
var body, href, html, link, newInline, op, quote, reply, _i, _j, _len, _len2, _ref, _ref2;
var doc, href, link, newInline, node, quote, _i, _len, _ref;
if (!inline.parentNode) return;
if (req.status !== 200) {
inline.textContent = "" + req.status + " " + req.statusText;
return;
}
body = $.el('body', {
innerHTML: req.responseText
});
if (id === threadID) {
op = Threading.op($('body > form', body).firstChild);
html = op.innerHTML;
} else {
_ref = $$('.reply', body);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
reply = _ref[_i];
if (reply.id === id) {
html = reply.innerHTML;
break;
}
}
}
newInline = QuoteInline.table(id, html);
_ref2 = $$('.quotelink', newInline);
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
quote = _ref2[_j];
doc = d.implementation.createHTMLDocument();
doc.documentElement.innerHTML = req.responseText;
node = id === threadID ? Threading.op($('body > form', doc).firstChild) : doc.getElementById(id);
newInline = QuoteInline.table(id, node.innerHTML);
_ref = $$('.quotelink', newInline);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
quote = _ref[_i];
if ((href = quote.getAttribute('href')) === quote.hash) {
quote.pathname = pathname;
} else if (!g.REPLY && href !== quote.href) {
@ -3291,29 +3278,16 @@
return $.off(this, 'click', QuotePreview.mouseout);
},
parse: function(req, id, threadID) {
var body, html, op, post, qp, reply, _i, _len, _ref;
if (!((qp = ui.el) && (qp.innerHTML === ("Loading " + id + "...")))) return;
var doc, node, post, qp;
if (!((qp = ui.el) && qp.innerHTML === ("Loading " + id + "..."))) return;
if (req.status !== 200) {
qp.textContent = "" + req.status + " " + req.statusText;
return;
}
body = $.el('body', {
innerHTML: req.responseText
});
if (id === threadID) {
op = Threading.op($('body > form', body).firstChild);
html = op.innerHTML;
} else {
_ref = $$('.reply', body);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
reply = _ref[_i];
if (reply.id === id) {
html = reply.innerHTML;
break;
}
}
}
qp.innerHTML = html;
doc = d.implementation.createHTMLDocument();
doc.documentElement.innerHTML = req.responseText;
node = id === threadID ? Threading.op($('body > form', doc).firstChild) : doc.getElementById(id);
qp.innerHTML = node.innerHTML;
post = {
root: qp,
filesize: $('.filesize', qp),

View File

@ -2646,19 +2646,17 @@ QuoteInline =
inline.textContent = "#{req.status} #{req.statusText}"
return
body = $.el 'body',
innerHTML: req.responseText
if id is threadID #OP
op = Threading.op $('body > form', body).firstChild
html = op.innerHTML
else
for reply in $$ '.reply', body
if reply.id == id
html = reply.innerHTML
break
newInline = QuoteInline.table id, html
doc = d.implementation.createHTMLDocument()
doc.documentElement.innerHTML = req.responseText
node =
if id is threadID #OP
Threading.op $('body > form', doc).firstChild
else
doc.getElementById id
newInline = QuoteInline.table id, node.innerHTML
for quote in $$ '.quotelink', newInline
if (href = quote.getAttribute('href')) is quote.hash #add pathname to normal quotes
if (href = quote.getAttribute 'href') is quote.hash #add pathname to normal quotes
quote.pathname = pathname
else if !g.REPLY and href isnt quote.href #fix x-thread links, not x-board ones
quote.href = "res/#{href}"
@ -2714,23 +2712,21 @@ QuotePreview =
$.off @, 'mouseout', QuotePreview.mouseout
$.off @, 'click', QuotePreview.mouseout
parse: (req, id, threadID) ->
return unless (qp = ui.el) and (qp.innerHTML is "Loading #{id}...")
return unless (qp = ui.el) and qp.innerHTML is "Loading #{id}..."
if req.status isnt 200
qp.textContent = "#{req.status} #{req.statusText}"
return
body = $.el 'body',
innerHTML: req.responseText
if id is threadID #OP
op = Threading.op $('body > form', body).firstChild
html = op.innerHTML
else
for reply in $$ '.reply', body
if reply.id == id
html = reply.innerHTML
break
qp.innerHTML = html
doc = d.implementation.createHTMLDocument()
doc.documentElement.innerHTML = req.responseText
node =
if id is threadID #OP
Threading.op $('body > form', doc).firstChild
else
doc.getElementById id
qp.innerHTML = node.innerHTML
post =
root: qp
filesize: $ '.filesize', qp