Retry if and only if we're sure the picture 404'd.

This commit is contained in:
Nicolas Stepien 2011-09-24 15:56:52 +02:00
parent e319beae48
commit fe45fcb4f0
2 changed files with 11 additions and 8 deletions

View File

@ -2734,15 +2734,18 @@
return $.add(a, img); return $.add(a, img);
}, },
error: function(e) { error: function(e) {
var thumb; var req, thumb;
thumb = this.previousSibling; thumb = this.previousSibling;
imgExpand.contract(thumb); imgExpand.contract(thumb);
if (!g.dead) { req = $.ajax(this.src, null, 'head');
return setTimeout(imgExpand.retry, 10000, thumb); return req.onreadystatechange = function(e) {
} if (this.status !== 404) {
return setTimeout(imgExpand.retry, 10000, thumb);
}
};
}, },
retry: function(thumb) { retry: function(thumb) {
if (!(g.dead || thumb.hidden)) { if (!thumb.hidden) {
return imgExpand.expand(thumb); return imgExpand.expand(thumb);
} }
}, },

View File

@ -2026,10 +2026,10 @@ imgExpand =
thumb = @previousSibling thumb = @previousSibling
imgExpand.contract thumb imgExpand.contract thumb
#navigator.online is not x-browser/os yet #navigator.online is not x-browser/os yet
#can't easily check if the image/post is deleted req = $.ajax @src, null, 'head'
setTimeout imgExpand.retry, 10000, thumb unless g.dead req.onreadystatechange = (e) -> setTimeout imgExpand.retry, 10000, thumb if @status isnt 404
retry: (thumb) -> retry: (thumb) ->
imgExpand.expand thumb unless g.dead or thumb.hidden imgExpand.expand thumb unless thumb.hidden
dialog: -> dialog: ->
controls = $.el 'div', controls = $.el 'div',