diff --git a/src/Monitoring/ThreadStats.coffee b/src/Monitoring/ThreadStats.coffee
index 3a0aa3018..91d86a9f4 100755
--- a/src/Monitoring/ThreadStats.coffee
+++ b/src/Monitoring/ThreadStats.coffee
@@ -2,25 +2,26 @@ ThreadStats =
init: ->
return if g.VIEW isnt 'thread' or !Conf['Thread Stats']
- countHTML = <%= html('? / ?') %>
+ countHTML = <%= html('? / ? / ?') %>
countHTML = <%= html('&{countHTML} / ?') %> if Conf['Page Count in Stats']
if Conf['Updater and Stats in Header']
@dialog = sc = $.el 'span',
id: 'thread-stats'
- title: 'Post Count / File Count' + (if Conf["Page Count in Stats"] then " / Page Count" else "")
+ title: 'Post Count / File Count / IP Count' + (if Conf["Page Count in Stats"] then " / Page Count" else "")
$.extend sc, countHTML
$.ready ->
Header.addShortcut sc
else
@dialog = sc = UI.dialog 'thread-stats', 'bottom: 0px; right: 0px;',
- <%= html('
&{countHTML}
') %>
+ <%= html('&{countHTML}
') %>
$.ready =>
$.add d.body, sc
@postCountEl = $ '#post-count', sc
@fileCountEl = $ '#file-count', sc
- @pageCountEl = $ '#page-count', sc
+ @ipCountEl = $ '#ip-count', sc
+ @pageCountEl = $ '#page-count', sc
Thread.callbacks.push
name: 'Thread Stats'
@@ -33,25 +34,30 @@ ThreadStats =
postCount++
fileCount++ if post.file
ThreadStats.lastPost = post.info.date if Conf["Page Count in Stats"]
+ for script in $$ 'script[type="text/javascript"]:not([src])', d.head
+ if m = script.textContent.match /\bvar unique_ips = (\d+);/
+ ipCount = +m[1]
+ break
ThreadStats.thread = @
ThreadStats.fetchPage()
- ThreadStats.update postCount, fileCount
+ ThreadStats.update postCount, fileCount, ipCount
$.on d, 'ThreadUpdate', ThreadStats.onUpdate
onUpdate: (e) ->
return if e.detail[404]
- {postCount, fileCount, newPosts} = e.detail
- ThreadStats.update postCount, fileCount
+ {postCount, fileCount, ipCount, newPosts} = e.detail
+ ThreadStats.update postCount, fileCount, ipCount
return unless Conf["Page Count in Stats"]
if newPosts.length
ThreadStats.lastPost = g.posts[newPosts[newPosts.length - 1]].info.date
if ThreadStats.lastPost > ThreadStats.lastPageUpdate and ThreadStats.pageCountEl?.textContent isnt '1'
ThreadStats.fetchPage()
- update: (postCount, fileCount) ->
- {thread, postCountEl, fileCountEl} = ThreadStats
+ update: (postCount, fileCount, ipCount) ->
+ {thread, postCountEl, fileCountEl, ipCountEl} = ThreadStats
postCountEl.textContent = postCount
fileCountEl.textContent = fileCount
+ ipCountEl.textContent = if ipCount? then ipCount else '?'
(if thread.postLimit and !thread.isSticky then $.addClass else $.rmClass) postCountEl, 'warning'
(if thread.fileLimit and !thread.isSticky then $.addClass else $.rmClass) fileCountEl, 'warning'
diff --git a/src/Monitoring/ThreadUpdater.coffee b/src/Monitoring/ThreadUpdater.coffee
index b27755ca7..723dffcc0 100755
--- a/src/Monitoring/ThreadUpdater.coffee
+++ b/src/Monitoring/ThreadUpdater.coffee
@@ -339,3 +339,4 @@ ThreadUpdater =
newPosts: posts.map (post) -> post.fullID
postCount: OP.replies + 1
fileCount: OP.images + (!!ThreadUpdater.thread.OP.file and !ThreadUpdater.thread.OP.file.isDead)
+ ipCount: OP.unique_ips