code review re. new tab selector

pull/2/head
gorhill 10 years ago
parent 04354e3e90
commit cbc0337110

@ -48,7 +48,7 @@ body {
vertical-align: middle; vertical-align: middle;
} }
#pageSelector { #pageSelector {
max-width: 28em; width: 28em;
padding: 0.2em 0; padding: 0.2em 0;
} }
body #compactViewToggler.button:before { body #compactViewToggler.button:before {

@ -281,11 +281,7 @@ var renderLogEntry = function(entry) {
tr.cells[0].title = time.toLocaleDateString('fullwide', dateOptions); tr.cells[0].title = time.toLocaleDateString('fullwide', dateOptions);
if ( entry.tab ) { if ( entry.tab ) {
tr.classList.add('tab'); tr.classList.add('tab', classNameFromTabId(entry.tab));
var className = classNameFromTabId(entry.tab);
if ( className !== '' ) {
tr.classList.add(className);
}
if ( entry.tab === noTabId ) { if ( entry.tab === noTabId ) {
tr.cells[1].appendChild(createHiddenTextNode('bts')); tr.cells[1].appendChild(createHiddenTextNode('bts'));
} }
@ -384,11 +380,9 @@ var synchronizeTabIds = function(newTabIds) {
var select = document.getElementById('pageSelector'); var select = document.getElementById('pageSelector');
var selectValue = select.value; var selectValue = select.value;
var tabIds = Object.keys(newTabIds).sort(function(a, b) { var tabIds = Object.keys(newTabIds).sort(function(a, b) {
var sa = newTabIds[a].title || newTabIds[a].url; return newTabIds[a].localeCompare(newTabIds[a]);
var sb = newTabIds[b].title || newTabIds[b].url;
return sa.localeCompare(sb);
}); });
var option, entry; var option;
for ( var i = 0, j = 2; i < tabIds.length; i++ ) { for ( var i = 0, j = 2; i < tabIds.length; i++ ) {
tabId = tabIds[i]; tabId = tabIds[i];
if ( tabId === noTabId ) { if ( tabId === noTabId ) {
@ -400,8 +394,7 @@ var synchronizeTabIds = function(newTabIds) {
option = document.createElement('option'); option = document.createElement('option');
select.appendChild(option); select.appendChild(option);
} }
entry = newTabIds[tabId]; option.textContent = newTabIds[tabId];
option.textContent = entry.title || entry.url;
option.value = classNameFromTabId(tabId); option.value = classNameFromTabId(tabId);
if ( option.value === selectValue ) { if ( option.value === selectValue ) {
option.setAttribute('selected', ''); option.setAttribute('selected', '');
@ -409,7 +402,7 @@ var synchronizeTabIds = function(newTabIds) {
option.removeAttribute('selected'); option.removeAttribute('selected');
} }
} }
for ( ; j < select.options.length; j++ ) { while ( j < select.options.length ) {
select.removeChild(select.options[j]); select.removeChild(select.options[j]);
} }
if ( select.value !== selectValue ) { if ( select.value !== selectValue ) {

@ -909,16 +909,17 @@ var onMessage = function(request, sender, callback) {
switch ( request.what ) { switch ( request.what ) {
case 'readMany': case 'readMany':
var tabIds = {}; var tabIds = {};
var loggerURL = vAPI.getURL('logger-ui.html');
var pageStore; var pageStore;
for ( var tabId in µm.pageStores ) { for ( var tabId in µm.pageStores ) {
pageStore = µm.pageStoreFromTabId(tabId); pageStore = µm.pageStoreFromTabId(tabId);
if ( pageStore === null ) { if ( pageStore === null ) {
continue; continue;
} }
tabIds[tabId] = { if ( pageStore.rawUrl.lastIndexOf(loggerURL, 0) === 0 ) {
title: pageStore.title, continue;
url: pageStore.pageUrl }
}; tabIds[tabId] = pageStore.title || pageStore.rawUrl;
} }
response = { response = {
colorBlind: false, colorBlind: false,

Loading…
Cancel
Save