BoardsJSON -> BoardConfig.
This commit is contained in:
parent
a22ca7a3f3
commit
f2bb9b00a3
@ -108,7 +108,7 @@ module.exports = (grunt) ->
|
|||||||
'src/classes/Connection.coffee'
|
'src/classes/Connection.coffee'
|
||||||
'src/classes/Fetcher.coffee'
|
'src/classes/Fetcher.coffee'
|
||||||
'src/General/Polyfill.coffee'
|
'src/General/Polyfill.coffee'
|
||||||
'src/General/BoardsJSON.coffee'
|
'src/General/BoardConfig.coffee'
|
||||||
'src/General/Header.coffee'
|
'src/General/Header.coffee'
|
||||||
'src/General/Index.coffee'
|
'src/General/Index.coffee'
|
||||||
'src/General/Build.coffee'
|
'src/General/Build.coffee'
|
||||||
|
|||||||
@ -1,26 +1,26 @@
|
|||||||
BoardsJSON =
|
BoardConfig =
|
||||||
cbs: []
|
cbs: []
|
||||||
|
|
||||||
init: ->
|
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
|
$.ajax '//a.4cdn.org/boards.json', onloadend: @load
|
||||||
else
|
else
|
||||||
@set Conf['boardsJSON'].boards
|
@set Conf['boardConfig'].boards
|
||||||
|
|
||||||
load: ->
|
load: ->
|
||||||
if @status is 200
|
if @status is 200
|
||||||
boards = {}
|
boards = {}
|
||||||
for board in @response.boards
|
for board in @response.boards
|
||||||
boards[board.board] = board
|
boards[board.board] = board
|
||||||
$.set 'boardsJSON', {boards, lastChecked: Date.now()}
|
$.set 'boardConfig', {boards, lastChecked: Date.now()}
|
||||||
else
|
else
|
||||||
{boards} = Conf['boardsJSON']
|
{boards} = Conf['boardConfig']
|
||||||
new Notice 'warning', "Failed to load boards JSON. Error #{@statusText} (#{@status})", 20
|
new Notice 'warning', "Failed to load board configuration data. Error #{@statusText} (#{@status})", 20
|
||||||
BoardsJSON.set boards
|
BoardConfig.set boards
|
||||||
|
|
||||||
set: (@boards) ->
|
set: (@boards) ->
|
||||||
for ID, board of @boards
|
for ID, board of @boards
|
||||||
g.boards[ID]?.json = board
|
g.boards[ID]?.config = board
|
||||||
for cb in @cbs
|
for cb in @cbs
|
||||||
$.queueTask cb
|
$.queueTask cb
|
||||||
return
|
return
|
||||||
@ -36,7 +36,7 @@ Main =
|
|||||||
|
|
||||||
for db in DataBoard.keys
|
for db in DataBoard.keys
|
||||||
Conf[db] = boards: {}
|
Conf[db] = boards: {}
|
||||||
Conf['boardsJSON'] = boards: {}
|
Conf['boardConfig'] = boards: {}
|
||||||
Conf['selectedArchives'] = {}
|
Conf['selectedArchives'] = {}
|
||||||
Conf['cooldowns'] = {}
|
Conf['cooldowns'] = {}
|
||||||
|
|
||||||
@ -358,7 +358,7 @@ Main =
|
|||||||
|
|
||||||
features: [
|
features: [
|
||||||
['Polyfill', Polyfill]
|
['Polyfill', Polyfill]
|
||||||
['Boards JSON', BoardsJSON]
|
['Board Configuration', BoardConfig]
|
||||||
['Normalize URL', NormalizeURL]
|
['Normalize URL', NormalizeURL]
|
||||||
['Captcha Configuration', Captcha.replace]
|
['Captcha Configuration', Captcha.replace]
|
||||||
['Redirect', Redirect]
|
['Redirect', Redirect]
|
||||||
|
|||||||
@ -182,7 +182,7 @@ Settings =
|
|||||||
# Make sure to export the most recent data.
|
# Make sure to export the most recent data.
|
||||||
$.get Conf, (Conf) ->
|
$.get Conf, (Conf) ->
|
||||||
# Don't export cached JSON data.
|
# Don't export cached JSON data.
|
||||||
delete Conf['boardsJSON']
|
delete Conf['boardConfig']
|
||||||
Settings.downloadExport {version: g.VERSION, date: Date.now(), Conf}
|
Settings.downloadExport {version: g.VERSION, date: Date.now(), Conf}
|
||||||
|
|
||||||
downloadExport: (data) ->
|
downloadExport: (data) ->
|
||||||
|
|||||||
@ -4,6 +4,6 @@ class Board
|
|||||||
constructor: (@ID) ->
|
constructor: (@ID) ->
|
||||||
@threads = new SimpleDict()
|
@threads = new SimpleDict()
|
||||||
@posts = new SimpleDict()
|
@posts = new SimpleDict()
|
||||||
@json = BoardsJSON.boards?[@ID]
|
@config = BoardConfig.boards?[@ID]
|
||||||
|
|
||||||
g.boards[@] = @
|
g.boards[@] = @
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user