Simplify duplicated code for thread watcher requests.
This commit is contained in:
parent
74268f78d5
commit
cafb7250c7
@ -219,18 +219,13 @@ ThreadWatcher =
|
|||||||
if ThreadWatcher.requests.length is 0
|
if ThreadWatcher.requests.length is 0
|
||||||
ThreadWatcher.status.textContent = '...'
|
ThreadWatcher.status.textContent = '...'
|
||||||
$.addClass ThreadWatcher.refreshButton, 'fa-spin'
|
$.addClass ThreadWatcher.refreshButton, 'fa-spin'
|
||||||
if Site.hasCORS?(url) or url.split('/')[...3].join('/') is location.origin
|
ajax = if (siteID is Site.hostname) then $.ajax else CrossOrigin.ajax
|
||||||
req = $.ajax url,
|
req = ajax url,
|
||||||
onloadend: ->
|
onloadend: ->
|
||||||
ThreadWatcher.parseStatus.call @, thread
|
ThreadWatcher.parseStatus.call @, thread
|
||||||
timeout: $.MINUTE
|
timeout: $.MINUTE
|
||||||
,
|
,
|
||||||
whenModified: if force then false else 'ThreadWatcher'
|
whenModified: if force then false else 'ThreadWatcher'
|
||||||
else
|
|
||||||
req = CrossOrigin.ajax url,
|
|
||||||
onloadend: ->
|
|
||||||
ThreadWatcher.parseStatus.call @, thread
|
|
||||||
timeout: $.MINUTE
|
|
||||||
ThreadWatcher.requests.push req
|
ThreadWatcher.requests.push req
|
||||||
|
|
||||||
parseStatus: ({siteID, boardID, threadID, data}) ->
|
parseStatus: ({siteID, boardID, threadID, data}) ->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user