Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
jgv committed May 22, 2011
2 parents 3c5954d + 345a97a commit de97bd0
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions tabby.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var tabs = [];
var timeout = 900; // fifteen minutes... this seems to go by really quick though
var timerId;
var timerId, selected;

function tabWasCreated (tabId, changeInfo, tab) {
new Tab(tabId, changeInfo, tab);
Expand All @@ -22,6 +22,14 @@ function tabWasRemoved (tabId, removeInfo) {
}
}

function tabIsSelected(id) {
selected = id;
}

//function tabIsVideo(tab) {

//}

function Tab (tabId, changeInfo, tab) {
this.id = tabId.id;
this.counter = 0;
Expand All @@ -30,16 +38,18 @@ function Tab (tabId, changeInfo, tab) {
}

function timer(id) {
timerId = setInterval(checkTabs, 1000);
timerId = setInterval(checkTabs, 2000); // playing with the timer interval for performance
}

function stopTimer(timerId) {
clearInterval(timerId);
}

function checkTabs () {
for (i = 0; i < tabs.length; i++) {
tabs[i].counter = tabs[i].counter + 1;
for (i = 0; i < tabs.length; i++) {
if (tabs[i].id != selected) {
tabs[i].counter = tabs[i].counter + 1;
}
if (tabs[i].counter >= timeout) {
chrome.tabs.remove(tabs[i].id);
tabs.splice(tabs.indexOf(tabs[i]), 1);
Expand All @@ -50,4 +60,5 @@ function checkTabs () {

chrome.tabs.onCreated.addListener(tabWasCreated);
chrome.tabs.onUpdated.addListener(tabWasUpdated);
chrome.tabs.onRemoved.addListener(tabWasRemoved);
chrome.tabs.onSelectionChanged.addListener(tabIsSelected);
chrome.tabs.onRemoved.addListener(tabWasRemoved);

0 comments on commit de97bd0

Please sign in to comment.