Move read of initial IP count to Main.coffee; also read bump/image limit.

This commit is contained in:
ccd0 2014-11-11 21:17:36 -08:00
parent 21d8871439
commit 24f5a743f7
4 changed files with 9 additions and 5 deletions

View File

@ -189,6 +189,12 @@ Main =
error: err
Main.handleErrors errors if errors
if g.VIEW is 'thread'
scriptData = $('script:not([src])', d.head)?.textContent or ''
threads[0].postLimit = /\bbumplimit *= *1\b/.test scriptData
threads[0].fileLimit = /\bimagelimit *= *1\b/.test scriptData
threads[0].ipCount = if m = scriptData.match /\bunique_ips *= *(\d+)\b/ then +m[1]
Main.callbackNodes Thread, threads
Main.callbackNodesDB Post, posts, ->
$.event '4chanXInitFinished'

View File

@ -13,6 +13,7 @@ class Thread
@isArchived = false
@postLimit = false
@fileLimit = false
@ipCount = undefined
@OP = null
@catalogView = null

View File

@ -40,13 +40,9 @@ 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, ipCount
ThreadStats.update postCount, fileCount, @ipCount
$.on d, 'ThreadUpdate', ThreadStats.onUpdate
onUpdate: (e) ->

View File

@ -266,6 +266,7 @@ ThreadUpdater =
ThreadUpdater.updateThreadStatus 'Closed', !!OP.closed
ThreadUpdater.thread.postLimit = !!OP.bumplimit
ThreadUpdater.thread.fileLimit = !!OP.imagelimit
ThreadUpdater.thread.ipCount = OP.unique_ips if OP.unique_ips?
posts = [] # post objects
index = [] # existing posts