From 6292a9dfea17270c5e2380e3dfb7cb9fd1f4aed2 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 7 May 2011 20:55:30 -0700 Subject: [PATCH] guard clause --- 4chan_x.js | 10 +++++++--- script.coffee | 8 ++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/4chan_x.js b/4chan_x.js index 0f59ea5a1..96b77b8b1 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1702,7 +1702,7 @@ if (html = g.cache[threadID]) { quotePreview.get(id, threadID, html); } else { - qp.innerHTML = 'Loading...'; + qp.innerHTML = "Loading " + id + "..."; $.get(this.href, (function() { html = this.responseText; g.cache[threadID] = html; @@ -1714,7 +1714,11 @@ return ui.el = qp; }, 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', { innerHTML: innerHTML }); @@ -1730,7 +1734,7 @@ } } } - return ui.el.innerHTML = html; + return qp.innerHTML = html; } }; quickReport = { diff --git a/script.coffee b/script.coffee index 6c3714ff8..59ec8c26f 100644 --- a/script.coffee +++ b/script.coffee @@ -1358,7 +1358,7 @@ quotePreview = if html = g.cache[threadID] quotePreview.get id, threadID, html else - qp.innerHTML = 'Loading...' + qp.innerHTML = "Loading #{id}..." $.get @href, (-> html = @responseText g.cache[threadID] = html @@ -1367,8 +1367,9 @@ quotePreview = $.show qp ui.el = qp get: (id, threadID, innerHTML) -> + qp = $ '#qp' + return unless qp.innerHTML is "Loading #{id}..." body = $.el 'body', {innerHTML} - if id == threadID #OP html = $('blockquote', body).innerHTML else @@ -1376,8 +1377,7 @@ quotePreview = if reply.id == id html = reply.innerHTML break - - ui.el.innerHTML = html + qp.innerHTML = html quickReport = init: ->