aboutsummaryrefslogtreecommitdiffstats
path: root/background_page.html
diff options
context:
space:
mode:
authorilya2010-02-26 22:21:45 -0800
committerilya2010-02-26 22:47:26 -0800
commit7c2cb40b4ee49935910c6e0308df55aaf906256f (patch)
treee4e9d1b029b3561d2f44a6206b7407cc24e19be0 /background_page.html
parent9286b8f61fe595ab37f8de2bf36d2f2e1d537e15 (diff)
downloadvimium-7c2cb40b4ee49935910c6e0308df55aaf906256f.tar.bz2
Key Mapping - Create an available commands structure and factor out the key registry into commands.js
Diffstat (limited to 'background_page.html')
-rw-r--r--background_page.html56
1 files changed, 6 insertions, 50 deletions
diff --git a/background_page.html b/background_page.html
index 10340019..faf1fa1b 100644
--- a/background_page.html
+++ b/background_page.html
@@ -1,5 +1,6 @@
<html>
<head>
+<script type="text/javascript" src="commands.js"/>
<script type="text/javascript" charset="utf-8">
// Currently we need to remember to change this each time we push. Chromium #15242 will enable us
// to retrieve this programmatically.
@@ -274,51 +275,6 @@
}
// End action functions
- var keyToCommandRegistry = {};
- keyToCommandRegistry['j'] = 'scrollDown';
- keyToCommandRegistry['k'] = 'scrollUp';
- keyToCommandRegistry['h'] = 'scrollLeft';
- keyToCommandRegistry['l'] = 'scrollRight';
- keyToCommandRegistry['gg'] = 'scrollToTop';
- keyToCommandRegistry['G'] = 'scrollToBottom';
- keyToCommandRegistry['<c-e>'] = 'scrollDown';
- keyToCommandRegistry['<c-y>'] = 'scrollUp';
- keyToCommandRegistry['<c-d>'] = "scrollPageDown";
- keyToCommandRegistry['<c-u>'] = "scrollPageUp";
- keyToCommandRegistry['<c-f>'] = "scrollFullPageDown";
- keyToCommandRegistry['<c-b>'] = "scrollFullPageUp";
- keyToCommandRegistry['r'] = 'reload';
- keyToCommandRegistry['gf'] = 'toggleViewSource';
-
- keyToCommandRegistry['i'] = 'enterInsertMode';
-
- keyToCommandRegistry['ba'] = 'goBack';
- keyToCommandRegistry['H'] = 'goBack';
- keyToCommandRegistry['fw'] = 'goForward';
- keyToCommandRegistry['fo'] = 'goForward';
- keyToCommandRegistry['L'] = 'goForward';
-
- keyToCommandRegistry['zi'] = 'zoomIn';
- keyToCommandRegistry['zo'] = 'zoomOut';
-
- keyToCommandRegistry['f'] = 'activateLinkHintsMode';
- keyToCommandRegistry['F'] = 'activateLinkHintsModeToOpenInNewTab';
-
- keyToCommandRegistry['/'] = 'enterFindMode';
- keyToCommandRegistry['n'] = 'performFind';
- keyToCommandRegistry['N'] = 'performBackwardsFind';
-
- keyToCommandRegistry['yy'] = 'copyCurrentUrl';
-
- keyToCommandRegistry['K'] = nextTab;
- keyToCommandRegistry['J'] = previousTab;
- keyToCommandRegistry['gt'] = nextTab;
- keyToCommandRegistry['gT'] = previousTab;
-
- keyToCommandRegistry['t'] = createTab;
- keyToCommandRegistry['d'] = removeTab;
- keyToCommandRegistry['u'] = restoreTab;
-
function getActualKeyStrokeLength(key) {
if (key.slice(0, 3) == "<c-" && key[key.length - 1] == ">")
return 1;
@@ -397,16 +353,16 @@
if (keyToCommandRegistry[command]) {
registryEntry = keyToCommandRegistry[command];
- console.log("command found for [", keysToCheck, "],", registryEntry);
+ console.log("command found for [", keysToCheck, "],", registryEntry.command);
- if (typeof(registryEntry) == "string") {
+ if (!registryEntry.isBackgroundCommand) {
var port = chrome.tabs.connect(tabId, { name: "executePageCommand" });
- port.postMessage({ command: registryEntry, count: count,
+ port.postMessage({ command: registryEntry.command, count: count,
completionKeys: generateCompletionKeys("") });
refreshedCompletionKeys = true;
} else {
- repeatFunction(registryEntry, count, 0);
+ repeatFunction(this[registryEntry.command], count, 0);
}
newKeyQueue = "";
@@ -478,4 +434,4 @@
init();
</script>
</head>
-</html> \ No newline at end of file
+</html>