Remove all inline catalog-related code.

This commit is contained in:
Mayhem 2014-01-29 16:25:52 +01:00
parent e95035a17f
commit 1aa467b051
40 changed files with 35 additions and 142 deletions

View File

@ -1,4 +1,3 @@
[<a href="./catalog">Catalog</a>]&nbsp;
[<time id="index-last-refresh" title="Last index refresh">...</time>]&nbsp;
<input type="search" id="index-search" class="field" placeholder="Search">
<a id="index-search-clear" class="fa fa-times-circle" href="javascript:;"></a>

View File

@ -9,6 +9,3 @@
<button disabled>Next</button>
</a>
</div>
<div class="pages cataloglink">
<a href="./catalog">Catalog</a>
</div>

View File

@ -7,9 +7,6 @@
<div>Board link (Replace with title when on that board): <code>board-replace</code></div>
<div>Full text link: <code>board-full</code></div>
<div>Custom text link: <code>board-text:"VIP Board"</code></div>
<div>Index-only link: <code>board-index</code></div>
<div>Catalog-only link: <code>board-catalog</code></div>
<div>Combinations are possible: <code>board-index-text:"VIP Index"</code></div>
<div>Full board list toggle: <code>toggle-all</code></div>
</fieldset>

View File

@ -1,7 +1,7 @@
Filter =
filters: {}
init: ->
return if g.VIEW is 'catalog' or !Conf['Filter']
return if !Conf['Filter']
for key of Config.filter
@filters[key] = []
@ -166,7 +166,7 @@ Filter =
menu:
init: ->
return if g.VIEW is 'catalog' or !Conf['Menu'] or !Conf['Filter']
return if !Conf['Menu'] or !Conf['Filter']
div = $.el 'div',
textContent: 'Filter'

View File

@ -1,6 +1,6 @@
PostHiding =
init: ->
return if g.VIEW is 'catalog' or !Conf['Reply Hiding'] and !Conf['Reply Hiding Link']
return if !Conf['Reply Hiding'] and !Conf['Reply Hiding Link']
@db = new DataBoard 'hiddenPosts'
Post.callbacks.push
@ -20,7 +20,7 @@ PostHiding =
menu:
init: ->
return if g.VIEW is 'catalog' or !Conf['Menu'] or !Conf['Reply Hiding Link']
return if !Conf['Menu'] or !Conf['Reply Hiding Link']
# Hide
div = $.el 'div',

View File

@ -1,8 +1,6 @@
Recursive =
recursives: {}
init: ->
return if g.VIEW is 'catalog'
Post.callbacks.push
name: 'Recursive'
cb: @node

View File

