Added all window search and list with toggling functionality.

This commit is contained in:
2018-05-21 04:48:34 -05:00
parent 316d9840f6
commit da93d9cfc3
9 changed files with 118 additions and 37 deletions

View File

@@ -6,12 +6,40 @@ const notFoundText = document.createTextNode("Search not found...");
const tabImg = browser.extension.getURL("icons/tab.png");
var oldElm = "";
var plusTag = ""
var currentWinId = undefined;
var newWinId = undefined;
var focusedWinID = undefined;
var windowIndex = 0;
function logTabs(tabs) {
// tab.url requires the `tabs` permission
windowIndex = 0;
tabsAction.query({currentWindow: true, active: true}).then((tab) => {
focusedWinID = tab[0].windowId;
}, focusedWinID);
for (let tab of tabs) {
createContainer(tab);
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++;
createContainer(tab);
} else {
windowIndex = 1;
}
}
newWinId = currentWinId;
}
newWinId = undefined;
// Set poped-out-window position and 100px up from selected elm
oldElm.scrollIntoView();
window.scrollBy(0, -100);
@@ -75,9 +103,21 @@ function createTab() {
function onError(error) { console.log(`Error: ${error}`); }
function getTabs(tabs) {
// Get current tab and then list of tabs
tabsAction.query({currentWindow: true})
.then(logTabs, onError);
function getTabs() {
var elm = document.getElementById("searchMode");
var currentMode = (elm.getAttribute("searchwindowsmode") == "false");
if (currentMode == false) {
tabsAction.query({}).then(logTabs, onError)
.then(resetWinIndex, onError);
} else {
tabsAction.query({currentWindow: currentMode})
.then(logTabs, onError)
}
}
function resetWinIndex() {
windowIndex = 0;
}
getTabs();