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

View File

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