Add Thread Stats. Close #73.
This commit is contained in:
parent
a58b5c7670
commit
289c187686
File diff suppressed because one or more lines are too long
@ -53,7 +53,7 @@ a[href="javascript:;"] {
|
|||||||
|
|
||||||
/* fixed, z-index */
|
/* fixed, z-index */
|
||||||
#qp, #ihover,
|
#qp, #ihover,
|
||||||
#updater, #stats,
|
#updater, #thread-stats,
|
||||||
#header,
|
#header,
|
||||||
#qr, #watcher {
|
#qr, #watcher {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
@ -67,7 +67,7 @@ a[href="javascript:;"] {
|
|||||||
#menu {
|
#menu {
|
||||||
z-index: 60;
|
z-index: 60;
|
||||||
}
|
}
|
||||||
#updater, #stats {
|
#updater, #thread-stats {
|
||||||
z-index: 50;
|
z-index: 50;
|
||||||
}
|
}
|
||||||
#header:hover {
|
#header:hover {
|
||||||
@ -199,6 +199,13 @@ a[href="javascript:;"] {
|
|||||||
color: limegreen;
|
color: limegreen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Thread Stats */
|
||||||
|
#thread-stats {
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
/* Quote */
|
/* Quote */
|
||||||
.deadlink {
|
.deadlink {
|
||||||
text-decoration: none !important;
|
text-decoration: none !important;
|
||||||
|
|||||||
@ -2413,6 +2413,47 @@ ImageHover =
|
|||||||
$.ajax URL, onreadystatechange: (-> clearTimeout timeoutID if @status is 404),
|
$.ajax URL, onreadystatechange: (-> clearTimeout timeoutID if @status is 404),
|
||||||
type: 'head'
|
type: 'head'
|
||||||
|
|
||||||
|
ThreadStats =
|
||||||
|
init: ->
|
||||||
|
return if g.VIEW isnt 'thread' or !Conf['Thread Stats']
|
||||||
|
@dialog = UI.dialog 'thread-stats', 'bottom: 0; left: 0;', """
|
||||||
|
<div class=move><span id=post-count>0</span> / <span id=file-count>0</span></div>
|
||||||
|
"""
|
||||||
|
|
||||||
|
@postCount = @fileCount = 0
|
||||||
|
@postCountEl = $ '#post-count', @dialog
|
||||||
|
@fileCountEl = $ '#file-count', @dialog
|
||||||
|
@fileLimit = # XXX need up to date data on this, check browser
|
||||||
|
switch g.BOARD
|
||||||
|
when 'a', 'b', 'v', 'co', 'mlp'
|
||||||
|
251
|
||||||
|
when 'vg'
|
||||||
|
376
|
||||||
|
else
|
||||||
|
151
|
||||||
|
|
||||||
|
Thread::callbacks.push
|
||||||
|
name: 'Thread Stats'
|
||||||
|
cb: @node
|
||||||
|
node: ->
|
||||||
|
for ID, post of @posts
|
||||||
|
ThreadStats.postCount++
|
||||||
|
ThreadStats.fileCount++ if post.file
|
||||||
|
ThreadStats.update()
|
||||||
|
$.on d, 'ThreadUpdate', ThreadStats.onUpdate
|
||||||
|
$.add d.body, ThreadStats.dialog
|
||||||
|
onUpdate: (e) ->
|
||||||
|
for post in e.detail.newPosts
|
||||||
|
ThreadStats.postCount++
|
||||||
|
ThreadStats.fileCount++ if post.file
|
||||||
|
ThreadStats.postCount -= e.detail.deletedPosts.length
|
||||||
|
ThreadStats.fileCount -= e.detail.deletedFiles.length
|
||||||
|
ThreadStats.update()
|
||||||
|
update: ->
|
||||||
|
@postCountEl.textContent = ThreadStats.postCount
|
||||||
|
@fileCountEl.textContent = ThreadStats.fileCount
|
||||||
|
(if ThreadStats.fileCount > ThreadStats.fileLimit then $.addClass else $.rmClass) ThreadStats.fileCountEl, 'warning'
|
||||||
|
|
||||||
ThreadUpdater =
|
ThreadUpdater =
|
||||||
init: ->
|
init: ->
|
||||||
return if g.VIEW isnt 'thread' or !Conf['Thread Updater']
|
return if g.VIEW isnt 'thread' or !Conf['Thread Updater']
|
||||||
|
|||||||
@ -333,6 +333,7 @@ Main =
|
|||||||
initFeature 'Reveal Spoilers', RevealSpoilers
|
initFeature 'Reveal Spoilers', RevealSpoilers
|
||||||
initFeature 'Auto-GIF', AutoGIF
|
initFeature 'Auto-GIF', AutoGIF
|
||||||
initFeature 'Image Hover', ImageHover
|
initFeature 'Image Hover', ImageHover
|
||||||
|
initFeature 'Thread Stats', ThreadStats
|
||||||
initFeature 'Thread Updater', ThreadUpdater
|
initFeature 'Thread Updater', ThreadUpdater
|
||||||
console.timeEnd 'All initializations'
|
console.timeEnd 'All initializations'
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user