Code simplification.

This commit is contained in:
ccd0 2015-11-01 03:52:52 -08:00
parent 95ba0fc027
commit a9cc5c7498

View File

@ -6,8 +6,8 @@ class Fetcher
@root.textContent = "Loading post No.#{@postID}..." @root.textContent = "Loading post No.#{@postID}..."
if @threadID if @threadID
$.cache "//a.4cdn.org/#{@boardID}/thread/#{@threadID}.json", do (self = @) -> -> $.cache "//a.4cdn.org/#{@boardID}/thread/#{@threadID}.json", (e) =>
self.fetchedPost @ @fetchedPost e.target
else else
@archivedPost() @archivedPost()
@ -56,8 +56,8 @@ class Fetcher
if req.cached if req.cached
api = "//a.4cdn.org/#{@boardID}/thread/#{@threadID}.json" api = "//a.4cdn.org/#{@boardID}/thread/#{@threadID}.json"
$.cleanCache (url) -> url is api $.cleanCache (url) -> url is api
$.cache api, do (self = @) -> -> $.cache api, (e) =>
self.fetchedPost @ @fetchedPost e.target
return return
# The post can be deleted by the time we check a quote. # The post can be deleted by the time we check a quote.
@ -81,8 +81,8 @@ class Fetcher
return false unless url = Redirect.to 'post', {@boardID, @postID} return false unless url = Redirect.to 'post', {@boardID, @postID}
archive = Redirect.data.post[@boardID] archive = Redirect.data.post[@boardID]
if /^https:\/\//.test(url) or location.protocol is 'http:' if /^https:\/\//.test(url) or location.protocol is 'http:'
$.cache url, $.cache url, (e) =>
do (self = @) -> -> self.parseArchivedPost @response, url @parseArchivedPost e.target.response, url
, ,
responseType: 'json' responseType: 'json'
withCredentials: archive.withCredentials withCredentials: archive.withCredentials