From cbc0337110bf70a0f261d9b0e7282edb298e48fd Mon Sep 17 00:00:00 2001 From: gorhill Date: Sat, 16 May 2015 13:17:46 -0400 Subject: [PATCH] code review re. new tab selector --- src/css/logger-ui.css | 2 +- src/js/logger-ui.js | 17 +++++------------ src/js/messaging.js | 9 +++++---- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/css/logger-ui.css b/src/css/logger-ui.css index 8ee07c7..4c1b9b3 100644 --- a/src/css/logger-ui.css +++ b/src/css/logger-ui.css @@ -48,7 +48,7 @@ body { vertical-align: middle; } #pageSelector { - max-width: 28em; + width: 28em; padding: 0.2em 0; } body #compactViewToggler.button:before { diff --git a/src/js/logger-ui.js b/src/js/logger-ui.js index 690f8f5..80504e2 100644 --- a/src/js/logger-ui.js +++ b/src/js/logger-ui.js @@ -281,11 +281,7 @@ var renderLogEntry = function(entry) { tr.cells[0].title = time.toLocaleDateString('fullwide', dateOptions); if ( entry.tab ) { - tr.classList.add('tab'); - var className = classNameFromTabId(entry.tab); - if ( className !== '' ) { - tr.classList.add(className); - } + tr.classList.add('tab', classNameFromTabId(entry.tab)); if ( entry.tab === noTabId ) { tr.cells[1].appendChild(createHiddenTextNode('bts')); } @@ -384,11 +380,9 @@ var synchronizeTabIds = function(newTabIds) { var select = document.getElementById('pageSelector'); var selectValue = select.value; var tabIds = Object.keys(newTabIds).sort(function(a, b) { - var sa = newTabIds[a].title || newTabIds[a].url; - var sb = newTabIds[b].title || newTabIds[b].url; - return sa.localeCompare(sb); + return newTabIds[a].localeCompare(newTabIds[a]); }); - var option, entry; + var option; for ( var i = 0, j = 2; i < tabIds.length; i++ ) { tabId = tabIds[i]; if ( tabId === noTabId ) { @@ -400,8 +394,7 @@ var synchronizeTabIds = function(newTabIds) { option = document.createElement('option'); select.appendChild(option); } - entry = newTabIds[tabId]; - option.textContent = entry.title || entry.url; + option.textContent = newTabIds[tabId]; option.value = classNameFromTabId(tabId); if ( option.value === selectValue ) { option.setAttribute('selected', ''); @@ -409,7 +402,7 @@ var synchronizeTabIds = function(newTabIds) { option.removeAttribute('selected'); } } - for ( ; j < select.options.length; j++ ) { + while ( j < select.options.length ) { select.removeChild(select.options[j]); } if ( select.value !== selectValue ) { diff --git a/src/js/messaging.js b/src/js/messaging.js index 4475ab6..cb69dfb 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -909,16 +909,17 @@ var onMessage = function(request, sender, callback) { switch ( request.what ) { case 'readMany': var tabIds = {}; + var loggerURL = vAPI.getURL('logger-ui.html'); var pageStore; for ( var tabId in µm.pageStores ) { pageStore = µm.pageStoreFromTabId(tabId); if ( pageStore === null ) { continue; } - tabIds[tabId] = { - title: pageStore.title, - url: pageStore.pageUrl - }; + if ( pageStore.rawUrl.lastIndexOf(loggerURL, 0) === 0 ) { + continue; + } + tabIds[tabId] = pageStore.title || pageStore.rawUrl; } response = { colorBlind: false,