cache, op

This commit is contained in:
James Campos 2011-05-07 20:46:39 -07:00
parent 1f08f803dd
commit fe0bbb842f
2 changed files with 47 additions and 30 deletions

View File

@ -1689,14 +1689,23 @@
return _results; return _results;
}, },
mouseover: function(e) { mouseover: function(e) {
var el, id, qp; var el, html, id, qp, threadID;
id = this.textContent.replace(">>", ''); id = this.textContent.replace(">>", '');
qp = $('#qp'); qp = $('#qp');
if (el = d.getElementById(id)) { if (el = d.getElementById(id)) {
qp.innerHTML = el.innerHTML; qp.innerHTML = el.innerHTML;
} else {
threadID = this.pathname.split('/').pop();
if (html = g.cache[threadID]) {
quotePreview.get(id, threadID, html);
} else { } else {
qp.innerHTML = 'Loading...'; qp.innerHTML = 'Loading...';
quotePreview.get(this, id); $.get(this.href, (function() {
html = this.responseText;
g.cache[threadID] = html;
return quotePreview.get(id, threadID, html);
}));
}
} }
$.show(qp); $.show(qp);
return ui.el = qp; return ui.el = qp;
@ -1704,26 +1713,24 @@
mouseout: function(e) { mouseout: function(e) {
return $.hide(ui.el); return $.hide(ui.el);
}, },
get: function(link, id) { get: function(id, threadID, innerHTML) {
return $.get(link.href, (function() { var body, html, reply, _i, _len, _ref;
return quotePreview.get2(link, id, this);
}));
},
get2: function(link, id, xhr) {
var body, reply, _i, _len, _ref, _results;
body = $.el('body', { body = $.el('body', {
innerHTML: xhr.responseText innerHTML: innerHTML
}); });
if (id === threadID) {
html = $('blockquote', body).innerHTML;
} else {
_ref = $$('td.reply', body); _ref = $$('td.reply', body);
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
reply = _ref[_i]; reply = _ref[_i];
if (reply.id === id) { if (reply.id === id) {
ui.el.innerHTML = reply.innerHTML; html = reply.innerHTML;
break; break;
} }
} }
return _results; }
return ui.el.innerHTML = html;
} }
}; };
quickReport = { quickReport = {

View File

@ -1351,24 +1351,34 @@ quotePreview =
qp = $ '#qp' qp = $ '#qp'
if el = d.getElementById id if el = d.getElementById id
qp.innerHTML = el.innerHTML qp.innerHTML = el.innerHTML
else
threadID = @pathname.split('/').pop()
if html = g.cache[threadID]
quotePreview.get id, threadID, html
else else
qp.innerHTML = 'Loading...' qp.innerHTML = 'Loading...'
quotePreview.get this, id $.get @href, (->
html = @responseText
g.cache[threadID] = html
quotePreview.get id, threadID, html
)
$.show qp $.show qp
ui.el = qp ui.el = qp
mouseout: (e) -> mouseout: (e) ->
$.hide ui.el $.hide ui.el
get: (link, id) -> get: (id, threadID, innerHTML) ->
$.get link.href, (-> quotePreview.get2 link, id, this) body = $.el 'body', {innerHTML}
get2: (link, id, xhr) ->
body = $.el 'body',
innerHTML: xhr.responseText
if id == threadID #OP
html = $('blockquote', body).innerHTML
else
for reply in $$ 'td.reply', body for reply in $$ 'td.reply', body
if reply.id == id if reply.id == id
ui.el.innerHTML = reply.innerHTML html = reply.innerHTML
break break
ui.el.innerHTML = html
quickReport = quickReport =
init: -> init: ->
g.callbacks.push quickReport.cb.node g.callbacks.push quickReport.cb.node