aboutsummaryrefslogtreecommitdiffstats
path: root/background_page.html
diff options
context:
space:
mode:
authorilya2009-10-28 23:20:11 -0700
committerilya2009-10-28 23:20:11 -0700
commit6f8fb89dd710e6709457ed64fd54a6f30f347d86 (patch)
treeab320cfaf3e64a99787806ab2436a00a301a0e30 /background_page.html
parent1bb0d3bcabb0b874cd3684db8f06dd68fad55a3b (diff)
downloadvimium-6f8fb89dd710e6709457ed64fd54a6f30f347d86.tar.bz2
Add tab create and remove to the new system, disable the old system.
Diffstat (limited to 'background_page.html')
-rw-r--r--background_page.html22
1 files changed, 16 insertions, 6 deletions
diff --git a/background_page.html b/background_page.html
index bddfbb17..18f91a6d 100644
--- a/background_page.html
+++ b/background_page.html
@@ -24,9 +24,21 @@
}
}
+ function createTab() {
+ console.log("createTab()");
+ chrome.tabs.create({});
+ }
+
+ function removeTab() {
+ console.log("removeTab()");
+ chrome.tabs.getSelected(null, function(tab) { chrome.tabs.remove(tab.id); });
+ }
+
var keyToCommandRegistry = {};
- keyToCommandRegistry['gg'] = {command: 'scrollToTop', executeInPage: true};
- keyToCommandRegistry['G'] = {command: 'scrollToBottom', executeInPage: true};
+ keyToCommandRegistry['gg'] = {command: 'scrollToTop'};
+ keyToCommandRegistry['G'] = {command: 'scrollToBottom'};
+ keyToCommandRegistry['t'] = {command: createTab};
+ keyToCommandRegistry['d'] = {command: removeTab};
var commandRegistry = {};
var keyQueue = "";
@@ -43,16 +55,14 @@
registryEntry = keyToCommandRegistry[keyQueue];
console.log("command found for [", keyQueue, "],", registryEntry.command);
- if (registryEntry.executeInPage)
+ if (typeof(registryEntry.command) == "string")
{
chrome.tabs.getSelected(null, function (tab) {
var port = chrome.tabs.connect(tab.id, {name: "executePageCommand"});
port.postMessage({command: registryEntry.command});
});
}
- else
- {
- }
+ else { registryEntry.command.call(); }
keyQueue = "";
}