Sync keybinds across tabs.
This commit is contained in:
parent
feb25694cc
commit
5157954b09
@ -211,7 +211,7 @@ $.sync = do ->
|
||||
chrome.storage.onChanged.addListener (changes) ->
|
||||
for key of changes
|
||||
if cb = $.syncing[key]
|
||||
cb changes[key].newValue
|
||||
cb changes[key].newValue, key
|
||||
return
|
||||
(key, cb) -> $.syncing[key] = cb
|
||||
$.localKeys = [
|
||||
@ -289,9 +289,9 @@ $.set = do ->
|
||||
<% } else { %>
|
||||
# http://wiki.greasespot.net/Main_Page
|
||||
$.sync = do ->
|
||||
$.on window, 'storage', (e) ->
|
||||
if cb = $.syncing[e.key]
|
||||
cb JSON.parse e.newValue
|
||||
$.on window, 'storage', ({key, newValue}) ->
|
||||
if cb = $.syncing[key]
|
||||
cb JSON.parse(newValue), key
|
||||
(key, cb) -> $.syncing[g.NAMESPACE + key] = cb
|
||||
$.delete = (keys) ->
|
||||
unless keys instanceof Array
|
||||
|
||||
@ -2,6 +2,9 @@ Keybinds =
|
||||
init: ->
|
||||
return if g.VIEW is 'catalog' or !Conf['Keybinds']
|
||||
|
||||
for hotkey of Conf.hotkeys
|
||||
$.sync hotkey, Keybinds.sync
|
||||
|
||||
init = ->
|
||||
$.off d, '4chanXInitFinished', init
|
||||
$.on d, 'keydown', Keybinds.keydown
|
||||
@ -10,6 +13,9 @@ Keybinds =
|
||||
return
|
||||
$.on d, '4chanXInitFinished', init
|
||||
|
||||
sync: (key, hotkey) ->
|
||||
Conf[hotkey] = key
|
||||
|
||||
keydown: (e) ->
|
||||
return unless key = Keybinds.keyCode e
|
||||
{target} = e
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user