Update the archives settings tab when manually updating the archives list.
This commit is contained in:
parent
b0e4238938
commit
da203ae76a
@ -33,12 +33,12 @@ Redirect =
|
|||||||
# The list is also updated when 4chan X gets updated.
|
# The list is also updated when 4chan X gets updated.
|
||||||
return if lastarchivecheck > now - 2 * $.DAY
|
return if lastarchivecheck > now - 2 * $.DAY
|
||||||
$.ajax '<%= meta.page %>json/archives.json', onload: ->
|
$.ajax '<%= meta.page %>json/archives.json', onload: ->
|
||||||
return unless @status is 200
|
if @status is 200
|
||||||
Conf['archives'] = JSON.parse @response
|
Conf['archives'] = JSON.parse @response
|
||||||
$.set
|
$.set
|
||||||
lastarchivecheck: now
|
lastarchivecheck: now
|
||||||
archives: Conf['archives']
|
archives: Conf['archives']
|
||||||
cb? now
|
cb?()
|
||||||
|
|
||||||
to: (dest, data) ->
|
to: (dest, data) ->
|
||||||
archive = (if dest is 'search' then Redirect.data.thread else Redirect.data[dest])[data.boardID]
|
archive = (if dest is 'search' then Redirect.data.thread else Redirect.data[dest])[data.boardID]
|
||||||
|
|||||||
@ -383,20 +383,17 @@ Settings =
|
|||||||
archives: (section) ->
|
archives: (section) ->
|
||||||
section.innerHTML = <%= importHTML('General/Settings-section-Archives') %>
|
section.innerHTML = <%= importHTML('General/Settings-section-Archives') %>
|
||||||
|
|
||||||
showLastUpdateTime = (time) ->
|
|
||||||
$('time', section).textContent = new Date(time).toLocaleString()
|
|
||||||
|
|
||||||
button = $ 'button', section
|
button = $ 'button', section
|
||||||
$.on button, 'click', ->
|
$.on button, 'click', ->
|
||||||
$.delete 'lastarchivecheck'
|
$.delete 'lastarchivecheck'
|
||||||
button.textContent = '...'
|
button.textContent = '...'
|
||||||
button.disabled = true
|
button.disabled = true
|
||||||
Redirect.update (time) ->
|
Redirect.update ->
|
||||||
button.textContent = 'Updated'
|
button.textContent = 'Updated'
|
||||||
showLastUpdateTime time
|
Settings.addArchivesTable section
|
||||||
|
|
||||||
$.get 'lastarchivecheck', 0, ({lastarchivecheck}) -> showLastUpdateTime lastarchivecheck
|
|
||||||
|
|
||||||
|
Settings.addArchivesTable section
|
||||||
|
addArchivesTable: (section) ->
|
||||||
boards = {}
|
boards = {}
|
||||||
for archive in Conf['archives']
|
for archive in Conf['archives']
|
||||||
for boardID in archive.boards
|
for boardID in archive.boards
|
||||||
@ -423,13 +420,18 @@ Settings =
|
|||||||
Settings.addArchiveCell row, boardID, data, 'thread'
|
Settings.addArchiveCell row, boardID, data, 'thread'
|
||||||
Settings.addArchiveCell row, boardID, data, 'post'
|
Settings.addArchiveCell row, boardID, data, 'post'
|
||||||
Settings.addArchiveCell row, boardID, data, 'file'
|
Settings.addArchiveCell row, boardID, data, 'file'
|
||||||
$.add $('tbody', section), rows
|
tbody = $ 'tbody', section
|
||||||
$.get 'selectedArchives', Conf['selectedArchives'], ({selectedArchives}) ->
|
$.rmAll tbody
|
||||||
|
$.add tbody, rows
|
||||||
|
$.get {
|
||||||
|
lastarchivecheck: 0
|
||||||
|
selectedArchives: Conf['selectedArchives']
|
||||||
|
}, ({lastarchivecheck, selectedArchives}) ->
|
||||||
for boardID, data of selectedArchives
|
for boardID, data of selectedArchives
|
||||||
for type, uid of data
|
for type, uid of data
|
||||||
if option = $ "select[data-board-i-d='#{boardID}'][data-type='#{type}'] > option[value='#{uid}']", section
|
if option = $ "select[data-board-i-d='#{boardID}'][data-type='#{type}'] > option[value='#{uid}']", section
|
||||||
option.selected = true
|
option.selected = true
|
||||||
return
|
$('time', section).textContent = new Date(lastarchivecheck).toLocaleString()
|
||||||
addArchiveCell: (row, boardID, data, type) ->
|
addArchiveCell: (row, boardID, data, type) ->
|
||||||
options = []
|
options = []
|
||||||
for archive in data[type]
|
for archive in data[type]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user