Refactoring masturbation.

This commit is contained in:
Nicolas Stepien 2012-01-30 20:42:30 +01:00
parent 6083136a85
commit 078db94ee8
2 changed files with 13 additions and 17 deletions

View File

@ -3312,16 +3312,14 @@
var href, src, thumb, timeoutID, url;
href = this.parentNode.href;
thumb = this.previousSibling;
imgExpand.contract(thumb);
src = href.split('/');
if (this.src.split('/')[2] === 'images.4chan.org' && (url = redirect.image(src[3], src[5]))) {
setTimeout(imgExpand.expand, 10000, thumb, url);
return;
imgExpand.contract(thumb);
if (!(this.src.split('/')[2] === 'images.4chan.org' && (url = redirect.image(src[3], src[5])))) {
if (g.dead) return;
url = href + '?' + Date.now();
}
if (g.dead) return;
url = href + '?' + Date.now();
timeoutID = setTimeout(imgExpand.expand, 10000, thumb, url);
return $.ajax(this.src, {
return $.ajax(url, {
onreadystatechange: (function() {
if (this.status === 404) return clearTimeout(timeoutID);
})

View File

@ -2537,20 +2537,18 @@ imgExpand =
$.add a, img
error: ->
href = @parentNode.href
href = @parentNode.href
thumb = @previousSibling
src = href.split '/'
imgExpand.contract thumb
src = href.split '/'
if @src.split('/')[2] is 'images.4chan.org' and url = redirect.image src[3], src[5]
setTimeout imgExpand.expand, 10000, thumb, url
return
return if g.dead
# CloudFlare may cache banned pages instead of images.
# This will fool CloudFlare's cache.
url = href + '?' + Date.now()
unless @src.split('/')[2] is 'images.4chan.org' and url = redirect.image src[3], src[5]
return if g.dead
# CloudFlare may cache banned pages instead of images.
# This will fool CloudFlare's cache.
url = href + '?' + Date.now()
#navigator.online is not x-browser/os yet
timeoutID = setTimeout imgExpand.expand, 10000, thumb, url
$.ajax @src, onreadystatechange: (-> clearTimeout timeoutID if @status is 404),
$.ajax url, onreadystatechange: (-> clearTimeout timeoutID if @status is 404),
type: 'head'
dialog: ->