diff --git a/src/General/Index.coffee b/src/General/Index.coffee
index 13db81787..bc82570a9 100644
--- a/src/General/Index.coffee
+++ b/src/General/Index.coffee
@@ -46,35 +46,37 @@ Index =
Header.addShortcut 'index-refresh', @button, 590
# Header "Index Navigation" submenu
- repliesEntry = el: UI.checkbox 'Show Replies', 'Show replies'
- hoverEntry = el: UI.checkbox 'Catalog Hover Expand', 'Catalog hover expand'
- sortEntry = el: UI.checkbox 'Per-Board Sort Type', 'Per-board sort type', (typeof Conf['Index Sort'] is 'object')
- pinEntry = el: UI.checkbox 'Pin Watched Threads', 'Pin watched threads'
- anchorEntry = el: UI.checkbox 'Anchor Hidden Threads', 'Anchor hidden threads'
- refNavEntry = el: UI.checkbox 'Refreshed Navigation', 'Refreshed navigation'
- hoverEntry.el.title = 'Expand the comment and show more details when you hover over a thread in the catalog.'
- sortEntry.el.title = 'Set the sorting order of each board independently.'
- pinEntry.el.title = 'Move watched threads to the start of the index.'
- anchorEntry.el.title = 'Move hidden threads to the end of the index.'
- refNavEntry.el.title = 'Refresh index when navigating through pages.'
- for label in [repliesEntry, hoverEntry, pinEntry, anchorEntry, refNavEntry]
- input = label.el.firstChild
- {name} = input
+ entries = []
+ inputs = {}
+ for name, arr of Config.Index when arr instanceof Array
+ label = UI.checkbox name, "#{name[0]}#{name[1..].toLowerCase()}"
+ label.title = arr[1]
+ entries.push {el: label}
+ input = label.firstChild
$.on input, 'change', $.cb.checked
- switch name
- when 'Show Replies'
- $.on input, 'change', @cb.replies
- when 'Catalog Hover Expand'
- $.on input, 'change', @cb.hover
- when 'Pin Watched Threads', 'Anchor Hidden Threads'
- $.on input, 'change', @cb.resort
- $.on sortEntry.el.firstChild, 'change', @cb.perBoardSort
+ inputs[name] = input
+ $.on inputs['Show Replies'], 'change', @cb.replies
+ $.on inputs['Catalog Hover Expand'], 'change', @cb.hover
+ $.on inputs['Pin Watched Threads'], 'change', @cb.resort
+ $.on inputs['Anchor Hidden Threads'], 'change', @cb.resort
+
+ watchSettings = (e) ->
+ if (input = inputs[e.target.name])
+ input.checked = e.target.checked
+ $.event 'change', null, input
+ $.on d, 'OpenSettings', ->
+ $.on $.id('fourchanx-settings'), 'change', watchSettings
+
+ sortEntry = UI.checkbox 'Per-Board Sort Type', 'Per-board sort type', (typeof Conf['Index Sort'] is 'object')
+ sortEntry.title = 'Set the sorting order of each board independently.'
+ $.on sortEntry.firstChild, 'change', @cb.perBoardSort
+ entries.splice 2, 0, {el: sortEntry}
Header.menu.addEntry
el: $.el 'span',
textContent: 'Index Navigation'
order: 100
- subEntries: [repliesEntry, hoverEntry, sortEntry, pinEntry, anchorEntry, refNavEntry]
+ subEntries: entries
# Navigation links at top of index
@navLinks = $.el 'div', className: 'navLinks json-index'
diff --git a/src/General/Settings.coffee b/src/General/Settings.coffee
index 5da658a69..a251d788d 100644
--- a/src/General/Settings.coffee
+++ b/src/General/Settings.coffee
@@ -135,19 +135,16 @@ Settings =
items = {}
inputs = {}
- for key, obj of Config.main
- fs = $.el 'fieldset',
- <%= html('') %>
- containers = [fs]
- for key, arr of obj
+ addCheckboxes = (root, obj) ->
+ containers = [root]
+ for key, arr of obj when arr instanceof Array
description = arr[1]
div = $.el 'div',
<%= html(': ${description}') %>
- div.hidden = true if $.engine isnt 'gecko' and key is 'Remember QR Size' # XXX not supported
+ div.dataset.name = key
input = $ 'input', div
- $.on input, 'change', ->
- @parentNode.parentNode.dataset.checked = @checked
- $.cb.checked.call @
+ $.on input, 'change', $.cb.checked
+ $.on input, 'change', -> @parentNode.parentNode.dataset.checked = @checked
items[key] = Conf[key]
inputs[key] = input
level = arr[2] or 0
@@ -158,7 +155,15 @@ Settings =
else if containers.length > level+1
containers.splice level+1, containers.length - (level+1)
$.add containers[level], div
+
+ for key, obj of Config.main
+ fs = $.el 'fieldset',
+ <%= html('') %>
+ addCheckboxes fs, obj
$.add section, fs
+ addCheckboxes $('div[data-name="JSON Index"] > .suboption-list', section), Config.Index
+ if $.engine isnt 'gecko'
+ $('div[data-name="Remember QR Size"]', section).hidden = true # XXX not supported
$.get items, (items) ->
for key, val of items
diff --git a/src/config/Config.coffee b/src/config/Config.coffee
index 49831afc1..16f42b9c1 100644
--- a/src/config/Config.coffee
+++ b/src/config/Config.coffee
@@ -736,11 +736,11 @@ Config =
'Index Mode': 'paged'
'Previous Index Mode': 'paged'
'Index Size': 'small'
- 'Show Replies': true
- 'Catalog Hover Expand': true
- 'Pin Watched Threads': false
- 'Anchor Hidden Threads': true
- 'Refreshed Navigation': false
+ 'Show Replies': [true, 'Show replies in the index, and also in the catalog if "Catalog hover expand" is checked.']
+ 'Catalog Hover Expand': [true, 'Expand the comment and show more details when you hover over a thread in the catalog.']
+ 'Pin Watched Threads': [false, 'Move watched threads to the start of the index.']
+ 'Anchor Hidden Threads': [true, 'Move hidden threads to the end of the index.']
+ 'Refreshed Navigation': [false, 'Refresh index when navigating through pages.']
Header:
'Fixed Header': true