diff options
| author | Phil Crosby | 2012-05-05 18:54:50 -0700 | 
|---|---|---|
| committer | Phil Crosby | 2012-05-05 18:54:50 -0700 | 
| commit | 6b3eea3c55519599bc6e5b9764604d5daa0bdd29 (patch) | |
| tree | ce0f376b3856bdb6ad97effe8cc377c8a9ce611d /fuzzyMode.js | |
| parent | 15a5319948ec0f27b83cdbb906db879e5f6689d5 (diff) | |
| download | vimium-6b3eea3c55519599bc6e5b9764604d5daa0bdd29.tar.bz2 | |
The completion actions make more sense grouped together.
Diffstat (limited to 'fuzzyMode.js')
| -rw-r--r-- | fuzzyMode.js | 34 | 
1 files changed, 19 insertions, 15 deletions
diff --git a/fuzzyMode.js b/fuzzyMode.js index 9d4f32e8..8d9329ef 100644 --- a/fuzzyMode.js +++ b/fuzzyMode.js @@ -180,7 +180,7 @@ var fuzzyMode = (function() {          if (msg.id != id) return;          callback(msg.results.map(function(result) {            // functionName will be either "navigateToUrl" or "switchToTab". args will be a URL or a tab ID. -          var functionToCall = eval(result.action.functionName); +          var functionToCall = completionActions[result.action.functionName];            result.performAction = functionToCall.curry(result.action.args);            return result;          })); @@ -189,20 +189,25 @@ var fuzzyMode = (function() {      }    }); -  /* Called when an item in the Vomnibox is chosen and requires navigating to a URL. */ -  function navigateToUrl(url, openInNewTab) { -    // If the URL is a bookmarklet prefixed with javascript:, we shouldn't open that in a new tab. -    if (url.indexOf("javascript:") == 0) -      openInNewTab = false; -    chrome.extension.sendRequest({ -      handler: openInNewTab ? "openUrlInNewTab" : "openUrlInCurrentTab", -      url: url, -      selected: openInNewTab -    }); -  } +  /* +   * These are the actions we can perform when the user selects a result in the Vomnibox. +   */ +  var completionActions = { +    navigateToUrl: function(url, openInNewTab) { +      // If the URL is a bookmarklet prefixed with javascript:, we shouldn't open that in a new tab. +      if (url.indexOf("javascript:") == 0) +        openInNewTab = false; +      chrome.extension.sendRequest({ +        handler: openInNewTab ? "openUrlInNewTab" : "openUrlInCurrentTab", +        url: url, +        selected: openInNewTab +      }); +    }, -  /* Called when an item in the Vomnibox is chosen and requires switching to a tab. */ -  function switchToTab(tabId) { chrome.extension.sendRequest({ handler: "selectSpecificTab", id: tabId }); } +    switchToTab: function(tabId) { +      chrome.extension.sendRequest({ handler: "selectSpecificTab", id: tabId }); +    } +  };    // public interface    return { @@ -210,5 +215,4 @@ var fuzzyMode = (function() {      activateAllNewTab: function() { start("omni", true,  100);  },      activateTabs:      function() { start("tabs", false, 0);  },    } -  })();  | 