@ -3,7 +3,6 @@ ThreadHiding =
return if g.VIEW isnt 'index'
@db = new DataBoard 'hiddenThreads'
@syncCatalog()
$.on d, 'IndexRefresh', @onIndexRefresh
Thread.callbacks.push
name: 'Thread Hiding'
@ -26,50 +25,6 @@ ThreadHiding =
ThreadHiding.makeStub thread, root
return
syncCatalog: ->
# Sync hidden threads from the catalog into the index.
hiddenThreads = ThreadHiding.db.get
boardID: g.BOARD.ID
defaultValue: {}
hiddenThreadsOnCatalog = JSON.parse(localStorage.getItem "4chan-hide-t-#{g.BOARD}") or {}
# Add threads that were hidden in the catalog.
for threadID of hiddenThreadsOnCatalog
unless threadID of hiddenThreads
hiddenThreads[threadID] = {}
# Remove threads that were un-hidden in the catalog.
for threadID of hiddenThreads
unless threadID of hiddenThreadsOnCatalog
delete hiddenThreads[threadID]
if (ThreadHiding.db.data.lastChecked or 0) > Date.now() - $.MINUTE
# Was cleaned just now.
ThreadHiding.cleanCatalog hiddenThreadsOnCatalog
unless Object.keys(hiddenThreads).length
ThreadHiding.db.delete boardID: g.BOARD.ID
return
ThreadHiding.db.set
boardID: g.BOARD.ID
val: hiddenThreads
cleanCatalog: (hiddenThreadsOnCatalog) ->
# We need to clean hidden threads on the catalog ourselves,
# otherwise if we don't visit the catalog regularly
# it will pollute the localStorage and our data.
$.cache "//a.4cdn.org/#{g.BOARD}/threads.json", ->
return unless @status is 200
threads = {}
for page in @response
for thread in page.threads
if thread.no of hiddenThreadsOnCatalog
threads[thread.no] = hiddenThreadsOnCatalog[thread.no]
if Object.keys(threads).length
localStorage.setItem "4chan-hide-t-#{g.BOARD}", JSON.stringify threads
else
localStorage.removeItem "4chan-hide-t-#{g.BOARD}"
menu:
init: ->
return if g.VIEW isnt 'index' or !Conf['Menu'] or !Conf['Thread Hiding Link']
@ -130,19 +85,15 @@ ThreadHiding =
$.prepend root, thread.stub
saveHiddenState: (thread, makeStub) ->
hiddenThreadsOnCatalog = JSON.parse(localStorage.getItem "4chan-hide-t-#{g.BOARD}") or {}
if thread.isHidden
ThreadHiding.db.set
boardID: thread.board.ID
threadID: thread.ID
val: {makeStub}
hiddenThreadsOnCatalog[thread] = true
else
ThreadHiding.db.delete
boardID: thread.board.ID
threadID: thread.ID
delete hiddenThreadsOnCatalog[thread]
localStorage.setItem "4chan-hide-t-#{g.BOARD}", JSON.stringify hiddenThreadsOnCatalog
toggle: (thread) ->
unless thread instanceof Thread

View File

@ -149,7 +149,6 @@ Config =
'Header auto-hide': false
'Header auto-hide on scroll': false
'Bottom header': false
'Header catalog links': false
'Top Board List': false
'Bottom Board List': false
'Custom Board Navigation': true

View File

