JSON Navigation -> JSON Index. #614

This commit is contained in:
ccd0 2016-01-27 00:07:44 -08:00
parent fb1009642f
commit 3a9fa8d98f
11 changed files with 35 additions and 32 deletions

View File

@ -1,6 +1,6 @@
ThreadHiding = ThreadHiding =
init: -> 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' @db = new DataBoard 'hiddenThreads'
return @catalogWatch() if g.VIEW is 'catalog' return @catalogWatch() if g.VIEW is 'catalog'
@catalogSet g.BOARD @catalogSet g.BOARD
@ -74,7 +74,7 @@ ThreadHiding =
el: div el: div
order: 20 order: 20
open: ({thread, isReply}) -> 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 return false
ThreadHiding.menu.thread = thread ThreadHiding.menu.thread = thread
true true
@ -90,7 +90,7 @@ ThreadHiding =
el: div el: div
order: 20 order: 20
open: ({thread, isReply}) -> 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 return false
ThreadHiding.menu.thread = thread ThreadHiding.menu.thread = thread
true true
@ -104,7 +104,7 @@ ThreadHiding =
el: hideStubLink el: hideStubLink
order: 15 order: 15
open: ({thread, isReply}) -> 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 return false
ThreadHiding.menu.thread = thread ThreadHiding.menu.thread = thread
@ -176,7 +176,7 @@ ThreadHiding =
return if thread.isHidden return if thread.isHidden
threadRoot = thread.OP.nodes.root.parentNode threadRoot = thread.OP.nodes.root.parentNode
thread.isHidden = true thread.isHidden = true
Index.updateHideLabel() if Conf['JSON Navigation'] Index.updateHideLabel() if Conf['JSON Index']
return threadRoot.hidden = true unless makeStub return threadRoot.hidden = true unless makeStub
@ -188,4 +188,4 @@ ThreadHiding =
delete thread.stub delete thread.stub
threadRoot = thread.OP.nodes.root.parentNode threadRoot = thread.OP.nodes.root.parentNode
threadRoot.hidden = thread.isHidden = false threadRoot.hidden = thread.isHidden = false
Index.updateHideLabel() if Conf['JSON Navigation'] Index.updateHideLabel() if Conf['JSON Index']

View File

