Add a button to update the archive list. Also display the last update time.

This commit is contained in:
Mayhem 2013-05-13 00:21:12 +02:00
parent ebfa224fe3
commit e9b8db87d8
3 changed files with 17 additions and 1 deletions

View File

@ -1,5 +1,6 @@
<div class="warning" #{if Conf['404 Redirect'] then 'hidden' else ''}><code>404 Redirect</code> is disabled.</div>
<p>Disabled selections indicate that only one archive is available for that board and redirection type.</p>
<p><button>Update now</button> Last updated: <time></time></p>
<table>
<caption>Archived boards</caption>
<thead>

View File

@ -34,7 +34,7 @@ Redirect =
Redirect.file[boardID] = archive
return
update: ->
update: (cb) ->
$.get 'lastarchivecheck', 0, ({lastarchivecheck}) ->
now = Date.now()
# Update the list of archives every 4 days.
@ -46,6 +46,7 @@ Redirect =
$.set
lastarchivecheck: now
archives: Conf['archives']
cb now if cb
to: (dest, data) ->
archive = (if dest is 'search' then Redirect.thread else Redirect[dest])[data.boardID]

View File

@ -399,6 +399,20 @@ Settings =
<%= grunt.file.read('html/General/Settings-section-Archives.html').replace(/>\s+</g, '><').trim() %>
"""
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) ->
button.textContent = 'Updated'
showLastUpdateTime time
$.get 'lastarchivecheck', 0, ({lastarchivecheck}) -> showLastUpdateTime lastarchivecheck
boards = {}
for archive in Conf['archives']
for boardID in archive.boards