diff --git a/README.md b/README.md index 03be841..998da0b 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,9 @@ Search Firefox tabs and get a list or automatic direct to the searched tab. # Download https://addons.mozilla.org/en-US/firefox/addon/tab-search-and-manage/ -# Version: 1.2.8 +# Version: 1.2.9 ***Note: diff --git a/src/manifest.json b/src/manifest.json index 2878f28..a1dc212 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Tab Search and Manage", - "version": "1.2.8", + "version": "1.2.9", "description": "This plugin can search, drag-n-drop ordering, and (un)hide all or some tabs.", "applications": { diff --git a/src/scripts/generateView.js b/src/scripts/generateView.js index 07570d0..af4b9ef 100644 --- a/src/scripts/generateView.js +++ b/src/scripts/generateView.js @@ -14,32 +14,34 @@ var windowIndex = 0; function logTabs(tabs) { windowIndex = 0; - tabsAction.query({currentWindow: true, active: true}).then((tab) => { - focusedWinID = tab[0].windowId; - }, focusedWinID); - for (let tab of tabs) { - currentWinId = tab.windowId; - if (currentWinId == newWinId) { - createContainer(tab); - } else { - if (windowIndex != 0) { - var pTag = document.createElement("P"); - var msg = (focusedWinID == tab.windowId) - ? "[ Current Window ] " : "Window: " + tab.windowId; - var pText = document.createTextNode(msg); - pTag.className = "windowIdHeaders"; - pTag.appendChild(pText); - listZone.appendChild(pTag); - windowIndex++; + tabsAction.query({currentWindow: true, active: true}).then((tab) => { + console.log(tab); + focusedWinID = tab[0].windowId; + }, focusedWinID).then(() => { + for (let tab of tabs) { + currentWinId = tab.windowId; + if (currentWinId == newWinId) { createContainer(tab); } else { - createContainer(tab); - windowIndex = 1; + if (windowIndex != 0) { + var pTag = document.createElement("P"); + var msg = (focusedWinID == tab.windowId) + ? "[ Current Window ] " : "Window: " + tab.windowId; + var pText = document.createTextNode(msg); + pTag.className = "windowIdHeaders"; + pTag.appendChild(pText); + listZone.appendChild(pTag); + windowIndex++; + createContainer(tab); + } else { + createContainer(tab); + windowIndex = 1; + } } + newWinId = currentWinId; } - newWinId = currentWinId; - } + }); newWinId = undefined; // Set poped-out-window position and 100px up from selected elm @@ -56,6 +58,19 @@ function createContainer(tab) { var hidnStImgTag = document.createElement("IMG"); var icoImgTag = document.createElement("IMG"); // Used to properly set bg + // Set oldElm so eventListeners.js has starting ref + if (tab.active == true) { + browser.windows.getCurrent().then((window) => { + if (tab.windowId == window.id) { + spanTag.className = "block block-focused"; + if (oldElm) { + oldElm.setAttribute("class", "block"); + } + oldElm = spanTag; + } + }, tab, oldElm, spanTag); + } + spanTag.setAttribute("tabID", tab.id); spanTag.title = tab.title; spanTag.id = "iconElm"; @@ -83,15 +98,6 @@ function createContainer(tab) { pTag.appendChild(iconText); spanTag.appendChild(pTag); listZone.appendChild(spanTag); - - // Set oldElm so eventListeners.js has starting ref - if (tab.active == true) { - spanTag.className = "block block-focused"; - if (oldElm) { - oldElm.setAttribute("class", "block"); - } - oldElm = spanTag; - } } function createTab() { diff --git a/src/scripts/searchTabs.js b/src/scripts/searchTabs.js index 0eded92..92e02e2 100644 --- a/src/scripts/searchTabs.js +++ b/src/scripts/searchTabs.js @@ -16,7 +16,14 @@ function findTabs(tabs) { searchBar.value = ""; errHandler.style.display = "none"; clearNodes(errHandler); - loadSelTab(selection[0].id); + + if (selection[0].windowId == focusedWinID) { + loadSelTab(selection[0].id); + } else { + browser.windows.update(selection[0].windowId, {focused: true}) + .finally(loadSelTab(selection[0].id)); + } + getTabs(); } else { errHandler.style.display = "block";