From e9ac861ad93c9994b3c5cdbfb57a06c270e049a6 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Fri, 1 Aug 2014 13:12:11 -0700 Subject: [PATCH] simplify ImageCommon.error --- src/Images/ImageCommon.coffee | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/Images/ImageCommon.coffee b/src/Images/ImageCommon.coffee index 6ac9968b3..2310483f0 100644 --- a/src/Images/ImageCommon.coffee +++ b/src/Images/ImageCommon.coffee @@ -8,14 +8,21 @@ ImageCommon = return true error: (file, post, delay, cb) -> - return ImageCommon.retry post, cb if (post.isDead or post.file.isDead) and file.src.split('/')[2] is 'i.4cdn.org' + src = post.file.URL.split '/' + URL = Redirect.to 'file', + boardID: post.board.ID + filename: src[src.length - 1] + unless URL and (/^https:\/\//.test(URL) or location.protocol is 'http:') + URL = null - timeoutID = setTimeout ImageCommon.retry, delay, post, cb if delay? + return cb URL if (post.isDead or post.file.isDead) and file.src.split('/')[2] is 'i.4cdn.org' + + timeoutID = setTimeout cb, delay, post.file.URL if delay? return if post.isDead or post.file.isDead kill = (fileOnly) -> - clearTimeout timeoutID + clearTimeout timeoutID if delay? post.kill fileOnly - ImageCommon.retry post, cb + cb URL <% if (type === 'crx') { %> $.ajax post.file.URL, @@ -37,17 +44,6 @@ ImageCommon = kill true <% } %> - retry: (post, cb) -> - unless post.isDead or post.file.isDead - return cb post.file.URL - src = post.file.URL.split '/' - URL = Redirect.to 'file', - boardID: post.board.ID - filename: src[src.length - 1] - if URL and (/^https:\/\//.test(URL) or location.protocol is 'http:') - return cb URL - cb null # report nothing to retry - # Add controls, but not until the mouse is moved over the video. addControls: (video) -> handler = ->