JSON Navigation -> JSON Index. #614
This commit is contained in:
parent
fb1009642f
commit
3a9fa8d98f
@ -1,6 +1,6 @@
|
||||
ThreadHiding =
|
||||
init: ->
|
||||
return if g.VIEW not in ['index', 'catalog'] or !Conf['Thread Hiding Buttons'] and !(Conf['Menu'] and Conf['Thread Hiding Link']) and !Conf['JSON Navigation']
|
||||
return if g.VIEW not in ['index', 'catalog'] or !Conf['Thread Hiding Buttons'] and !(Conf['Menu'] and Conf['Thread Hiding Link']) and !Conf['JSON Index']
|
||||
@db = new DataBoard 'hiddenThreads'
|
||||
return @catalogWatch() if g.VIEW is 'catalog'
|
||||
@catalogSet g.BOARD
|
||||
@ -74,7 +74,7 @@ ThreadHiding =
|
||||
el: div
|
||||
order: 20
|
||||
open: ({thread, isReply}) ->
|
||||
if isReply or thread.isHidden or Conf['JSON Navigation'] and Conf['Index Mode'] is 'catalog'
|
||||
if isReply or thread.isHidden or Conf['JSON Index'] and Conf['Index Mode'] is 'catalog'
|
||||
return false
|
||||
ThreadHiding.menu.thread = thread
|
||||
true
|
||||
@ -90,7 +90,7 @@ ThreadHiding =
|
||||
el: div
|
||||
order: 20
|
||||
open: ({thread, isReply}) ->
|
||||
if isReply or !thread.isHidden or Conf['JSON Navigation'] and Conf['Index Mode'] is 'catalog'
|
||||
if isReply or !thread.isHidden or Conf['JSON Index'] and Conf['Index Mode'] is 'catalog'
|
||||
return false
|
||||
ThreadHiding.menu.thread = thread
|
||||
true
|
||||
@ -104,7 +104,7 @@ ThreadHiding =
|
||||
el: hideStubLink
|
||||
order: 15
|
||||
open: ({thread, isReply}) ->
|
||||
if isReply or !thread.isHidden or Conf['JSON Navigation'] and Conf['Index Mode'] is 'catalog'
|
||||
if isReply or !thread.isHidden or Conf['JSON Index'] and Conf['Index Mode'] is 'catalog'
|
||||
return false
|
||||
ThreadHiding.menu.thread = thread
|
||||
|
||||
@ -176,7 +176,7 @@ ThreadHiding =
|
||||
return if thread.isHidden
|
||||
threadRoot = thread.OP.nodes.root.parentNode
|
||||
thread.isHidden = true
|
||||
Index.updateHideLabel() if Conf['JSON Navigation']
|
||||
Index.updateHideLabel() if Conf['JSON Index']
|
||||
|
||||
return threadRoot.hidden = true unless makeStub
|
||||
|
||||
@ -188,4 +188,4 @@ ThreadHiding =
|
||||
delete thread.stub
|
||||
threadRoot = thread.OP.nodes.root.parentNode
|
||||
threadRoot.hidden = thread.isHidden = false
|
||||
Index.updateHideLabel() if Conf['JSON Navigation']
|
||||
Index.updateHideLabel() if Conf['JSON Index']
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
Config =
|
||||
main:
|
||||
'Miscellaneous':
|
||||
'JSON Navigation': [
|
||||
'JSON Index': [
|
||||
true
|
||||
'Replace the original board index with one supporting searching, sorting, infinite scrolling, and a catalog mode.'
|
||||
]
|
||||
@ -66,7 +66,7 @@ Config =
|
||||
]
|
||||
'Comment Expansion': [
|
||||
true
|
||||
'Expand comments that are too long to display on the index. Not applicable with JSON Navigation.'
|
||||
'Expand comments that are too long to display on the index. Not applicable with JSON Index.'
|
||||
]
|
||||
'File Info Formatting': [
|
||||
true
|
||||
|
||||
@ -3,7 +3,7 @@ Index =
|
||||
changed: {}
|
||||
|
||||
init: ->
|
||||
return if g.BOARD.ID is 'f' or !Conf['JSON Navigation'] or g.VIEW isnt 'index'
|
||||
return if g.BOARD.ID is 'f' or !Conf['JSON Index'] or g.VIEW isnt 'index'
|
||||
|
||||
CatalogThread.callbacks.push
|
||||
name: 'Catalog Features'
|
||||
@ -150,7 +150,7 @@ Index =
|
||||
|
||||
menu:
|
||||
init: ->
|
||||
return if g.VIEW isnt 'index' or !Conf['JSON Navigation'] or !Conf['Menu'] or !Conf['Thread Hiding Link'] or g.BOARD.ID is 'f'
|
||||
return if g.VIEW isnt 'index' or !Conf['JSON Index'] or !Conf['Menu'] or !Conf['Thread Hiding Link'] or g.BOARD.ID is 'f'
|
||||
|
||||
Menu.menu.addEntry
|
||||
el: $.el 'a',
|
||||
|
||||
@ -219,7 +219,7 @@ Main =
|
||||
new Notice 'warning', msg
|
||||
|
||||
# Parse HTML or skip it and start building from JSON.
|
||||
unless Conf['JSON Navigation'] and g.VIEW is 'index'
|
||||
unless Conf['JSON Index'] and g.VIEW is 'index'
|
||||
Main.initThread()
|
||||
else
|
||||
Main.expectInitFinished = true
|
||||
|
||||
@ -348,6 +348,9 @@ Settings =
|
||||
if compareString < '00001.00011.00022.00002'
|
||||
if not data['Use Recaptcha v1 in Reports']? and data['Use Recaptcha v1'] and not data['Use Recaptcha v2 in Reports']
|
||||
set 'Use Recaptcha v1 in Reports', true
|
||||
if compareString < '00001.00011.00024.00000'
|
||||
if data['JSON Navigation']? and not data['JSON Index']?
|
||||
set 'JSON Index', data['JSON Navigation']
|
||||
changes
|
||||
loadSettings: (data, cb) ->
|
||||
if data.version.split('.')[0] is '2' # https://github.com/loadletter/4chan-x
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
CatalogLinks =
|
||||
init: ->
|
||||
if (Conf['External Catalog'] or Conf['JSON Navigation']) and !(Conf['JSON Navigation'] and g.VIEW is 'index')
|
||||
if (Conf['External Catalog'] or Conf['JSON Index']) and !(Conf['JSON Index'] and g.VIEW is 'index')
|
||||
selector = switch g.VIEW
|
||||
when 'thread', 'archive' then '.navLinks.desktop > a'
|
||||
when 'catalog' then '.navLinks > :first-child > a'
|
||||
@ -9,18 +9,18 @@ CatalogLinks =
|
||||
for link in $$ selector
|
||||
switch link.pathname.replace /\/+/g, '/'
|
||||
when "/#{g.BOARD}/"
|
||||
link.textContent = 'Index' if Conf['JSON Navigation']
|
||||
link.textContent = 'Index' if Conf['JSON Index']
|
||||
link.href = CatalogLinks.index()
|
||||
when "/#{g.BOARD}/catalog"
|
||||
link.href = CatalogLinks.catalog()
|
||||
if g.VIEW is 'catalog' and Conf['JSON Navigation'] and Conf['Use <%= meta.name %> Catalog']
|
||||
if g.VIEW is 'catalog' and Conf['JSON Index'] and Conf['Use <%= meta.name %> Catalog']
|
||||
catalogLink = link.parentNode.cloneNode true
|
||||
catalogLink.firstElementChild.textContent = '<%= meta.name %> Catalog'
|
||||
catalogLink.firstElementChild.href = CatalogLinks.catalog()
|
||||
$.after link.parentNode, [$.tn(' '), catalogLink]
|
||||
return
|
||||
|
||||
if Conf['JSON Navigation'] and Conf['Use <%= meta.name %> Catalog']
|
||||
if Conf['JSON Index'] and Conf['Use <%= meta.name %> Catalog']
|
||||
Post.callbacks.push
|
||||
name: 'Catalog Link Rewrite'
|
||||
cb: @node
|
||||
@ -73,13 +73,13 @@ CatalogLinks =
|
||||
catalog: (board=g.BOARD.ID) ->
|
||||
if Conf['External Catalog'] and board in ['a', 'c', 'g', 'biz', 'k', 'm', 'o', 'p', 'v', 'vg', 'vr', 'w', 'wg', 'cm', '3', 'adv', 'an', 'asp', 'cgl', 'ck', 'co', 'diy', 'fa', 'fit', 'gd', 'int', 'jp', 'lit', 'mlp', 'mu', 'n', 'out', 'po', 'sci', 'sp', 'tg', 'toy', 'trv', 'tv', 'vp', 'wsg', 'x', 'f', 'pol', 's4s', 'lgbt']
|
||||
"http://catalog.neet.tv/#{board}/"
|
||||
else if Conf['JSON Navigation'] and Conf['Use <%= meta.name %> Catalog']
|
||||
else if Conf['JSON Index'] and Conf['Use <%= meta.name %> Catalog']
|
||||
if g.BOARD.ID is board and g.VIEW is 'index' then '#catalog' else "/#{board}/#catalog"
|
||||
else
|
||||
"/#{board}/catalog"
|
||||
|
||||
index: (board=g.BOARD.ID) ->
|
||||
if Conf['JSON Navigation'] and board isnt 'f'
|
||||
if Conf['JSON Index'] and board isnt 'f'
|
||||
if g.BOARD.ID is board and g.VIEW is 'index' then '#index' else "/#{board}/#index"
|
||||
else
|
||||
"/#{board}/"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
ExpandComment =
|
||||
init: ->
|
||||
return if g.VIEW isnt 'index' or !Conf['Comment Expansion'] or Conf['JSON Navigation']
|
||||
return if g.VIEW isnt 'index' or !Conf['Comment Expansion'] or Conf['JSON Index']
|
||||
|
||||
@callbacks.push Fourchan.code if g.BOARD.ID is 'g'
|
||||
@callbacks.push Fourchan.math if g.BOARD.ID is 'sci'
|
||||
|
||||
@ -2,7 +2,7 @@ ExpandThread =
|
||||
statuses: {}
|
||||
init: ->
|
||||
return if g.VIEW is 'thread' or !Conf['Thread Expansion']
|
||||
if Conf['JSON Navigation']
|
||||
if Conf['JSON Index']
|
||||
$.on d, 'IndexRefresh', @onIndexRefresh
|
||||
else
|
||||
Thread.callbacks.push
|
||||
@ -62,7 +62,7 @@ ExpandThread =
|
||||
return
|
||||
|
||||
replies = $$ '.thread > .replyContainer', threadRoot
|
||||
if !Conf['JSON Navigation'] or Conf['Show Replies']
|
||||
if !Conf['JSON Index'] or Conf['Show Replies']
|
||||
num = if thread.isSticky
|
||||
1
|
||||
else switch g.BOARD.ID
|
||||
|
||||
@ -23,7 +23,7 @@ Keybinds =
|
||||
return unless /(Esc|Alt|Ctrl|Meta|Shift\+\w{2,})/.test(key) and not /^Alt\+(\d|Up|Down|Left|Right)$/.test(key)
|
||||
unless (
|
||||
g.VIEW not in ['index', 'thread'] or
|
||||
g.VIEW is 'index' and Conf['JSON Navigation'] and Conf['Index Mode'] is 'catalog' or
|
||||
g.VIEW is 'index' and Conf['JSON Index'] and Conf['Index Mode'] is 'catalog' or
|
||||
g.VIEW is 'index' and g.BOARD.ID is 'f'
|
||||
)
|
||||
threadRoot = Nav.getThread()
|
||||
@ -87,7 +87,7 @@ Keybinds =
|
||||
return unless Conf['Thread Updater']
|
||||
ThreadUpdater.update()
|
||||
when 'index'
|
||||
return unless Conf['JSON Navigation'] and g.BOARD.ID isnt 'f'
|
||||
return unless Conf['JSON Index'] and g.BOARD.ID isnt 'f'
|
||||
Index.update()
|
||||
else
|
||||
return
|
||||
@ -112,7 +112,7 @@ Keybinds =
|
||||
FappeTyme.toggle 'werk'
|
||||
# Board Navigation
|
||||
when Conf['Front page']
|
||||
if Conf['JSON Navigation'] and g.VIEW is 'index' and g.BOARD.ID isnt 'f'
|
||||
if Conf['JSON Index'] and g.VIEW is 'index' and g.BOARD.ID isnt 'f'
|
||||
Index.userPageNav 1
|
||||
else
|
||||
window.location = "/#{g.BOARD}/"
|
||||
@ -120,7 +120,7 @@ Keybinds =
|
||||
$.open "/#{g.BOARD}/"
|
||||
when Conf['Next page']
|
||||
return unless g.VIEW is 'index' and g.BOARD.ID isnt 'f'
|
||||
if Conf['JSON Navigation']
|
||||
if Conf['JSON Index']
|
||||
return unless Conf['Index Mode'] in ['paged', 'infinite']
|
||||
$('.next button', Index.pagelist).click()
|
||||
else
|
||||
@ -128,7 +128,7 @@ Keybinds =
|
||||
window.location = form.action
|
||||
when Conf['Previous page']
|
||||
return unless g.VIEW is 'index' and g.BOARD.ID isnt 'f'
|
||||
if Conf['JSON Navigation']
|
||||
if Conf['JSON Index']
|
||||
return unless Conf['Index Mode'] in ['paged', 'infinite']
|
||||
$('.prev button', Index.pagelist).click()
|
||||
else
|
||||
@ -136,23 +136,23 @@ Keybinds =
|
||||
window.location = form.action
|
||||
when Conf['Search form']
|
||||
return unless g.VIEW is 'index' and g.BOARD.ID isnt 'f'
|
||||
searchInput = if Conf['JSON Navigation'] then Index.searchInput else $.id('search-box')
|
||||
searchInput = if Conf['JSON Index'] then Index.searchInput else $.id('search-box')
|
||||
Header.scrollToIfNeeded searchInput
|
||||
searchInput.focus()
|
||||
when Conf['Paged mode']
|
||||
return unless Conf['JSON Navigation'] and g.BOARD.ID isnt 'f'
|
||||
return unless Conf['JSON Index'] and g.BOARD.ID isnt 'f'
|
||||
window.location = if g.VIEW is 'index' then '#paged' else "/#{g.BOARD}/#paged"
|
||||
when Conf['Infinite scrolling mode']
|
||||
return unless Conf['JSON Navigation'] and g.BOARD.ID isnt 'f'
|
||||
return unless Conf['JSON Index'] and g.BOARD.ID isnt 'f'
|
||||
window.location = if g.VIEW is 'index' then '#infinite' else "/#{g.BOARD}/#infinite"
|
||||
when Conf['All pages mode']
|
||||
return unless Conf['JSON Navigation'] and g.BOARD.ID isnt 'f'
|
||||
return unless Conf['JSON Index'] and g.BOARD.ID isnt 'f'
|
||||
window.location = if g.VIEW is 'index' then '#all-pages' else "/#{g.BOARD}/#all-pages"
|
||||
when Conf['Open catalog']
|
||||
return if g.BOARD.ID is 'f'
|
||||
window.location = CatalogLinks.catalog()
|
||||
when Conf['Cycle sort type']
|
||||
return unless Conf['JSON Navigation'] and g.VIEW is 'index' and g.BOARD.ID isnt 'f'
|
||||
return unless Conf['JSON Index'] and g.VIEW is 'index' and g.BOARD.ID isnt 'f'
|
||||
Index.cycleSortType()
|
||||
# Thread Navigation
|
||||
when Conf['Next thread']
|
||||
|
||||
@ -3,7 +3,7 @@ RelativeDates =
|
||||
init: ->
|
||||
if (
|
||||
g.VIEW in ['index', 'thread'] and Conf['Relative Post Dates'] and !Conf['Relative Date Title'] or
|
||||
g.VIEW is 'index' and Conf['JSON Navigation'] and g.BOARD.ID isnt 'f'
|
||||
g.VIEW is 'index' and Conf['JSON Index'] and g.BOARD.ID isnt 'f'
|
||||
)
|
||||
@flush()
|
||||
$.on d, 'visibilitychange ThreadUpdate', @flush
|
||||
|
||||
@ -41,7 +41,7 @@ ThreadWatcher =
|
||||
|
||||
ThreadWatcher.fetchAuto()
|
||||
|
||||
if g.VIEW is 'index' and Conf['JSON Navigation'] and Conf['Menu'] and g.BOARD.ID isnt 'f'
|
||||
if g.VIEW is 'index' and Conf['JSON Index'] and Conf['Menu'] and g.BOARD.ID isnt 'f'
|
||||
Menu.menu.addEntry
|
||||
el: $.el 'a',
|
||||
href: 'javascript:;'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user