Toggle the pagelist visibility via CSS to avoid a crash when the index update is done before the element exists.

Also only send the If-Modified-Since HTTP header when we have something significant to send.
This commit is contained in:
Mayhem 2013-11-01 13:57:24 +01:00
parent 855b7f0173
commit 7e8fd31733
3 changed files with 8 additions and 3 deletions

View File

@ -363,7 +363,8 @@ a[href="javascript:;"] {
} }
/* Index */ /* Index */
:root.index-loading .board { :root.index-loading .board,
:root.index-hide-pagelist .pagelist {
display: none; display: none;
} }

View File

@ -45,7 +45,7 @@ $.ajax = do ->
type or= form and 'post' or 'get' type or= form and 'post' or 'get'
r.open type, url, !sync r.open type, url, !sync
if whenModified if whenModified
r.setRequestHeader 'If-Modified-Since', lastModified[url] or '0' r.setRequestHeader 'If-Modified-Since', lastModified[url] if url of lastModified
$.on r, 'load', -> lastModified[url] = r.getResponseHeader 'Last-Modified' $.on r, 'load', -> lastModified[url] = r.getResponseHeader 'Last-Modified'
$.extend r, options $.extend r, options
$.extend r.upload, upCallbacks $.extend r.upload, upCallbacks

View File

@ -44,6 +44,7 @@ Index =
subEntries: [modeEntry, sortEntry] subEntries: [modeEntry, sortEntry]
$.addClass doc, 'index-loading' $.addClass doc, 'index-loading'
Index.togglePagelist()
Index.root = $.el 'div', className: 'board' Index.root = $.el 'div', className: 'board'
Index.update() Index.update()
$.asap (-> $('.board', doc) or d.readyState isnt 'loading'), -> $.asap (-> $('.board', doc) or d.readyState isnt 'loading'), ->
@ -52,11 +53,15 @@ Index =
cb: cb:
mode: -> mode: ->
Index.togglePagelist()
Index.buildIndex() Index.buildIndex()
sort: -> sort: ->
Index.sort() Index.sort()
Index.buildIndex() Index.buildIndex()
togglePagelist: ->
(if Conf['Index Mode'] is 'paged' then $.rmClass else $.addClass) doc, 'index-hide-pagelist'
update: -> update: ->
return unless navigator.onLine return unless navigator.onLine
Index.req?.abort() Index.req?.abort()
@ -170,4 +175,3 @@ Index =
$.event 'IndexRefresh' $.event 'IndexRefresh'
$.rmAll Index.root $.rmAll Index.root
$.add Index.root, nodes $.add Index.root, nodes
$('.pagelist').hidden = Conf['Index Mode'] isnt 'paged'