Fix cross-quotes inlining and addEventListener error.

This commit is contained in:
Nicolas Stepien 2011-05-18 19:53:25 +02:00
parent 50b57d049a
commit cb8b3fb898
2 changed files with 39 additions and 34 deletions

View File

@ -1744,40 +1744,41 @@
}
return;
}
inline = $.el('table', {
className: 'inline',
innerHTML: "<tbody><tr><td class=reply id=i" + id + "></td></tr></tbody>"
});
td = $('td', inline);
if (el = d.getElementById(id)) {
td.innerHTML = el.innerHTML;
inline = $.el('table', {
className: 'inline',
innerHTML: "<tbody><tr><td class=reply id=i" + id + ">" + el.innerHTML + "</td></tr></tbody>"
});
if (this.className === 'backlink') {
$.after($('td > br:first-of-type, td > a:last-of-type', this.parentNode), inline);
return $.hide($.x('ancestor::table[1]', el));
} else {
return $.after(this.parentNode, inline);
}
} else {
td.innerHTML = "Loading " + id + "...";
inline = $.el('div', {
className: 'reply inline',
innerHTML: "Loading " + id + "..."
});
$.after(this.parentNode, inline);
threadID = this.pathname.split('/').pop() || $.x('ancestor::div[@class="thread"]/div', this).id;
if (req = g.requests[threadID]) {
if (req.readyState === 4) {
quoteInline.parse(req, id, threadID, inline);
return quoteInline.parse(req, id, threadID, inline);
}
} else {
g.requests[threadID] = $.get(this.href, (function() {
return g.requests[threadID] = $.get(this.href, (function() {
return quoteInline.parse(this, id, threadID, inline);
}));
}
}
if (this.className === 'backlink') {
$.after($('td > br:first-of-type, td > a:last-of-type', this.parentNode), inline);
return $.hide($.x('ancestor::table[1]', el));
} else {
return $.after(this.parentNode, inline);
}
},
parse: function(req, id, threadID, inline) {
var body, clone, html, op, reply, _i, _len, _ref;
var body, html, newInline, op, reply, _i, _len, _ref;
if (req.status !== 200) {
inline.innerHTML = "" + req.status + " " + req.statusText;
return;
}
clone = inline.cloneNode(true);
body = $.el('body', {
innerHTML: req.responseText
});
@ -1794,8 +1795,11 @@
}
}
}
$('td', clone).innerHTML = html;
return $.replace(inline, clone);
newInline = $.el('table', {
className: 'inline',
innerHTML: "<tbody><tr><td class=reply id=i" + id + ">" + html + "</td></tr></tbody>"
});
return $.replace(inline, newInline);
}
};
quotePreview = {

View File

@ -1393,16 +1393,21 @@ quoteInline =
if @className is 'backlink'
$.show $.x 'ancestor::table[1]', d.getElementById id
return
inline = $.el 'table',
className: 'inline'
innerHTML: "<tbody><tr><td class=reply id=i#{id}></td></tr></tbody>"
td = $ 'td', inline
if el = d.getElementById id
td.innerHTML = el.innerHTML
inline = $.el 'table',
className: 'inline'
innerHTML: "<tbody><tr><td class=reply id=i#{id}>#{el.innerHTML}</td></tr></tbody>"
if @className is 'backlink'
$.after $('td > br:first-of-type, td > a:last-of-type', @parentNode), inline
$.hide $.x 'ancestor::table[1]', el
else
$.after @parentNode, inline
else
td.innerHTML = "Loading #{id}..."
inline = $.el 'div',
className: 'reply inline'
innerHTML: "Loading #{id}..."
$.after @parentNode, inline
# or ... is for index page new posts.
# FIXME x-thread quotes
threadID = @pathname.split('/').pop() or $.x('ancestor::div[@class="thread"]/div', this).id
if req = g.requests[threadID]
if req.readyState is 4
@ -1410,17 +1415,11 @@ quoteInline =
else
#FIXME need an array of callbacks
g.requests[threadID] = $.get @href, (-> quoteInline.parse this, id, threadID, inline)
if @className is 'backlink'
$.after $('td > br:first-of-type, td > a:last-of-type', @parentNode), inline
$.hide $.x 'ancestor::table[1]', el
else
$.after @parentNode, inline
parse: (req, id, threadID, inline) ->
if req.status isnt 200
inline.innerHTML = "#{req.status} #{req.statusText}"
return
clone = inline.cloneNode true
body = $.el 'body',
innerHTML: req.responseText
if id == threadID #OP
@ -1431,8 +1430,10 @@ quoteInline =
if reply.id == id
html = reply.innerHTML
break
$('td', clone).innerHTML = html
$.replace inline, clone
newInline = $.el 'table',
className: 'inline'
innerHTML: "<tbody><tr><td class=reply id=i#{id}>#{html}</td></tr></tbody>"
$.replace inline, newInline
quotePreview =
init: ->