diff options
| author | ilya | 2009-10-29 01:00:03 -0700 |
|---|---|---|
| committer | ilya | 2009-10-29 01:00:03 -0700 |
| commit | 10c33ba614356d39d601a34bd1e4029ffa9dd124 (patch) | |
| tree | 370d62a9d072c079312c3f90702cf7191c837d38 | |
| parent | 8e85557b22fe025caff6b328f811cbf953ae3c6c (diff) | |
| download | vimium-10c33ba614356d39d601a34bd1e4029ffa9dd124.tar.bz2 | |
Implement basic tab restore functionality (the 'u' command).
| -rw-r--r-- | background_page.html | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/background_page.html b/background_page.html index 0c68f91a..077466b1 100644 --- a/background_page.html +++ b/background_page.html @@ -1,19 +1,25 @@ <html> <head> <script type="text/javascript" charset="utf-8"> + var tabQueue = []; + var keyQueue = ""; + chrome.extension.onConnect.addListener(function(port, name) { if (port.name == "keyDown") port.onMessage.addListener(handleKeyDown); }); - function createTab() { - console.log("createTab()"); - chrome.tabs.create({}); - } + function createTab() { chrome.tabs.create({}); } function removeTab() { - console.log("removeTab()"); - chrome.tabs.getSelected(null, function(tab) { chrome.tabs.remove(tab.id); }); + chrome.tabs.getSelected(null, function(tab) { + tabQueue.push(tab.url); + chrome.tabs.remove(tab.id); + }); + } + + function restoreTab() { + if (tabQueue.length > 0) { chrome.tabs.create({url: tabQueue.pop()}); } } var keyToCommandRegistry = {}; @@ -26,8 +32,7 @@ keyToCommandRegistry['r'] = 'reload'; keyToCommandRegistry['t'] = createTab; keyToCommandRegistry['d'] = removeTab; - - var keyQueue = ""; + keyToCommandRegistry['u'] = restoreTab; function handleKeyDown(key) { keyQueue = keyQueue + key; |
