diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | background_page.html | 38 | ||||
| -rw-r--r-- | background_scripts/commands.coffee | 240 | ||||
| -rw-r--r-- | background_scripts/commands.js | 252 | ||||
| -rw-r--r-- | options.html | 8 | 
5 files changed, 264 insertions, 275 deletions
| @@ -1,4 +1,5 @@  background_scripts/completion.js +background_scripts/commands.js  tests/completion_test.js  tests/test_helper.js  tests/utils_test.js diff --git a/background_page.html b/background_page.html index bae23acb..bf1af077 100644 --- a/background_page.html +++ b/background_page.html @@ -162,14 +162,14 @@     */    function helpDialogHtml(showUnboundCommands, showCommandNames, customTitle) {      var commandsToKey = {}; -    for (var key in keyToCommandRegistry) { -      var command = keyToCommandRegistry[key].command; +    for (var key in Commands.keyToCommandRegistry) { +      var command = Commands.keyToCommandRegistry[key].command;        commandsToKey[command] = (commandsToKey[command] || []).concat(key);      }      var dialogHtml = fetchFileContents("help_dialog.html"); -    for (var group in commandGroups) +    for (var group in Commands.commandGroups)        dialogHtml = dialogHtml.replace("{{" + group + "}}", -          helpDialogHtmlForCommandGroup(group, commandsToKey, availableCommands, +          helpDialogHtmlForCommandGroup(group, commandsToKey, Commands.availableCommands,                                          showUnboundCommands, showCommandNames));      dialogHtml = dialogHtml.replace("{{version}}", currentVersion);      dialogHtml = dialogHtml.replace("{{title}}", customTitle || "Help"); @@ -184,12 +184,13 @@    function helpDialogHtmlForCommandGroup(group, commandsToKey, availableCommands,                                           showUnboundCommands, showCommandNames) {      var html = []; -    for (var i = 0; i < commandGroups[group].length; i++) { -      var command = commandGroups[group][i]; +    for (var i = 0; i < Commands.commandGroups[group].length; i++) { +      var command = Commands.commandGroups[group][i];        bindings = (commandsToKey[command] || [""]).join(", ");        if (showUnboundCommands || commandsToKey[command]) {          html.push( -          "<tr class='vimiumReset " + (advancedCommands.indexOf(command) >= 0 ? "advanced" : "") + "'>", +          "<tr class='vimiumReset " + +              (Commands.advancedCommands.indexOf(command) >= 0 ? "advanced" : "") + "'>",            "<td class='vimiumReset'>", utils.escapeHtml(bindings), "</td>",            "<td class='vimiumReset'>:</td><td class='vimiumReset'>", availableCommands[command].description); @@ -531,7 +532,7 @@    }    function populateValidFirstKeys() { -    for (var key in keyToCommandRegistry) +    for (var key in Commands.keyToCommandRegistry)      {        if (getActualKeyStrokeLength(key) == 2)          validFirstKeys[splitKeyIntoFirstAndSecond(key).first] = true; @@ -539,7 +540,7 @@    }    function populateSingleKeyCommands() { -    for (var key in keyToCommandRegistry) +    for (var key in Commands.keyToCommandRegistry)      {        if (getActualKeyStrokeLength(key) == 1)          singleKeyCommands.push(key); @@ -569,7 +570,7 @@      if (getActualKeyStrokeLength(command) == 1)      { -      for (var key in keyToCommandRegistry) +      for (var key in Commands.keyToCommandRegistry)        {          var splitKey = splitKeyIntoFirstAndSecond(key);          if (splitKey.first == command) @@ -610,9 +611,8 @@      if (command.length == 0) { return keysToCheck; }      if (isNaN(count)) { count = 1; } -    if (keyToCommandRegistry[command]) { -      registryEntry = keyToCommandRegistry[command]; -      console.log("command found for [", keysToCheck, "],", registryEntry.command); +    if (Commands.keyToCommandRegistry[command]) { +      registryEntry = Commands.keyToCommandRegistry[command];        if (!registryEntry.isBackgroundCommand) {          var port = chrome.tabs.connect(tabId, { name: "executePageCommand" }); @@ -637,7 +637,7 @@        var splitKey = splitKeyIntoFirstAndSecond(command);        // The second key might be a valid command by its self. -      if (keyToCommandRegistry[splitKey.second]) +      if (Commands.keyToCommandRegistry[splitKey.second])          newKeyQueue = checkKeyQueue(splitKey.second, tabId, frameId);        else          newKeyQueue = (validFirstKeys[splitKey.second] ? splitKey.second : ""); @@ -764,23 +764,23 @@    }    function init() { -    clearKeyMappingsAndSetDefaults(); +    Commands.clearKeyMappingsAndSetDefaults();      if (settings.has("keyMappings")) -      parseCustomKeyMappings(settings.get("keyMappings")); +      Commands.parseCustomKeyMappings(settings.get("keyMappings"));      // In version 1.22, we changed the mapping for "d" and "u" to be scroll page down/up instead of close      // and restore tab. For existing users, we want to preserve existing behavior for them by adding some      // custom key mappings on their behalf.      if (settings.get("previousVersion") == "1.21") {        var customKeyMappings = settings.get("keyMappings") || ""; -      if ((keyToCommandRegistry["d"] || {}).command == "scrollPageDown") +      if ((Commands.keyToCommandRegistry["d"] || {}).command == "scrollPageDown")          customKeyMappings += "\nmap d removeTab"; -      if ((keyToCommandRegistry["u"] || {}).command == "scrollPageUp") +      if ((Commands.keyToCommandRegistry["u"] || {}).command == "scrollPageUp")          customKeyMappings += "\nmap u restoreTab";        if (customKeyMappings != "") {          settings.set("keyMappings", customKeyMappings); -        parseCustomKeyMappings(customKeyMappings); +        Commands.parseCustomKeyMappings(customKeyMappings);        }      } diff --git a/background_scripts/commands.coffee b/background_scripts/commands.coffee new file mode 100644 index 00000000..0d689043 --- /dev/null +++ b/background_scripts/commands.coffee @@ -0,0 +1,240 @@ +Commands = +  init: -> +    for command of commandDescriptions +      @addCommand(command, commandDescriptions[command][0], commandDescriptions[command][1]) + +  availableCommands: {} +  keyToCommandRegistry: {} + +  # Registers a command, making it available to be optionally bound to a key. +  # options: +  #  - background: whether this command needs to be run against the background page. +  #  - passCountToFunction: true if this command should have any digits which were typed prior to the +  #    command passed to it. This is used to implement e.g. "closing of 3 tabs". +  addCommand: (command, description, options) -> +    if @availableCommands[command] +      console.log(command, "is already defined! Check commands.js for duplicates.") +      return + +    options ||= {} +    @availableCommands[command] = +      description: description +      isBackgroundCommand: options.background +      passCountToFunction: options.passCountToFunction + +  mapKeyToCommand: (key, command) -> +    unless @availableCommands[command] +      console.log(command, "doesn't exist!") +      return + +    @keyToCommandRegistry[key] = +      command: command +      isBackgroundCommand: @availableCommands[command].isBackgroundCommand +      passCountToFunction: @availableCommands[command].passCountToFunction + +  unmapKey: (key) -> delete @keyToCommandRegistry[key] + +  # Lower-case the appropriate portions of named keys. +  # +  # A key name is one of three forms exemplified by <c-a> <left> or <c-f12> +  # (prefixed normal key, named key, or prefixed named key). Internally, for +  # simplicity, we would like prefixes and key names to be lowercase, though +  # humans may prefer other forms <Left> or <C-a>. +  # On the other hand, <c-a> and <c-A> are different named keys - for one of +  # them you have to press "shift" as well. +  normalizeKey: (key) -> +      key.replace(/<[acm]-/ig, (match) -> match.toLowerCase()) +          .replace(/<([acm]-)?([a-zA-Z0-9]{2,5})>/g, (match, optionalPrefix, keyName) -> +            "<" + (if optionalPrefix then optionalPrefix else "") + keyName.toLowerCase() + ">") + +  parseCustomKeyMappings: (customKeyMappings) -> +    lines = customKeyMappings.split("\n") + +    for line in lines +      continue if (line[0] == "\"" || line[0] == "#") +      split_line = line.split(/\s+/) + +      lineCommand = split_line[0] + +      if (lineCommand == "map") +        continue if (split_line.length != 3) +        key = @normalizeKey(split_line[1]) +        vimiumCommand = split_line[2] + +        continue unless @availableCommands[vimiumCommand] + +        console.log("Mapping", key, "to", vimiumCommand) +        @mapKeyToCommand(key, vimiumCommand) +      else if (lineCommand == "unmap") +        continue if (split_line.length != 2) + +        key = @normalizeKey(split_line[1]) +        console.log("Unmapping", key) +        @unmapKey(key) +      else if (lineCommand == "unmapAll") +        @keyToCommandRegistry = {} + +  clearKeyMappingsAndSetDefaults: -> +    @keyToCommandRegistry = {} + +    for key of defaultKeyMappings +      @mapKeyToCommand(key, defaultKeyMappings[key]) + +  # An ordered listing of all available commands, grouped by type. This is the order they will +  # be shown in the help page. +  commandGroups: +    pageNavigation: +      ["scrollDown", "scrollUp", "scrollLeft", "scrollRight", +       "scrollToTop", "scrollToBottom", "scrollToLeft", "scrollToRight", "scrollPageDown", +       "scrollPageUp", "scrollFullPageUp", "scrollFullPageDown", +       "reload", "toggleViewSource", "copyCurrentUrl", "linkHints.activateModeToCopyLinkUrl", +       "openCopiedUrlInCurrentTab", "openCopiedUrlInNewTab", "goUp", +       "enterInsertMode", "focusInput", +       "linkHints.activateMode", "linkHints.activateModeToOpenInNewTab", "linkHints.activateModeWithQueue", +       "vomnibar.activate", "vomnibar.activateWithCurrentUrl", "vomnibar.activateTabSelection", +       "goPrevious", "goNext", "nextFrame"] +    findCommands: ["enterFindMode", "performFind", "performBackwardsFind"] +    historyNavigation: +      ["goBack", "goForward"] +    tabManipulation: +      ["nextTab", "previousTab", "firstTab", "lastTab", "createTab", "removeTab", "restoreTab"] +    misc: +      ["showHelp"] + +  # Rarely used commands are not shown by default in the help dialog or in the README. The goal is to present +  # a focused, high-signal set of commands to the new and casual user. Only those truly hungry for more power +  # from Vimium will uncover these gems. +  advancedCommands: [ +    "scrollToLeft", "scrollToRight", +    "goUp", "focusInput", "linkHints.activateModeWithQueue", +    "goPrevious", "goNext"] + +defaultKeyMappings = +  "?": "showHelp" +  "j": "scrollDown" +  "k": "scrollUp" +  "h": "scrollLeft" +  "l": "scrollRight" +  "gg": "scrollToTop" +  "G": "scrollToBottom" +  "zH": "scrollToLeft" +  "zL": "scrollToRight" +  "<c-e>": "scrollDown" +  "<c-y>": "scrollUp" + +  "d": "scrollPageDown" +  "u": "scrollPageUp" +  "r": "reload" +  "gs": "toggleViewSource" + +  "i": "enterInsertMode" + +  "H": "goBack" +  "L": "goForward" +  "gu": "goUp" + +  "gi": "focusInput" + +  "f":     "linkHints.activateMode" +  "F":     "linkHints.activateModeToOpenInNewTab" +  "<a-f>": "linkHints.activateModeWithQueue" + +  "/": "enterFindMode" +  "n": "performFind" +  "N": "performBackwardsFind" + +  "[[": "goPrevious" +  "]]": "goNext" + +  "yy": "copyCurrentUrl" +  "yf": "linkHints.activateModeToCopyLinkUrl" + +  "p": "openCopiedUrlInCurrentTab" +  "P": "openCopiedUrlInNewTab" + +  "K": "nextTab" +  "J": "previousTab" +  "gt": "nextTab" +  "gT": "previousTab" +  "g0": "firstTab" +  "g$": "lastTab" + +  "t": "createTab" +  "x": "removeTab" +  "X": "restoreTab" + +  "o": "vomnibar.activate" +  "O": "vomnibar.activateWithCurrentUrl" + +  "T": "vomnibar.activateTabSelection" + +  "gf": "nextFrame" + + +# This is a mapping of: commandIdentifier => [description, options]. +commandDescriptions = +  # Navigating the current page +  showHelp: ["Show help", { background: true }] +  scrollDown: ["Scroll down"] +  scrollUp: ["Scroll up"] +  scrollLeft: ["Scroll left"] +  scrollRight: ["Scroll right"] +  scrollToTop: ["Scroll to the top of the page"] +  scrollToBottom: ["Scroll to the bottom of the page"] +  scrollToLeft: ["Scroll all the way to the left"] + +  scrollToRight: ["Scroll all the way to the right"] +  scrollPageDown: ["Scroll a page down"] +  scrollPageUp: ["Scroll a page up"] +  scrollFullPageDown: ["Scroll a full page down"] +  scrollFullPageUp: ["Scroll a full page up"] + +  reload: ["Reload the page"] +  toggleViewSource: ["View page source"] + +  copyCurrentUrl: ["Copy the current URL to the clipboard"] +  'linkHints.activateModeToCopyLinkUrl': ["Copy a link URL to the clipboard"] +  openCopiedUrlInCurrentTab: ["Open the clipboard's URL in the current tab", { background: true }] +  openCopiedUrlInNewTab: ["Open the clipboard's URL in a new tab", { background: true }] + +  enterInsertMode: ["Enter insert mode"] + +  focusInput: ["Focus the first (or n-th) text box on the page", { passCountToFunction: true }] + +  'linkHints.activateMode': ["Open a link in the current tab"] +  'linkHints.activateModeToOpenInNewTab': ["Open a link in a new tab"] +  'linkHints.activateModeWithQueue': ["Open multiple links in a new tab"] + +  enterFindMode: ["Enter find mode"] +  performFind: ["Cycle forward to the next find match"] +  performBackwardsFind: ["Cycle backward to the previous find match"] + +  goPrevious: ["Follow the link labeled previous or <"] +  goNext: ["Follow the link labeled next or >"] + +  # Navigating your history +  goBack: ["Go back in history", { passCountToFunction: true }] +  goForward: ["Go forward in history", { passCountToFunction: true }] + +  # Navigating the URL hierarchy +  goUp: ["Go up the URL hierarchy", { passCountToFunction: true }] + +  # Manipulating tabs +  nextTab: ["Go one tab right", { background: true }] +  previousTab: ["Go one tab left", { background: true }] +  firstTab: ["Go to the first tab", { background: true }] +  lastTab: ["Go to the last tab", { background: true }] +  createTab: ["Create new tab", { background: true }] +  removeTab: ["Close current tab", { background: true }] +  restoreTab: ["Restore closed tab", { background: true }] + +  "vomnibar.activate": ["Open URL, bookmark, or history entry"] +  "vomnibar.activateWithCurrentUrl": ["Open URL, bookmark, history entry, starting with the current URL"] +  "vomnibar.activateTabSelection": ["Search through your open tabs"] + +  nextFrame: ["Cycle forward to the next frame on the page", { background: true, passCountToFunction: true }] + +Commands.init() + +root = exports ? window +root.Commands = Commands diff --git a/background_scripts/commands.js b/background_scripts/commands.js deleted file mode 100644 index c9061822..00000000 --- a/background_scripts/commands.js +++ /dev/null @@ -1,252 +0,0 @@ -var availableCommands    = {}; -var keyToCommandRegistry = {}; - -/* - * Registers a command, making it available to be optionally bound to a key. - * options: - *   - background: whether this command needs to be run against the background page. - *   - passCountToFunction: true if this command should have any digits which were typed prior to the - *     command passed to it. This is used to implement e.g. "closing of 3 tabs". - */ -function addCommand(command, description, options) { -  if (availableCommands[command]) { -    console.log(command, "is already defined! Check commands.js for duplicates."); -    return; -  } - -  options = options || {}; -  availableCommands[command] = { description: description, -                                 isBackgroundCommand: options.background, -                                 passCountToFunction: options.passCountToFunction -                               }; -} - -function mapKeyToCommand(key, command) { -  if (!availableCommands[command]) { -    console.log(command, "doesn't exist!"); -    return; -  } - -  keyToCommandRegistry[key] = { command: command, -                                isBackgroundCommand: availableCommands[command].isBackgroundCommand, -                                passCountToFunction: availableCommands[command].passCountToFunction -                              }; -} - -function unmapKey(key) { delete keyToCommandRegistry[key]; } - -/* Lower-case the appropriate portions of named keys. - * - * A key name is one of three forms exemplified by <c-a> <left> or <c-f12> - * (prefixed normal key, named key, or prefixed named key). Internally, for - * simplicity, we would like prefixes and key names to be lowercase, though - * humans may prefer other forms <Left> or <C-a>. - * On the other hand, <c-a> and <c-A> are different named keys - for one of - * them you have to press "shift" as well. - */ -function normalizeKey(key) { -    return key.replace(/<[acm]-/ig, function(match){ return match.toLowerCase(); }) -              .replace(/<([acm]-)?([a-zA-Z0-9]{2,5})>/g, function(match, optionalPrefix, keyName){ -                  return "<" + ( optionalPrefix ? optionalPrefix : "") + keyName.toLowerCase() + ">"; -              }); -} - -function parseCustomKeyMappings(customKeyMappings) { -  lines = customKeyMappings.split("\n"); - -  for (var i = 0; i < lines.length; i++) { -    if (lines[i][0] == "\"" || lines[i][0] == "#") { continue } -    split_line = lines[i].split(/\s+/); - -    var lineCommand = split_line[0]; - -    if (lineCommand == "map") { -      if (split_line.length != 3) { continue; } -      var key = normalizeKey(split_line[1]); -      var vimiumCommand = split_line[2]; - -      if (!availableCommands[vimiumCommand]) { continue } - -      console.log("Mapping", key, "to", vimiumCommand); -      mapKeyToCommand(key, vimiumCommand); -    } -    else if (lineCommand == "unmap") { -      if (split_line.length != 2) { continue; } - -      var key = normalizeKey(split_line[1]); - -      console.log("Unmapping", key); -      unmapKey(key); -    } -    else if (lineCommand == "unmapAll") { -      keyToCommandRegistry = {}; -    } -  } -} - -function clearKeyMappingsAndSetDefaults() { -  keyToCommandRegistry = {}; - -  var defaultKeyMappings = { -    "?": "showHelp", -    "j": "scrollDown", -    "k": "scrollUp", -    "h": "scrollLeft", -    "l": "scrollRight", -    "gg": "scrollToTop", -    "G": "scrollToBottom", -    "zH": "scrollToLeft", -    "zL": "scrollToRight", -    "<c-e>": "scrollDown", -    "<c-y>": "scrollUp", - -    "d": "scrollPageDown", -    "u": "scrollPageUp", -    "r": "reload", -    "gs": "toggleViewSource", - -    "i": "enterInsertMode", - -    "H": "goBack", -    "L": "goForward", -    "gu": "goUp", - -    "gi": "focusInput", - -    "f":     "linkHints.activateMode", -    "F":     "linkHints.activateModeToOpenInNewTab", -    "<a-f>": "linkHints.activateModeWithQueue", - -    "/": "enterFindMode", -    "n": "performFind", -    "N": "performBackwardsFind", - -    "[[": "goPrevious", -    "]]": "goNext", - -    "yy": "copyCurrentUrl", -    "yf": "linkHints.activateModeToCopyLinkUrl", - -    "p": "openCopiedUrlInCurrentTab", -    "P": "openCopiedUrlInNewTab", - -    "K": "nextTab", -    "J": "previousTab", -    "gt": "nextTab", -    "gT": "previousTab", -    "g0": "firstTab", -    "g$": "lastTab", - -    "t": "createTab", -    "x": "removeTab", -    "X": "restoreTab", - -    "o": "vomnibar.activate", -    "O": "vomnibar.activateWithCurrentUrl", - -    "T": "vomnibar.activateTabSelection", - -    "gf": "nextFrame", -  }; - -  for (var key in defaultKeyMappings) -    mapKeyToCommand(key, defaultKeyMappings[key]); -} - -// This is a mapping of: commandIdentifier => [description, options]. -var commandDescriptions = { -  // Navigating the current page -  showHelp: ["Show help", { background: true }], -  scrollDown: ["Scroll down"], -  scrollUp: ["Scroll up"], -  scrollLeft: ["Scroll left"], -  scrollRight: ["Scroll right"], -  scrollToTop: ["Scroll to the top of the page"], -  scrollToBottom: ["Scroll to the bottom of the page"], -  scrollToLeft: ["Scroll all the way to the left"], - -  scrollToRight: ["Scroll all the way to the right"], -  scrollPageDown: ["Scroll a page down"], -  scrollPageUp: ["Scroll a page up"], -  scrollFullPageDown: ["Scroll a full page down"], -  scrollFullPageUp: ["Scroll a full page up"], - -  reload: ["Reload the page"], -  toggleViewSource: ["View page source"], - -  copyCurrentUrl: ["Copy the current URL to the clipboard"], -  'linkHints.activateModeToCopyLinkUrl': ["Copy a link URL to the clipboard"], -  openCopiedUrlInCurrentTab: ["Open the clipboard's URL in the current tab", { background: true }], -  openCopiedUrlInNewTab: ["Open the clipboard's URL in a new tab", { background: true }], - -  enterInsertMode: ["Enter insert mode"], - -  focusInput: ["Focus the first (or n-th) text box on the page", { passCountToFunction: true }], - -  'linkHints.activateMode': ["Open a link in the current tab"], -  'linkHints.activateModeToOpenInNewTab': ["Open a link in a new tab"], -  'linkHints.activateModeWithQueue': ["Open multiple links in a new tab"], - -  enterFindMode: ["Enter find mode"], -  performFind: ["Cycle forward to the next find match"], -  performBackwardsFind: ["Cycle backward to the previous find match"], - -  goPrevious: ["Follow the link labeled previous or <"], -  goNext: ["Follow the link labeled next or >"], - -  // Navigating your history -  goBack: ["Go back in history", { passCountToFunction: true }], -  goForward: ["Go forward in history", { passCountToFunction: true }], - -  // Navigating the URL hierarchy -  goUp: ["Go up the URL hierarchy", { passCountToFunction: true }], - -  // Manipulating tabs -  nextTab: ["Go one tab right", { background: true }], -  previousTab: ["Go one tab left", { background: true }], -  firstTab: ["Go to the first tab", { background: true }], -  lastTab: ["Go to the last tab", { background: true }], -  createTab: ["Create new tab", { background: true }], -  removeTab: ["Close current tab", { background: true }], -  restoreTab: ["Restore closed tab", { background: true }], - -  "vomnibar.activate": ["Open URL, bookmark, or history entry"], -  "vomnibar.activateWithCurrentUrl": ["Open URL, bookmark, history entry, starting with the current URL"], -  "vomnibar.activateTabSelection": ["Search through your open tabs"], - -  nextFrame: ["Cycle forward to the next frame on the page", { background: true, passCountToFunction: true }] -}; - -for (var command in commandDescriptions) -  addCommand(command, commandDescriptions[command][0], commandDescriptions[command][1]); - - -// An ordered listing of all available commands, grouped by type. This is the order they will -// be shown in the help page. -var commandGroups = { -  pageNavigation: -    ["scrollDown", "scrollUp", "scrollLeft", "scrollRight", -     "scrollToTop", "scrollToBottom", "scrollToLeft", "scrollToRight", "scrollPageDown", -     "scrollPageUp", "scrollFullPageUp", "scrollFullPageDown", -     "reload", "toggleViewSource", "copyCurrentUrl", "linkHints.activateModeToCopyLinkUrl", -     "openCopiedUrlInCurrentTab", "openCopiedUrlInNewTab", "goUp", -     "enterInsertMode", "focusInput", -     "linkHints.activateMode", "linkHints.activateModeToOpenInNewTab", "linkHints.activateModeWithQueue", -     "vomnibar.activate", "vomnibar.activateWithCurrentUrl", "vomnibar.activateTabSelection", -     "goPrevious", "goNext", "nextFrame"], -  findCommands: ["enterFindMode", "performFind", "performBackwardsFind"], -  historyNavigation: -    ["goBack", "goForward"], -  tabManipulation: -    ["nextTab", "previousTab", "firstTab", "lastTab", "createTab", "removeTab", "restoreTab"], -  misc: -    ["showHelp"] -}; - -// Rarely used commands are not shown by default in the help dialog or in the README. The goal is to present -// a focused, high-signal set of commands to the new and casual user. Only those truly hungry for more power -// from Vimium will uncover these gems. -var advancedCommands = [ -    "scrollToLeft", "scrollToRight", -    "goUp", "focusInput", "linkHints.activateModeWithQueue", -    "goPrevious", "goNext"]; diff --git a/options.html b/options.html index d38d6b0c..ba97d0ab 100644 --- a/options.html +++ b/options.html @@ -95,10 +95,10 @@    var postSaveHooks = {      keyMappings: function (value) { -      backgroundPage = chrome.extension.getBackgroundPage(); -      backgroundPage.clearKeyMappingsAndSetDefaults(); -      backgroundPage.parseCustomKeyMappings(value); -      backgroundPage.refreshCompletionKeysAfterMappingSave(); +      commands = chrome.extension.getBackgroundPage().Commands; +      commands.clearKeyMappingsAndSetDefaults(); +      commands.parseCustomKeyMappings(value); +      chrome.extension.getBackgroundPage().refreshCompletionKeysAfterMappingSave();      }    }; | 
