Fetch the image's HEAD status to see if it's still available or not.

Chrome bypasses the lack of CORS because we've allowed `i.4cdn.org` in the manifest.
This commit is contained in:
Mayhem 2014-01-22 16:52:46 +01:00
parent c7c8ea9ec5
commit 1eaf43e39a
2 changed files with 20 additions and 0 deletions

View File

@ -132,6 +132,15 @@ ImageExpand =
return
timeoutID = setTimeout ImageExpand.expand, 10000, post
<% if (type === 'crx') { %>
$.ajax @src,
onloadend: ->
return if @status isnt 404
clearTimeout timeoutID
post.kill true
,
type: 'head'
<% } else { %>
# XXX CORS for i.4cdn.org WHEN?
$.ajax "//a.4cdn.org/#{post.board}/res/#{post.thread}.json", onload: ->
return if @status isnt 200
@ -143,6 +152,7 @@ ImageExpand =
else if postObj.filedeleted
clearTimeout timeoutID
post.kill true
<% } %>
menu:
init: ->

View File

@ -38,6 +38,15 @@ ImageHover =
return
timeoutID = setTimeout (=> @src = post.file.URL + '?' + Date.now()), 3000
<% if (type === 'crx') { %>
$.ajax @src,
onloadend: ->
return if @status isnt 404
clearTimeout timeoutID
post.kill true
,
type: 'head'
<% } else { %>
# XXX CORS for i.4cdn.org WHEN?
$.ajax "//a.4cdn.org/#{post.board}/res/#{post.thread}.json", onload: ->
return if @status isnt 200
@ -49,3 +58,4 @@ ImageHover =
else if postObj.filedeleted
clearTimeout timeoutID
post.kill true
<% } %>