@ -25,8 +25,6 @@ Header =
innerHTML: '<input type=checkbox name="Header auto-hide on scroll"> Auto-hide header on scroll'
barPositionToggler = $.el 'label',
innerHTML: '<input type=checkbox name="Bottom header"> Bottom header'
catalogToggler = $.el 'label',
innerHTML: '<input type=checkbox name="Header catalog links"> Use catalog board links'
topBoardToggler = $.el 'label',
innerHTML: '<input type=checkbox name="Top Board List"> Top original board list'
botBoardToggler = $.el 'label',
@ -40,7 +38,6 @@ Header =
@headerToggler = headerToggler.firstElementChild
@scrollHeaderToggler = scrollHeaderToggler.firstElementChild
@barPositionToggler = barPositionToggler.firstElementChild
@catalogToggler = catalogToggler.firstElementChild
@topBoardToggler = topBoardToggler.firstElementChild
@botBoardToggler = botBoardToggler.firstElementChild
@customNavToggler = customNavToggler.firstElementChild
@ -48,7 +45,6 @@ Header =
$.on @headerToggler, 'change', @toggleBarVisibility
$.on @scrollHeaderToggler, 'change', @toggleHideBarOnScroll
$.on @barPositionToggler, 'change', @toggleBarPosition
$.on @catalogToggler, 'change', @toggleCatalogLinks
$.on @topBoardToggler, 'change', @toggleOriginalBoardList
$.on @botBoardToggler, 'change', @toggleOriginalBoardList
$.on @customNavToggler, 'change', @toggleCustomNav
@ -74,7 +70,6 @@ Header =
{el: headerToggler}
{el: scrollHeaderToggler}
{el: barPositionToggler}
{el: catalogToggler}
{el: topBoardToggler}
{el: botBoardToggler}
{el: customNavToggler}
@ -92,9 +87,6 @@ Header =
if a = $ "a[href*='/#{g.BOARD}/']", $.id 'boardNavDesktopFoot'
a.className = 'current'
Header.setCatalogLinks Conf['Header catalog links']
$.sync 'Header catalog links', Header.setCatalogLinks
@enableDesktopNotifications()
setBoardList: ->
@ -121,7 +113,7 @@ Header =
$.rmAll list
return unless text
as = $$ '#full-board-list a[title]', Header.bar
nodes = text.match(/[\w@]+(-(all|title|replace|full|index|catalog|text:"[^"]+"))*|[^\w@]+/g).map (t) ->
nodes = text.match(/[\w@]+(-(all|title|replace|full|text:"[^"]+"))*|[^\w@]+/g).map (t) ->
if /^[^\w@]/.test t
return $.tn t
if /^toggle-all/.test t
@ -148,11 +140,6 @@ Header =
else
a.textContent
if m = t.match /-(index|catalog)/
a.dataset.only = m[1]
a.href = "//boards.4chan.org/#{board}/"
a.href += 'catalog' if m[1] is 'catalog'
$.addClass a, 'navSmall' if board is '@'
return a
$.tn t
@ -219,21 +206,6 @@ Header =
$.cb.checked.call @
Header.setBarPosition @checked
setCatalogLinks: (useCatalog) ->
Header.catalogToggler.checked = useCatalog
as = $$ [
'#board-list a'
'#boardNavDesktop a'
'#boardNavDesktopFoot a'
].join ', '
path = if useCatalog then 'catalog' else ''
for a in as when a.hostname is 'boards.4chan.org' and not a.dataset.only
a.pathname = "/#{a.pathname.split('/')[1]}/#{path}"
return
toggleCatalogLinks: ->
$.cb.checked.call @
Header.setCatalogLinks @checked
setTopBoardList: (show) ->
Header.topBoardToggler.checked = show
if show

View File

@ -1,15 +1,5 @@
Index =
init: ->
if g.VIEW is 'catalog'
$.ready ->
span = $.el 'a',
href: '<%= meta.repo %>blob/<%= meta.mainBranch %>/CHANGELOG.md'
textContent: 'Support for the official catalog to be removed'
title: '<%= meta.name %> now has a "catalog" Index mode.'
className: 'btn-wrap warning'
target: '_blank'
$.add $.id('info'), span
return if g.VIEW isnt 'index' or g.BOARD.ID is 'f'
@db = new DataBoard 'pinnedThreads'
@ -179,7 +169,6 @@ Index =
a = e.target
else
return
return if a.textContent is 'Catalog'
e.preventDefault()
Index.userPageNav +a.pathname.split('/')[2]

View File

@ -11,6 +11,8 @@ Main =
'catalog'
else
'index'
if g.VIEW is 'catalog'
return
if g.VIEW is 'thread'
g.THREADID = +pathname[3]
@ -131,10 +133,6 @@ Main =
$.addClass doc, 'fourchan-x', '<% if (type === 'crx') { %>blink<% } else { %>gecko<% } %>'
$.addStyle Main.css
if g.VIEW is 'catalog'
$.addClass doc, $.id('base-css').href.match(/catalog_(\w+)/)[1].replace('_new', '').replace /_+/g, '-'
return
style = 'yotsuba-b'
mainStyleSheet = $ 'link[title=switch]', d.head
styleSheets = $$ 'link[rel="alternate stylesheet"]', d.head

View File

@ -133,10 +133,7 @@ Settings =
button.textContent = "Hidden: #{hiddenNum}"
$.on button, 'click', ->
@textContent = 'Hidden: 0'
$.get 'hiddenThreads', {}, ({hiddenThreads}) ->
for boardID of hiddenThreads.boards
localStorage.removeItem "4chan-hide-t-#{boardID}"
$.delete ['hiddenThreads', 'hiddenPosts']
$.delete ['hiddenThreads', 'hiddenPosts']
$.after $('input[name="Stubs"]', section).parentNode.parentNode, div
export: ->
# Make sure to export the most recent data.

View File

@ -1,6 +1,6 @@
AutoGIF =
init: ->
return if g.VIEW is 'catalog' or !Conf['Auto-GIF'] or g.BOARD.ID in ['gif', 'wsg']
return if !Conf['Auto-GIF'] or g.BOARD.ID in ['gif', 'wsg']
Post.callbacks.push
name: 'Auto-GIF'

View File

@ -1,6 +1,6 @@
ImageExpand =
init: ->
return if g.VIEW is 'catalog' or !Conf['Image Expansion']
return if !Conf['Image Expansion']
@EAI = $.el 'a',
className: 'expand-all-shortcut fa fa-expand'
@ -156,7 +156,7 @@ ImageExpand =
menu:
init: ->
return if g.VIEW is 'catalog' or !Conf['Image Expansion']
return if !Conf['Image Expansion']
el = $.el 'span',
textContent: 'Image Expansion'

View File

@ -1,6 +1,6 @@
ImageHover =
init: ->
return if g.VIEW is 'catalog' or !Conf['Image Hover']
return if !Conf['Image Hover']
Post.callbacks.push
name: 'Image Hover'

View File

@ -1,6 +1,6 @@
RevealSpoilers =
init: ->
return if g.VIEW is 'catalog' or !Conf['Reveal Spoilers']
return if !Conf['Reveal Spoilers']
Post.callbacks.push
name: 'Reveal Spoilers'

View File

@ -1,6 +1,6 @@
Sauce =
init: ->
return if g.VIEW is 'catalog' or !Conf['Sauce']
return if !Conf['Sauce']
links = []
for link in Conf['sauces'].split '\n'

View File

@ -1,6 +1,6 @@
Linkify =
init: ->
return if g.VIEW is 'catalog' or !Conf['Linkify']
return if !Conf['Linkify']
# gruber revised + magnet support
# http://df4.us/fv9

View File

@ -1,6 +1,6 @@
ArchiveLink =
init: ->
return if g.VIEW is 'catalog' or !Conf['Menu'] or !Conf['Archive Link']
return if !Conf['Menu'] or !Conf['Archive Link']
div = $.el 'div',
textContent: 'Archive'

View File

@ -1,6 +1,6 @@
DeleteLink =
init: ->
return if g.VIEW is 'catalog' or !Conf['Menu'] or !Conf['Delete Link']
return if !Conf['Menu'] or !Conf['Delete Link']
div = $.el 'div',
className: 'delete-link'

View File

@ -1,6 +1,6 @@
DownloadLink =
init: ->
return if g.VIEW is 'catalog' or !Conf['Menu'] or !Conf['Download Link']
return if !Conf['Menu'] or !Conf['Download Link']
a = $.el 'a',
className: 'download-link'

View File

@ -1,6 +1,6 @@
Menu =
init: ->
return if g.VIEW is 'catalog' or !Conf['Menu']
return if !Conf['Menu']
@menu = new UI.Menu 'post'
Post.callbacks.push

View File

@ -1,6 +1,6 @@
ReportLink =
init: ->
return if g.VIEW is 'catalog' or !Conf['Menu'] or !Conf['Report Link']
return if !Conf['Menu'] or !Conf['Report Link']
a = $.el 'a',
className: 'report-link'

View File

@ -1,6 +1,6 @@
Anonymize =
init: ->
return if g.VIEW is 'catalog' or !Conf['Anonymize']
return if !Conf['Anonymize']
Post.callbacks.push
name: 'Anonymize'

View File

@ -1,6 +1,6 @@
Dice =
init: ->
return if g.BOARD.ID isnt 'tg' or g.VIEW is 'catalog' or !Conf['Show Dice Roll']
return if g.BOARD.ID isnt 'tg' or !Conf['Show Dice Roll']
Post.callbacks.push
name: 'Show Dice Roll'
cb: @node

View File

@ -1,6 +1,6 @@
FileInfo =
init: ->
return if g.VIEW is 'catalog' or !Conf['File Info Formatting']
return if !Conf['File Info Formatting']
@funk = @createFunc Conf['fileInfo']
Post.callbacks.push

View File

@ -1,7 +1,5 @@
Fourchan =
init: ->
return if g.VIEW is 'catalog'
board = g.BOARD.ID
if board is 'g'
$.globalEval """

View File

@ -1,6 +1,6 @@
IDColor =
init: ->
return if g.VIEW is 'catalog' or !Conf['Color User IDs']
return if !Conf['Color User IDs']
@ids = {}
Post.callbacks.push

View File

@ -1,6 +1,6 @@
Keybinds =
init: ->
return if g.VIEW is 'catalog' or !Conf['Keybinds']
return if !Conf['Keybinds']
for hotkey of Conf.hotkeys
$.sync hotkey, Keybinds.sync

View File

@ -5,8 +5,6 @@ Nav =
return unless Conf['Index Navigation']
when 'thread'
return unless Conf['Reply Navigation']
else # catalog
return
span = $.el 'span',
id: 'navlinks'

View File

@ -1,6 +1,6 @@
Time =
init: ->
return if g.VIEW is 'catalog' or !Conf['Time Formatting']
return if !Conf['Time Formatting']
@funk = @createFunc Conf['time']
Post.callbacks.push

View File

@ -57,7 +57,7 @@ QR =
persist: ->
QR.open()
QR.hide() if Conf['Auto-Hide QR'] or g.VIEW is 'catalog'
QR.hide() if Conf['Auto-Hide QR']
open: ->
if QR.nodes
QR.nodes.el.hidden = false

View File

@ -11,7 +11,7 @@ QuoteBacklink =
# This is is so that fetched posts can get their backlinks,
# and that as much backlinks are appended in the background as possible.
init: ->
return if g.VIEW is 'catalog' or !Conf['Quote Backlinks']
return if !Conf['Quote Backlinks']
format = Conf['backlink'].replace /%id/g, "' + id + '"
@funk = Function 'id', "return '#{format}'"

View File

@ -1,6 +1,6 @@
QuoteCT =
init: ->
return if g.VIEW is 'catalog' or !Conf['Mark Cross-thread Quotes']
return if !Conf['Mark Cross-thread Quotes']
# \u00A0 is nbsp
@text = '\u00A0(Cross-thread)'

View File

@ -1,6 +1,6 @@
QuoteInline =
init: ->
return if g.VIEW is 'catalog' or !Conf['Quote Inlining']
return if !Conf['Quote Inlining']
Post.callbacks.push
name: 'Quote Inlining'

View File

@ -1,6 +1,6 @@
QuoteOP =
init: ->
return if g.VIEW is 'catalog' or !Conf['Mark OP Quotes']
return if !Conf['Mark OP Quotes']
# \u00A0 is nbsp
@text = '\u00A0(OP)'

View File

@ -1,6 +1,6 @@
QuotePreview =
init: ->
return if g.VIEW is 'catalog' or !Conf['Quote Previewing']
return if !Conf['Quote Previewing']
Post.callbacks.push
name: 'Quote Previewing'

View File

@ -1,6 +1,6 @@
QuoteStrikeThrough =
init: ->
return if g.VIEW is 'catalog' or !Conf['Reply Hiding'] and !Conf['Reply Hiding Link'] and !Conf['Filter']
return if !Conf['Reply Hiding'] and !Conf['Reply Hiding Link'] and !Conf['Filter']
Post.callbacks.push
name: 'Strike-through Quotes'

View File

@ -1,6 +1,6 @@
QuoteYou =
init: ->
return if g.VIEW is 'catalog' or !Conf['Mark Quotes of You'] or !Conf['Quick Reply']
return if !Conf['Mark Quotes of You'] or !Conf['Quick Reply']
# \u00A0 is nbsp
@text = '\u00A0(You)'

View File

@ -1,6 +1,6 @@
Quotify =
init: ->
return if g.VIEW is 'catalog' or !Conf['Resurrect Quotes']
return if !Conf['Resurrect Quotes']
Post.callbacks.push
name: 'Resurrect Quotes'