From fe45fcb4f04bec0ca484805cc63de5854f3d8b55 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sat, 24 Sep 2011 15:56:52 +0200 Subject: [PATCH] Retry if and only if we're sure the picture 404'd. --- 4chan_x.user.js | 13 ++++++++----- script.coffee | 6 +++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index bc754d053..c33e9a5a9 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2734,15 +2734,18 @@ return $.add(a, img); }, error: function(e) { - var thumb; + var req, thumb; thumb = this.previousSibling; imgExpand.contract(thumb); - if (!g.dead) { - return setTimeout(imgExpand.retry, 10000, thumb); - } + req = $.ajax(this.src, null, 'head'); + return req.onreadystatechange = function(e) { + if (this.status !== 404) { + return setTimeout(imgExpand.retry, 10000, thumb); + } + }; }, retry: function(thumb) { - if (!(g.dead || thumb.hidden)) { + if (!thumb.hidden) { return imgExpand.expand(thumb); } }, diff --git a/script.coffee b/script.coffee index 66b26cfae..fd975629e 100644 --- a/script.coffee +++ b/script.coffee @@ -2026,10 +2026,10 @@ imgExpand = thumb = @previousSibling imgExpand.contract thumb #navigator.online is not x-browser/os yet - #can't easily check if the image/post is deleted - setTimeout imgExpand.retry, 10000, thumb unless g.dead + req = $.ajax @src, null, 'head' + req.onreadystatechange = (e) -> setTimeout imgExpand.retry, 10000, thumb if @status isnt 404 retry: (thumb) -> - imgExpand.expand thumb unless g.dead or thumb.hidden + imgExpand.expand thumb unless thumb.hidden dialog: -> controls = $.el 'div',