diff --git a/4chan_x.user.js b/4chan_x.user.js index 208bba20b..9352cae3a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -146,28 +146,28 @@ backlink: '>>%id', favicon: 'ferongr', hotkeys: { - openOptions: 'ctrl+o', - close: 'Esc', - spoiler: 'ctrl+s', - openQR: 'i', - openEmptyQR: 'I', - submit: 'alt+s', - nextReply: 'J', - previousReply: 'K', - nextThread: 'n', - previousThread: 'p', - nextPage: 'L', - previousPage: 'H', - zero: '0', - openThreadTab: 'o', - openThread: 'O', - expandThread: 'e', - watch: 'w', - hide: 'x', - expandImages: 'm', - expandAllImages: 'M', - update: 'u', - unreadCountTo0: 'z' + openOptions: ['ctrl+o', 'Open Options'], + close: ['Esc', 'Close Options or QR'], + spoiler: ['ctrl+s', 'Quick spoiler'], + openQR: ['i', 'Open QR with post number inserted'], + openEmptyQR: ['I', 'Open QR without post number inserted'], + submit: ['alt+s', 'Submit post'], + nextReply: ['J', 'Select next reply'], + previousReply: ['K', 'Select previous reply'], + nextThread: ['n', 'See next thread'], + previousThread: ['p', 'See previous thread'], + nextPage: ['L', 'Jump to the next page'], + previousPage: ['H', 'Jump to the previous page'], + zero: ['0', 'Jump to page 0'], + openThreadTab: ['o', 'Open thread in current tab'], + openThread: ['O', 'Open thread in new tab'], + expandThread: ['e', 'Expand thread'], + watch: ['w', 'Watch thread'], + hide: ['x', 'Hide thread'], + expandImages: ['m', 'Expand selected image'], + expandAllImages: ['M', 'Expand all images'], + update: ['u', 'Update now'], + unreadCountTo0: ['z', 'Reset unread count to 0'] }, updater: { checkbox: { @@ -186,19 +186,17 @@ (flatten = function(parent, obj) { var key, val, _results; - if (obj.length) { - if (typeof obj[0] === 'boolean') { + if (typeof obj === 'object') { + if (obj.length) { return conf[parent] = obj[0]; } else { - return conf[parent] = obj; + _results = []; + for (key in obj) { + val = obj[key]; + _results.push(flatten(key, val)); + } + return _results; } - } else if (typeof obj === 'object') { - _results = []; - for (key in obj) { - val = obj[key]; - _results.push(flatten(key, val)); - } - return _results; } else { return conf[parent] = obj; } @@ -1969,7 +1967,7 @@ } }, dialog: function() { - var arr, back, checked, description, dialog, favicon, hiddenNum, hiddenThreads, indicator, indicators, input, key, li, obj, overlay, ta, time, ul, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _ref3, _ref4; + var arr, back, checked, description, dialog, favicon, hiddenNum, hiddenThreads, indicator, indicators, input, key, li, obj, overlay, ta, time, tr, ul, _i, _j, _len, _len2, _ref, _ref2, _ref3, _ref4; dialog = $.el('div', { id: 'options', className: 'reply dialog', @@ -2041,30 +2039,9 @@ \
\
Keybinds are disabled.
\ +
Allowed keys: Ctrl, Alt, a-z, A-Z, 0-1, Up, Down, Right, Left.
\ \ \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \
ActionsKeybinds
Open Options
Close Options or QR
Quick spoiler
Open QR with post number inserted
Open QR without post number inserted
Submit post
Select next reply
Select previous reply
See next thread
See previous thread
Jump to the next page
Jump to the previous page
Jump to page 0
Open thread in current tab
Open thread in new tab
Expand thread
Watch thread
Hide thread
Expand selected image
Expand all images
Update now
Reset the unread count to 0
\
\ ' @@ -2110,17 +2087,21 @@ favicon.value = conf['favicon']; $.on(favicon, 'change', $.cb.value); $.on(favicon, 'change', options.favicon); - _ref3 = $$('#keybinds_tab + div input', dialog); - for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) { - input = _ref3[_j]; - input.type = 'text'; - input.value = conf[input.name]; + _ref3 = config.hotkeys; + for (key in _ref3) { + arr = _ref3[key]; + tr = $.el('tr', { + innerHTML: "" + arr[1] + "" + }); + input = $('input', tr); + input.value = conf[key]; $.on(input, 'keydown', options.keybind); + $.add($('#keybinds_tab + div tbody', dialog), tr); } indicators = {}; _ref4 = $$('.warning', dialog); - for (_k = 0, _len3 = _ref4.length; _k < _len3; _k++) { - indicator = _ref4[_k]; + for (_j = 0, _len2 = _ref4.length; _j < _len2; _j++) { + indicator = _ref4[_j]; key = indicator.firstChild.textContent; indicator.hidden = conf[key]; indicators[key] = indicator; diff --git a/script.coffee b/script.coffee index 783613eb3..56c8f669f 100644 --- a/script.coffee +++ b/script.coffee @@ -71,34 +71,34 @@ config = backlink: '>>%id' favicon: 'ferongr' hotkeys: - openOptions: 'ctrl+o' - close: 'Esc' - spoiler: 'ctrl+s' - openQR: 'i' - openEmptyQR: 'I' - submit: 'alt+s' - nextReply: 'J' - previousReply: 'K' - nextThread: 'n' - previousThread: 'p' - nextPage: 'L' - previousPage: 'H' - zero: '0' - openThreadTab: 'o' - openThread: 'O' - expandThread: 'e' - watch: 'w' - hide: 'x' - expandImages: 'm' - expandAllImages: 'M' - update: 'u' - unreadCountTo0: 'z' + openOptions: ['ctrl+o', 'Open Options'] + close: ['Esc', 'Close Options or QR'] + spoiler: ['ctrl+s', 'Quick spoiler'] + openQR: ['i', 'Open QR with post number inserted'] + openEmptyQR: ['I', 'Open QR without post number inserted'] + submit: ['alt+s', 'Submit post'] + nextReply: ['J', 'Select next reply'] + previousReply: ['K', 'Select previous reply'] + nextThread: ['n', 'See next thread'] + previousThread: ['p', 'See previous thread'] + nextPage: ['L', 'Jump to the next page'] + previousPage: ['H', 'Jump to the previous page'] + zero: ['0', 'Jump to page 0'] + openThreadTab: ['o', 'Open thread in current tab'] + openThread: ['O', 'Open thread in new tab'] + expandThread: ['e', 'Expand thread'] + watch: ['w', 'Watch thread'] + hide: ['x', 'Hide thread'] + expandImages: ['m', 'Expand selected image'] + expandAllImages: ['M', 'Expand all images'] + update: ['u', 'Update now'] + unreadCountTo0: ['z', 'Reset unread count to 0'] updater: checkbox: - 'Scrolling': [false, 'Scroll updated posts into view. Only enabled at bottom of page.'] - 'Scroll BG': [false, 'Scroll background tabs'] - 'Verbose': [true, 'Show countdown timer, new post count'] - 'Auto Update': [true, 'Automatically fetch new posts'] + 'Scrolling': [false, 'Scroll updated posts into view. Only enabled at bottom of page.'] + 'Scroll BG': [false, 'Scroll background tabs'] + 'Verbose': [true, 'Show countdown timer, new post count'] + 'Auto Update': [true, 'Automatically fetch new posts'] 'Interval': 30 # XXX Chrome can't into {log} = console @@ -108,15 +108,14 @@ log = console.log.bind? console # flatten the config conf = {} (flatten = (parent, obj) -> - if obj.length #array - if typeof obj[0] is 'boolean' + if typeof obj is 'object' + # array + if obj.length conf[parent] = obj[0] - else - conf[parent] = obj - else if typeof obj is 'object' - for key, val of obj + # object + else for key, val of obj flatten key, val - else #constant + else # string or number conf[parent] = obj ) null, config @@ -1577,30 +1576,9 @@ options =
Keybinds are disabled.
+
Allowed keys: Ctrl, Alt, a-z, A-Z, 0-1, Up, Down, Right, Left.
- - - - - - - - - - - - - - - - - - - - - -
ActionsKeybinds
Open Options
Close Options or QR
Quick spoiler
Open QR with post number inserted
Open QR without post number inserted
Submit post
Select next reply
Select previous reply
See next thread
See previous thread
Jump to the next page
Jump to the previous page
Jump to page 0
Open thread in current tab
Open thread in new tab
Expand thread
Watch thread
Hide thread
Expand selected image
Expand all images
Update now
Reset the unread count to 0
' @@ -1643,10 +1621,13 @@ options = $.on favicon, 'change', options.favicon #keybinds - for input in $$ '#keybinds_tab + div input', dialog - input.type = 'text' - input.value = conf[input.name] + for key, arr of config.hotkeys + tr = $.el 'tr', + innerHTML: "#{arr[1]}" + input = $ 'input', tr + input.value = conf[key] $.on input, 'keydown', options.keybind + $.add $('#keybinds_tab + div tbody', dialog), tr #indicate if the settings require a feature to be enabled indicators = {}