diff --git a/src/Archive/Redirect.coffee b/src/Archive/Redirect.coffee index bb63f09ae..27593edd1 100644 --- a/src/Archive/Redirect.coffee +++ b/src/Archive/Redirect.coffee @@ -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] diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee index 8f7cc2d5c..ed05ebf42 100644 --- a/src/General/Settings.coffee +++ b/src/General/Settings.coffee @@ -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]