Add fetching status at the top of the thread watcher. #99
This commit is contained in:
parent
30d0cc8718
commit
a92afa5679
@ -448,6 +448,12 @@ a.hide-announcement {
|
|||||||
-webkit-flex: 1;
|
-webkit-flex: 1;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
#watcher-status:not(:empty)::before {
|
||||||
|
content: "(";
|
||||||
|
}
|
||||||
|
#watcher-status:not(:empty)::after {
|
||||||
|
content: ")";
|
||||||
|
}
|
||||||
#watched-threads:not(:hover) {
|
#watched-threads:not(:hover) {
|
||||||
max-height: 150px;
|
max-height: 150px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<div>
|
<div>
|
||||||
<span class="move">Thread Watcher</span>
|
<span class="move">Thread Watcher <span id="watcher-status"></span></span>
|
||||||
<a class="menu-button" href="javascript:;">[<i></i>]</a>
|
<a class="menu-button" href="javascript:;">[<i></i>]</a>
|
||||||
</div>
|
</div>
|
||||||
<div id="watched-threads"></div>
|
<div id="watched-threads"></div>
|
||||||
|
|||||||
@ -6,7 +6,8 @@ ThreadWatcher =
|
|||||||
@dialog = UI.dialog 'thread-watcher', 'top: 50px; left: 0px;', """
|
@dialog = UI.dialog 'thread-watcher', 'top: 50px; left: 0px;', """
|
||||||
<%= grunt.file.read('html/Monitoring/ThreadWatcher.html').replace(/>\s+</g, '><').trim() %>
|
<%= grunt.file.read('html/Monitoring/ThreadWatcher.html').replace(/>\s+</g, '><').trim() %>
|
||||||
"""
|
"""
|
||||||
@list = @dialog.lastElementChild
|
@status = $ '#watcher-status', @dialog
|
||||||
|
@list = @dialog.lastElementChild
|
||||||
|
|
||||||
$.on d, 'QRPostSuccessful', @cb.post
|
$.on d, 'QRPostSuccessful', @cb.post
|
||||||
$.on d, 'ThreadUpdate', @cb.threadUpdate if g.VIEW is 'thread'
|
$.on d, 'ThreadUpdate', @cb.threadUpdate if g.VIEW is 'thread'
|
||||||
@ -81,15 +82,28 @@ ThreadWatcher =
|
|||||||
# Update 404 status.
|
# Update 404 status.
|
||||||
ThreadWatcher.add thread
|
ThreadWatcher.add thread
|
||||||
|
|
||||||
|
fetchCount:
|
||||||
|
fetched: 0
|
||||||
|
fetching: 0
|
||||||
fetchAllStatus: ->
|
fetchAllStatus: ->
|
||||||
# XXX need visual feedback
|
ThreadWatcher.status.textContent = '...'
|
||||||
for thread in ThreadWatcher.getAll()
|
for thread in ThreadWatcher.getAll()
|
||||||
ThreadWatcher.fetchStatus thread
|
ThreadWatcher.fetchStatus thread
|
||||||
return
|
return
|
||||||
fetchStatus: ({boardID, threadID, data}) ->
|
fetchStatus: ({boardID, threadID, data}) ->
|
||||||
return if data.isDead
|
return if data.isDead
|
||||||
|
{fetchCount} = ThreadWatcher
|
||||||
|
fetchCount.fetching++
|
||||||
$.ajax "//api.4chan.org/#{boardID}/res/#{threadID}.json",
|
$.ajax "//api.4chan.org/#{boardID}/res/#{threadID}.json",
|
||||||
onload: ->
|
onloadend: ->
|
||||||
|
fetchCount.fetched++
|
||||||
|
if fetchCount.fetched is fetchCount.fetching
|
||||||
|
fetchCount.fetched = 0
|
||||||
|
fetchCount.fetching = 0
|
||||||
|
status = ''
|
||||||
|
else
|
||||||
|
status = "#{Math.round fetchCount.fetched / fetchCount.fetching * 100}%"
|
||||||
|
ThreadWatcher.status.textContent = status
|
||||||
return if @status isnt 404
|
return if @status isnt 404
|
||||||
if Conf['Auto Prune']
|
if Conf['Auto Prune']
|
||||||
ThreadWatcher.rm boardID, threadID
|
ThreadWatcher.rm boardID, threadID
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user