diff options
| author | Stephen Blott | 2016-02-09 15:55:49 +0000 | 
|---|---|---|
| committer | Stephen Blott | 2016-02-09 15:55:52 +0000 | 
| commit | 60d33d20026cdcdd0c4ecef20410d38341c86633 (patch) | |
| tree | cd9c40694ad4fadd039e143685e33be49b45610d /background_scripts/bg_utils.coffee | |
| parent | 4ada22e85dcd061fa806a5fe72a9dc3f1cfe0442 (diff) | |
| download | vimium-60d33d20026cdcdd0c4ecef20410d38341c86633.tar.bz2 | |
BgUtils; implement visitPreviousTab.
Implements visitPreviousTab (as discussed in #1955).
Diffstat (limited to 'background_scripts/bg_utils.coffee')
| -rw-r--r-- | background_scripts/bg_utils.coffee | 7 | 
1 files changed, 7 insertions, 0 deletions
| diff --git a/background_scripts/bg_utils.coffee b/background_scripts/bg_utils.coffee index 9c1674bf..bd00fd24 100644 --- a/background_scripts/bg_utils.coffee +++ b/background_scripts/bg_utils.coffee @@ -39,6 +39,13 @@ class TabRecency      @cache[tabId] ||= 1      if tabId == @current then 0.0 else @cache[tabId] / @timestamp +  # Get the tab Id of the count-th most recently visited tab (excluding tabId, which is the current tab). +  getRecentTab: (tabId, count) -> +    tabId = tabId.toString() +    tabIds = (tId for own tId of @cache when tId != tabId) +    tabIds.sort (a,b) => @cache[b] - @cache[a] +    parseInt tabIds[(count-1)%tabIds.length] +  BgUtils =    tabRecency: new TabRecency() | 
