Display unloaded tabs properly. Begin adding prune option

This commit is contained in:
dpedu 2015-02-19 16:41:40 -08:00
parent 6233554080
commit ab462d0f43
5 changed files with 43 additions and 18 deletions

View File

@ -1,9 +1,9 @@
_tabbro_ = function() { _tabbro_ = function() {
// Options // Options
this.options = { this.options = {
"autoStickyTabs":true, "autoStickyTabs":true,
"pruneStickyTabs":true
} }
// Database version // Database version
@ -92,6 +92,9 @@ _tabbro_ = function() {
this.t_removeTab = function(tabid) { this.t_removeTab = function(tabid) {
// Removed tab record // Removed tab record
var thewindow = this.t_getWindowFromTab(tabid) var thewindow = this.t_getWindowFromTab(tabid)
// If the window is missing, it was probably ignored because we ignore non-"normal" windows
//if(typeof thewindow == "undefined") return
for(var i in thewindow.tabs) { for(var i in thewindow.tabs) {
if(thewindow.tabs[i].id == tabid) { if(thewindow.tabs[i].id == tabid) {
thewindow.tabs.splice(i, 1) thewindow.tabs.splice(i, 1)
@ -229,7 +232,9 @@ _tabbro_ = function() {
focused:true, focused:true,
url:tab.url url:tab.url
}, function(ev) { }, function(ev) {
debugger //debugger
console.log("ui_open_tab")
console.log(ev)
}) })
} }
@ -306,7 +311,7 @@ _tabbro_ = function() {
// Get all windows // Get all windows
chrome.windows.getAll(function(_windows){ chrome.windows.getAll(function(_windows){
for(var w in _windows) { for(var w in _windows) {
if(_windows[w].type!="normal") continue; //if(_windows[w].type!="normal") continue;
var newWindowInfo = { var newWindowInfo = {
id: _windows[w].id, id: _windows[w].id,
tabs:[], tabs:[],
@ -399,7 +404,7 @@ _tabbro_ = function() {
this.save = function() { this.save = function() {
// Save data to chrome // Save data to chrome
//this._storage.set({"tabbro":this.data}) this._storage.set({"tabbro":this.data})
// Save options to cloud // Save options to cloud
this._cloudstorage.set({"tabbro_options":this.options}) this._cloudstorage.set({"tabbro_options":this.options})
} }
@ -409,8 +414,8 @@ _tabbro_ = function() {
// Add window listeners // Add window listeners
chrome.windows.onCreated.addListener(function(e) { chrome.windows.onCreated.addListener(function(e) {
if(e.type!="normal") return //if(e.type!="normal") return
//console.log("windows.onCreated: "+e.id) console.log("windows.onCreated: "+e.id)
//console.log(e) //console.log(e)
if(bro.nextCreatedWindowIndex==null) { if(bro.nextCreatedWindowIndex==null) {
@ -434,7 +439,7 @@ _tabbro_ = function() {
}) })
chrome.windows.onRemoved.addListener(function(windowid) { chrome.windows.onRemoved.addListener(function(windowid) {
//console.log("windows.onRemoved") console.log("windows.onRemoved")
//console.log(windowid) //console.log(windowid)
var thewindow = bro.t_getWindow(windowid) var thewindow = bro.t_getWindow(windowid)
if(thewindow.sticky) { if(thewindow.sticky) {
@ -457,7 +462,7 @@ _tabbro_ = function() {
// Add tab listeners // Add tab listeners
chrome.tabs.onCreated.addListener(function(e) { chrome.tabs.onCreated.addListener(function(e) {
//console.log("tabs.onCreated") console.log("tabs.onCreated")
//console.log(e) //console.log(e)
var pinned = e.pinned var pinned = e.pinned
@ -487,14 +492,15 @@ _tabbro_ = function() {
}) })
chrome.tabs.onUpdated.addListener(function(tabid) { chrome.tabs.onUpdated.addListener(function(tabid) {
console.log("tabs.onUpdated "+tabid)
// TODO loading indicator when a tab is loading // TODO loading indicator when a tab is loading
// TOOO determine if other attributes need to be tracked // TOOO determine if other attributes need to be tracked
// Update tab title // Update tab title
tab = bro.t_getTab(tabid) tab = bro.t_getTab(tabid)
if(tab) chrome.tabs.get(tabid, function(_tab) { if(tab) chrome.tabs.get(tabid, function(_tab) {
if(_tab == null) debugger //if(_tab == null) debugger
if(tab == null) debugger //if(tab == null) debugger
tab.title = _tab.title tab.title = _tab.title
tab.url = _tab.url tab.url = _tab.url
tab.pinned = _tab.pinned tab.pinned = _tab.pinned
@ -506,7 +512,7 @@ _tabbro_ = function() {
}) })
chrome.tabs.onMoved.addListener(function(tabid) { chrome.tabs.onMoved.addListener(function(tabid) {
//console.log("tabs.onMoved "+tabid) console.log("tabs.onMoved "+tabid)
// Fetch tab // Fetch tab
chrome.tabs.get(tabid, function(_tab) { chrome.tabs.get(tabid, function(_tab) {
@ -526,18 +532,19 @@ _tabbro_ = function() {
}) })
chrome.tabs.onActivated.addListener(function(x) { chrome.tabs.onActivated.addListener(function(x) {
//console.log("tabs.onActivated") console.log("tabs.onActivated")
//console.log(x) console.log(x)
// TODO indicate that this tab is the active one // TODO indicate that this tab is the active one
}) })
chrome.tabs.onHighlighted.addListener(function(x) { chrome.tabs.onHighlighted.addListener(function(x) {
//console.log("tabs.onHighlighted") console.log("tabs.onHighlighted")
//console.log(x) console.log(x)
// This seems the same as tabs.onActivated? // This seems the same as tabs.onActivated?
}) })
chrome.tabs.onDetached.addListener(function(tabid) { chrome.tabs.onDetached.addListener(function(tabid) {
console.log("tabs.onDetached "+tabid)
// Remove tab from it's window // Remove tab from it's window
var tab = bro.t_getTab(tabid) var tab = bro.t_getTab(tabid)
bro.t_removeTab(tabid) bro.t_removeTab(tabid)
@ -547,6 +554,7 @@ _tabbro_ = function() {
}) })
chrome.tabs.onAttached.addListener(function(tabid) { chrome.tabs.onAttached.addListener(function(tabid) {
console.log("tabs.onAttached "+tabid)
// Remove from bro.detached_tabs // Remove from bro.detached_tabs
var tab = bro.detached_tabs.splice(tabid, 1)[0] var tab = bro.detached_tabs.splice(tabid, 1)[0]
@ -558,7 +566,7 @@ _tabbro_ = function() {
}) })
chrome.tabs.onRemoved.addListener(function(tabid) { chrome.tabs.onRemoved.addListener(function(tabid) {
//console.log("tabs.onRemoved "+tabid) console.log("tabs.onRemoved "+tabid)
//console.log(tabid) //console.log(tabid)
@ -578,7 +586,7 @@ _tabbro_ = function() {
}) })
chrome.tabs.onReplaced.addListener(function(x) { chrome.tabs.onReplaced.addListener(function(x) {
//console.log("tabs.onReplaced") console.log("tabs.onReplaced")
//console.log(x) //console.log(x)
// TODO handle when a tab is inexplicable replaced with another tab // TODO handle when a tab is inexplicable replaced with another tab
}) })

View File

@ -20,6 +20,16 @@
<span class="off">When a new tab is opened, it will not be sticky. If the parent window is closed, only stick tabs are saved.</span> <span class="off">When a new tab is opened, it will not be sticky. If the parent window is closed, only stick tabs are saved.</span>
</div> </div>
</li> </li>
<li>
<label class="clearfix">
<input type="checkbox" class="toggle" id="pruneStickyTabs" />
<strong>Prune sticky tabs</strong>
</label>
<div class="answer">
<span class="on">When a tab is closed in a sticky window, it will be removed.</span>
<span class="off">When a tab is closed in a sticky window, it will be saved under that window.</span>
</div>
</li>
</ul> </ul>
<br /> <br />
<br /> <br />

View File

@ -167,7 +167,7 @@ function renderTab(tabdata, tabnum, winnum) {
//console.log("renderTab("+tabdata+", "+tabnum+", "+winnum+")") //console.log("renderTab("+tabdata+", "+tabnum+", "+winnum+")")
//console.log(tabdata) //console.log(tabdata)
var tab = element('li', {class:"clearfix"}) var tab = element('li', {class:"clearfix "+(tabdata.id==null?'unloaded':'loaded')})
if(tabdata.icon && tabdata.icon.substr(0, 9)!="chrome://") { if(tabdata.icon && tabdata.icon.substr(0, 9)!="chrome://") {
tab.style.backgroundImage = "url(\""+tabdata.icon+"\")"; tab.style.backgroundImage = "url(\""+tabdata.icon+"\")";

View File

@ -167,6 +167,8 @@ ul#root > li {
white-space: nowrap; white-space: nowrap;
display: block; display: block;
padding-right: 3px; } padding-right: 3px; }
ul#root > li > ul > li.unloaded > span {
color: #AAA; }
ul#root > li > ul > li:nth-child(2n+1) { ul#root > li > ul > li:nth-child(2n+1) {
background-color: rgba(0, 0, 0, 0.05); } background-color: rgba(0, 0, 0, 0.05); }

View File

@ -205,6 +205,11 @@ ul#root {
display: block; display: block;
padding-right: 3px; padding-right: 3px;
} }
&.unloaded {
&>span {
color: #AAA;
}
}
&:nth-child(2n+1) { &:nth-child(2n+1) {
background-color: rgba(0,0,0,0.05); background-color: rgba(0,0,0,0.05);
} }