Merge commit 'f2bb9b00a343a305e04f4f29285084c758471c34' (BoardsJSON -> BoardConfig.)
This commit is contained in:
commit
52e7749f72
@ -1,26 +1,26 @@
|
||||
BoardsJSON =
|
||||
BoardConfig =
|
||||
cbs: []
|
||||
|
||||
init: ->
|
||||
if (Conf['boardsJSON'].lastChecked or 0) < Date.now() - 2 * $.HOUR
|
||||
if (Conf['boardConfig'].lastChecked or 0) < Date.now() - 2 * $.HOUR
|
||||
$.ajax '//a.4cdn.org/boards.json', onloadend: @load
|
||||
else
|
||||
@set Conf['boardsJSON'].boards
|
||||
@set Conf['boardConfig'].boards
|
||||
|
||||
load: ->
|
||||
if @status is 200
|
||||
boards = {}
|
||||
for board in @response.boards
|
||||
boards[board.board] = board
|
||||
$.set 'boardsJSON', {boards, lastChecked: Date.now()}
|
||||
$.set 'boardConfig', {boards, lastChecked: Date.now()}
|
||||
else
|
||||
{boards} = Conf['boardsJSON']
|
||||
new Notice 'warning', "Failed to load boards JSON. Error #{@statusText} (#{@status})", 20
|
||||
BoardsJSON.set boards
|
||||
{boards} = Conf['boardConfig']
|
||||
new Notice 'warning', "Failed to load board configuration data. Error #{@statusText} (#{@status})", 20
|
||||
BoardConfig.set boards
|
||||
|
||||
set: (@boards) ->
|
||||
for ID, board of @boards
|
||||
g.boards[ID]?.json = board
|
||||
g.boards[ID]?.config = board
|
||||
for cb in @cbs
|
||||
$.queueTask cb
|
||||
return
|
||||
@ -190,7 +190,7 @@ Settings =
|
||||
# Make sure to export the most recent data.
|
||||
$.get Conf, (Conf) ->
|
||||
# Don't export cached JSON data.
|
||||
delete Conf['boardsJSON']
|
||||
delete Conf['boardConfig']
|
||||
Settings.downloadExport {version: g.VERSION, date: Date.now(), Conf}
|
||||
|
||||
downloadExport: (data) ->
|
||||
|
||||
@ -4,6 +4,6 @@ class Board
|
||||
constructor: (@ID) ->
|
||||
@threads = new SimpleDict()
|
||||
@posts = new SimpleDict()
|
||||
@json = BoardsJSON.boards?[@ID]
|
||||
@config = BoardConfig.boards?[@ID]
|
||||
|
||||
g.boards[@] = @
|
||||
|
||||
@ -43,7 +43,7 @@ Main =
|
||||
|
||||
for db in DataBoard.keys
|
||||
Conf[db] = boards: {}
|
||||
Conf['boardsJSON'] = boards: {}
|
||||
Conf['boardConfig'] = boards: {}
|
||||
Conf['archives'] = Redirect.archives
|
||||
Conf['selectedArchives'] = {}
|
||||
Conf['cooldowns'] = {}
|
||||
@ -431,7 +431,7 @@ Main =
|
||||
|
||||
features: [
|
||||
['Polyfill', Polyfill]
|
||||
['Boards JSON', BoardsJSON]
|
||||
['Board Configuration', BoardConfig]
|
||||
['Normalize URL', NormalizeURL]
|
||||
['Captcha Configuration', Captcha.replace]
|
||||
['Redirect', Redirect]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user