guard clause

This commit is contained in:
James Campos 2011-05-07 20:55:30 -07:00
parent 6287bdc4dd
commit 6292a9dfea
2 changed files with 11 additions and 7 deletions

View File

@ -1702,7 +1702,7 @@
if (html = g.cache[threadID]) { if (html = g.cache[threadID]) {
quotePreview.get(id, threadID, html); quotePreview.get(id, threadID, html);
} else { } else {
qp.innerHTML = 'Loading...'; qp.innerHTML = "Loading " + id + "...";
$.get(this.href, (function() { $.get(this.href, (function() {
html = this.responseText; html = this.responseText;
g.cache[threadID] = html; g.cache[threadID] = html;
@ -1714,7 +1714,11 @@
return ui.el = qp; return ui.el = qp;
}, },
get: function(id, threadID, innerHTML) { get: function(id, threadID, innerHTML) {
var body, html, reply, _i, _len, _ref; var body, html, qp, reply, _i, _len, _ref;
qp = $('#qp');
if (qp.innerHTML !== ("Loading " + id + "...")) {
return;
}
body = $.el('body', { body = $.el('body', {
innerHTML: innerHTML innerHTML: innerHTML
}); });
@ -1730,7 +1734,7 @@
} }
} }
} }
return ui.el.innerHTML = html; return qp.innerHTML = html;
} }
}; };
quickReport = { quickReport = {

View File

@ -1358,7 +1358,7 @@ quotePreview =
if html = g.cache[threadID] if html = g.cache[threadID]
quotePreview.get id, threadID, html quotePreview.get id, threadID, html
else else
qp.innerHTML = 'Loading...' qp.innerHTML = "Loading #{id}..."
$.get @href, (-> $.get @href, (->
html = @responseText html = @responseText
g.cache[threadID] = html g.cache[threadID] = html
@ -1367,8 +1367,9 @@ quotePreview =
$.show qp $.show qp
ui.el = qp ui.el = qp
get: (id, threadID, innerHTML) -> get: (id, threadID, innerHTML) ->
qp = $ '#qp'
return unless qp.innerHTML is "Loading #{id}..."
body = $.el 'body', {innerHTML} body = $.el 'body', {innerHTML}
if id == threadID #OP if id == threadID #OP
html = $('blockquote', body).innerHTML html = $('blockquote', body).innerHTML
else else
@ -1376,8 +1377,7 @@ quotePreview =
if reply.id == id if reply.id == id
html = reply.innerHTML html = reply.innerHTML
break break
qp.innerHTML = html
ui.el.innerHTML = html
quickReport = quickReport =
init: -> init: ->