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

View File

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