use g.requests, handle !200
This commit is contained in:
parent
6292a9dfea
commit
f248398b46
24
4chan_x.js
24
4chan_x.js
@ -1692,35 +1692,39 @@
|
||||
return _results;
|
||||
},
|
||||
mouseover: function(e) {
|
||||
var el, html, id, qp, threadID;
|
||||
var el, id, qp, req, threadID;
|
||||
id = this.textContent.replace(">>", '');
|
||||
qp = $('#qp');
|
||||
if (el = d.getElementById(id)) {
|
||||
qp.innerHTML = el.innerHTML;
|
||||
} else {
|
||||
threadID = this.pathname.split('/').pop();
|
||||
if (html = g.cache[threadID]) {
|
||||
quotePreview.get(id, threadID, html);
|
||||
if (req = g.requests[threadID] && req.readyState === 4) {
|
||||
quotePreview.parse(req, id, threadID);
|
||||
} else {
|
||||
qp.innerHTML = "Loading " + id + "...";
|
||||
$.get(this.href, (function() {
|
||||
html = this.responseText;
|
||||
g.cache[threadID] = html;
|
||||
return quotePreview.get(id, threadID, html);
|
||||
}));
|
||||
if (!req) {
|
||||
g.requests[threadID] = $.get(this.href, (function() {
|
||||
return quotePreview.parse(this, id, threadID);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
$.show(qp);
|
||||
return ui.el = qp;
|
||||
},
|
||||
get: function(id, threadID, innerHTML) {
|
||||
parse: function(req, id, threadID) {
|
||||
var body, html, qp, reply, _i, _len, _ref;
|
||||
qp = $('#qp');
|
||||
if (qp.innerHTML !== ("Loading " + id + "...")) {
|
||||
return;
|
||||
}
|
||||
if (req.status !== 200) {
|
||||
qp.innerHTML = "" + req.status + " " + req.statusText;
|
||||
return;
|
||||
}
|
||||
body = $.el('body', {
|
||||
innerHTML: innerHTML
|
||||
innerHTML: req.responseText
|
||||
});
|
||||
if (id === threadID) {
|
||||
html = $('blockquote', body).innerHTML;
|
||||
|
||||
@ -1355,21 +1355,25 @@ quotePreview =
|
||||
qp.innerHTML = el.innerHTML
|
||||
else
|
||||
threadID = @pathname.split('/').pop()
|
||||
if html = g.cache[threadID]
|
||||
quotePreview.get id, threadID, html
|
||||
if req = g.requests[threadID] and req.readyState is 4
|
||||
quotePreview.parse req, id, threadID
|
||||
else
|
||||
qp.innerHTML = "Loading #{id}..."
|
||||
$.get @href, (->
|
||||
html = @responseText
|
||||
g.cache[threadID] = html
|
||||
quotePreview.get id, threadID, html
|
||||
)
|
||||
if not req
|
||||
g.requests[threadID] = $.get @href,
|
||||
(-> quotePreview.parse this, id, threadID)
|
||||
$.show qp
|
||||
ui.el = qp
|
||||
get: (id, threadID, innerHTML) ->
|
||||
parse: (req, id, threadID) ->
|
||||
qp = $ '#qp'
|
||||
return unless qp.innerHTML is "Loading #{id}..."
|
||||
body = $.el 'body', {innerHTML}
|
||||
|
||||
if req.status isnt 200
|
||||
qp.innerHTML = "#{req.status} #{req.statusText}"
|
||||
return
|
||||
|
||||
body = $.el 'body',
|
||||
innerHTML: req.responseText
|
||||
if id == threadID #OP
|
||||
html = $('blockquote', body).innerHTML
|
||||
else
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user