fix catalog reverting to index on refresh

This commit is contained in:
ccd0 2014-09-21 11:10:46 -07:00
parent 78483f7eec
commit 736242bf10

View File

@ -235,20 +235,23 @@ Index =
Index.sort() Index.sort()
Index.buildIndex() Index.buildIndex()
hashchange: (e) -> hashchange: (e) ->
switch command = location.hash[1..] {pathname, hash} = location
switch command = hash[1..]
when 'paged', 'infinite', 'all-pages', 'catalog' when 'paged', 'infinite', 'all-pages', 'catalog'
mode = command.replace /-/g, ' ' mode = command.replace /-/g, ' '
when 'index' when 'index'
mode = Conf['Previous Index Mode'] mode = Conf['Previous Index Mode']
if mode if mode
Index.setMode mode Index.setMode mode
history.replaceState {mode}, '', if Index.currentPage is 1 then './' else Index.currentPage pathname = if Index.currentPage is 1 then './' else Index.currentPage
if e hash = ''
# hash change, not call from init if Conf['Use 4chan X Catalog'] and Conf['Index Mode'] is 'catalog'
Index.buildIndex() hash = '#catalog'
Index.setPage() history.replaceState {mode: Conf['Index Mode']}, '', pathname + hash
return if mode and e
history.replaceState {mode: Conf['Index Mode']}, '' # hash change, not call from init
Index.buildIndex()
Index.setPage()
popstate: (e) -> popstate: (e) ->
unless e?.state unless e?.state
# page load or hash change # page load or hash change