Update the archives settings tab when manually updating the archives list.

This commit is contained in:
Mayhem 2014-01-19 00:25:01 +01:00
parent b0e4238938
commit da203ae76a
2 changed files with 18 additions and 16 deletions

View File

@ -33,12 +33,12 @@ Redirect =
# The list is also updated when 4chan X gets updated.
return if lastarchivecheck > now - 2 * $.DAY
$.ajax '<%= meta.page %>json/archives.json', onload: ->
return unless @status is 200
Conf['archives'] = JSON.parse @response
$.set
lastarchivecheck: now
archives: Conf['archives']
cb? now
if @status is 200
Conf['archives'] = JSON.parse @response
$.set
lastarchivecheck: now
archives: Conf['archives']
cb?()
to: (dest, data) ->
archive = (if dest is 'search' then Redirect.data.thread else Redirect.data[dest])[data.boardID]

View File

@ -383,20 +383,17 @@ Settings =
archives: (section) ->
section.innerHTML = <%= importHTML('General/Settings-section-Archives') %>
showLastUpdateTime = (time) ->
$('time', section).textContent = new Date(time).toLocaleString()
button = $ 'button', section
$.on button, 'click', ->
$.delete 'lastarchivecheck'
button.textContent = '...'
button.disabled = true
Redirect.update (time) ->
Redirect.update ->
button.textContent = 'Updated'
showLastUpdateTime time
$.get 'lastarchivecheck', 0, ({lastarchivecheck}) -> showLastUpdateTime lastarchivecheck
Settings.addArchivesTable section
Settings.addArchivesTable section
addArchivesTable: (section) ->
boards = {}
for archive in Conf['archives']
for boardID in archive.boards
@ -423,13 +420,18 @@ Settings =
Settings.addArchiveCell row, boardID, data, 'thread'
Settings.addArchiveCell row, boardID, data, 'post'
Settings.addArchiveCell row, boardID, data, 'file'
$.add $('tbody', section), rows
$.get 'selectedArchives', Conf['selectedArchives'], ({selectedArchives}) ->
tbody = $ 'tbody', section
$.rmAll tbody
$.add tbody, rows
$.get {
lastarchivecheck: 0
selectedArchives: Conf['selectedArchives']
}, ({lastarchivecheck, selectedArchives}) ->
for boardID, data of selectedArchives
for type, uid of data
if option = $ "select[data-board-i-d='#{boardID}'][data-type='#{type}'] > option[value='#{uid}']", section
option.selected = true
return
$('time', section).textContent = new Date(lastarchivecheck).toLocaleString()
addArchiveCell: (row, boardID, data, type) ->
options = []
for archive in data[type]