diff options
Diffstat (limited to 'background_scripts/commands.coffee')
| -rw-r--r-- | background_scripts/commands.coffee | 19 | 
1 files changed, 19 insertions, 0 deletions
| diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee index 2d3312ea..f5a3840b 100644 --- a/background_scripts/commands.coffee +++ b/background_scripts/commands.coffee @@ -9,6 +9,7 @@ Commands =      Settings.postUpdateHooks["keyMappings"] = @loadKeyMappings.bind this      @loadKeyMappings Settings.get "keyMappings" +    @prepareHelpPageData()    loadKeyMappings: (customKeyMappings) ->      @keyToCommandRegistry = {} @@ -113,6 +114,24 @@ Commands =            delete currentMapping[key][prop] for prop in ["keySequence", "description"]      chrome.storage.local.set normalModeKeyStateMapping: keyStateMapping +  # Build the "helpPageData" data structure which the help page needs and place it in Chrome storage.  We do +  # this on the "nextTick" because there's not need for it to be done synchronously. +  prepareHelpPageData: -> +    Utils.nextTick => +      commandToKey = {} +      for own key, registryEntry of @keyToCommandRegistry +        (commandToKey[registryEntry.command] ?= []).push key +      commandGroups = {} +      for own group, commands of @commandGroups +        commandGroups[group] = [] +        for command in commands +          commandGroups[group].push +            command: command +            description: @availableCommands[command].description +            keys: commandToKey[command] ? [] +            advanced: command in @advancedCommands +      chrome.storage.local.set helpPageData: commandGroups +    # An ordered listing of all available commands, grouped by type. This is the order they will    # be shown in the help page.    commandGroups: | 