@ -1,7 +1,7 @@
Config = Config =
main: main:
'Miscellaneous': 'Miscellaneous':
'JSON Navigation': [ 'JSON Index': [
true true
'Replace the original board index with one supporting searching, sorting, infinite scrolling, and a catalog mode.' 'Replace the original board index with one supporting searching, sorting, infinite scrolling, and a catalog mode.'
] ]
@ -66,7 +66,7 @@ Config =
] ]
'Comment Expansion': [ 'Comment Expansion': [
true 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': [ 'File Info Formatting': [
true true

View File

@ -3,7 +3,7 @@ Index =
changed: {} changed: {}
init: -> 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 CatalogThread.callbacks.push
name: 'Catalog Features' name: 'Catalog Features'
@ -150,7 +150,7 @@ Index =
menu: menu:
init: -> 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 Menu.menu.addEntry
el: $.el 'a', el: $.el 'a',

View File

@ -219,7 +219,7 @@ Main =
new Notice 'warning', msg new Notice 'warning', msg
# Parse HTML or skip it and start building from JSON. # 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() Main.initThread()
else else
Main.expectInitFinished = true Main.expectInitFinished = true

View File

@ -348,6 +348,9 @@ Settings =
if compareString < '00001.00011.00022.00002' 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'] 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 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 changes
loadSettings: (data, cb) -> loadSettings: (data, cb) ->
if data.version.split('.')[0] is '2' # https://github.com/loadletter/4chan-x if data.version.split('.')[0] is '2' # https://github.com/loadletter/4chan-x

View File

@ -1,6 +1,6 @@
CatalogLinks = CatalogLinks =
init: -> 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 selector = switch g.VIEW
when 'thread', 'archive' then '.navLinks.desktop > a' when 'thread', 'archive' then '.navLinks.desktop > a'
when 'catalog' then '.navLinks > :first-child > a' when 'catalog' then '.navLinks > :first-child > a'
@ -9,18 +9,18 @@ CatalogLinks =
for link in $$ selector for link in $$ selector
switch link.pathname.replace /\/+/g, '/' switch link.pathname.replace /\/+/g, '/'
when "/#{g.BOARD}/" when "/#{g.BOARD}/"
link.textContent = 'Index' if Conf['JSON Navigation'] link.textContent = 'Index' if Conf['JSON Index']
link.href = CatalogLinks.index() link.href = CatalogLinks.index()
when "/#{g.BOARD}/catalog" when "/#{g.BOARD}/catalog"
link.href = CatalogLinks.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 = link.parentNode.cloneNode true
catalogLink.firstElementChild.textContent = '<%= meta.name %> Catalog' catalogLink.firstElementChild.textContent = '<%= meta.name %> Catalog'
catalogLink.firstElementChild.href = CatalogLinks.catalog() catalogLink.firstElementChild.href = CatalogLinks.catalog()
$.after link.parentNode, [$.tn(' '), catalogLink] $.after link.parentNode, [$.tn(' '), catalogLink]
return return
if Conf['JSON Navigation'] and Conf['Use <%= meta.name %> Catalog'] if Conf['JSON Index'] and Conf['Use <%= meta.name %> Catalog']
Post.callbacks.push Post.callbacks.push
name: 'Catalog Link Rewrite' name: 'Catalog Link Rewrite'
cb: @node cb: @node
@ -73,13 +73,13 @@ CatalogLinks =
catalog: (board=g.BOARD.ID) -> 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'] 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}/" "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" if g.BOARD.ID is board and g.VIEW is 'index' then '#catalog' else "/#{board}/#catalog"
else else
"/#{board}/catalog" "/#{board}/catalog"
index: (board=g.BOARD.ID) -> 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" if g.BOARD.ID is board and g.VIEW is 'index' then '#index' else "/#{board}/#index"
else else
"/#{board}/" "/#{board}/"

View File

@ -1,6 +1,6 @@
ExpandComment = ExpandComment =
init: -> 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.code if g.BOARD.ID is 'g'
@callbacks.push Fourchan.math if g.BOARD.ID is 'sci' @callbacks.push Fourchan.math if g.BOARD.ID is 'sci'

View File

@ -2,7 +2,7 @@ ExpandThread =
statuses: {} statuses: {}
init: -> init: ->
return if g.VIEW is 'thread' or !Conf['Thread Expansion'] return if g.VIEW is 'thread' or !Conf['Thread Expansion']
if Conf['JSON Navigation'] if Conf['JSON Index']
$.on d, 'IndexRefresh', @onIndexRefresh $.on d, 'IndexRefresh', @onIndexRefresh
else else
Thread.callbacks.push Thread.callbacks.push
@ -62,7 +62,7 @@ ExpandThread =
return return
replies = $$ '.thread > .replyContainer', threadRoot replies = $$ '.thread > .replyContainer', threadRoot
if !Conf['JSON Navigation'] or Conf['Show Replies'] if !Conf['JSON Index'] or Conf['Show Replies']
num = if thread.isSticky num = if thread.isSticky
1 1
else switch g.BOARD.ID else switch g.BOARD.ID

View File

@ -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) return unless /(Esc|Alt|Ctrl|Meta|Shift\+\w{2,})/.test(key) and not /^Alt\+(\d|Up|Down|Left|Right)$/.test(key)
unless ( unless (
g.VIEW not in ['index', 'thread'] or 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' g.VIEW is 'index' and g.BOARD.ID is 'f'
) )
threadRoot = Nav.getThread() threadRoot = Nav.getThread()
@ -87,7 +87,7 @@ Keybinds =
return unless Conf['Thread Updater'] return unless Conf['Thread Updater']
ThreadUpdater.update() ThreadUpdater.update()
when 'index' 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() Index.update()
else else
return return
@ -112,7 +112,7 @@ Keybinds =
FappeTyme.toggle 'werk' FappeTyme.toggle 'werk'
# Board Navigation # Board Navigation
when Conf['Front page'] 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 Index.userPageNav 1
else else
window.location = "/#{g.BOARD}/" window.location = "/#{g.BOARD}/"
@ -120,7 +120,7 @@ Keybinds =
$.open "/#{g.BOARD}/" $.open "/#{g.BOARD}/"
when Conf['Next page'] when Conf['Next page']
return unless g.VIEW is 'index' and g.BOARD.ID isnt 'f' 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'] return unless Conf['Index Mode'] in ['paged', 'infinite']
$('.next button', Index.pagelist).click() $('.next button', Index.pagelist).click()
else else
@ -128,7 +128,7 @@ Keybinds =
window.location = form.action window.location = form.action
when Conf['Previous page'] when Conf['Previous page']
return unless g.VIEW is 'index' and g.BOARD.ID isnt 'f' 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'] return unless Conf['Index Mode'] in ['paged', 'infinite']
$('.prev button', Index.pagelist).click() $('.prev button', Index.pagelist).click()
else else
@ -136,23 +136,23 @@ Keybinds =
window.location = form.action window.location = form.action
when Conf['Search form'] when Conf['Search form']
return unless g.VIEW is 'index' and g.BOARD.ID isnt 'f' 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 Header.scrollToIfNeeded searchInput
searchInput.focus() searchInput.focus()
when Conf['Paged mode'] 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" window.location = if g.VIEW is 'index' then '#paged' else "/#{g.BOARD}/#paged"
when Conf['Infinite scrolling mode'] 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" window.location = if g.VIEW is 'index' then '#infinite' else "/#{g.BOARD}/#infinite"
when Conf['All pages mode'] 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" window.location = if g.VIEW is 'index' then '#all-pages' else "/#{g.BOARD}/#all-pages"
when Conf['Open catalog'] when Conf['Open catalog']
return if g.BOARD.ID is 'f' return if g.BOARD.ID is 'f'
window.location = CatalogLinks.catalog() window.location = CatalogLinks.catalog()
when Conf['Cycle sort type'] 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() Index.cycleSortType()
# Thread Navigation # Thread Navigation
when Conf['Next thread'] when Conf['Next thread']

View File

@ -3,7 +3,7 @@ RelativeDates =
init: -> init: ->
if ( if (
g.VIEW in ['index', 'thread'] and Conf['Relative Post Dates'] and !Conf['Relative Date Title'] or 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() @flush()
$.on d, 'visibilitychange ThreadUpdate', @flush $.on d, 'visibilitychange ThreadUpdate', @flush

View File

@ -41,7 +41,7 @@ ThreadWatcher =
ThreadWatcher.fetchAuto() 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 Menu.menu.addEntry
el: $.el 'a', el: $.el 'a',
href: 'javascript:;' href: 'javascript:;'