Fixed serchmode persistence and missing slot 0 tab
This commit is contained in:
parent
da93d9cfc3
commit
c70553b0e4
|
@ -4,9 +4,10 @@ Search Firefox tabs and get a list or automatic direct to the searched tab.
|
||||||
# Download
|
# Download
|
||||||
https://addons.mozilla.org/en-US/firefox/addon/tab-search-and-manage/
|
https://addons.mozilla.org/en-US/firefox/addon/tab-search-and-manage/
|
||||||
|
|
||||||
# Version: 1.2.6
|
# Version: 1.2.8
|
||||||
<ul>
|
<ul>
|
||||||
<li>Added all window search and list with toggling functionality.</li>
|
<li>Fixed search type persistence.</li>
|
||||||
|
<li>Fixed missing starting tabs in list.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
***Note:
|
***Note:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "Tab Search and Manage",
|
"name": "Tab Search and Manage",
|
||||||
"version": "1.2.6",
|
"version": "1.2.8",
|
||||||
"description": "This plugin can search, drag-n-drop ordering, and (un)hide all or some tabs.",
|
"description": "This plugin can search, drag-n-drop ordering, and (un)hide all or some tabs.",
|
||||||
|
|
||||||
"applications": {
|
"applications": {
|
||||||
|
@ -18,7 +18,8 @@
|
||||||
|
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"tabs",
|
"tabs",
|
||||||
"tabHide"
|
"tabHide",
|
||||||
|
"storage"
|
||||||
],
|
],
|
||||||
|
|
||||||
"browser_action": {
|
"browser_action": {
|
||||||
|
|
|
@ -59,16 +59,12 @@ document.addEventListener("click", (e) => {
|
||||||
} else if (targetID == "searchMode") {
|
} else if (targetID == "searchMode") {
|
||||||
var currentMode = target.getAttribute("searchwindowsmode");
|
var currentMode = target.getAttribute("searchwindowsmode");
|
||||||
if (currentMode == "true") {
|
if (currentMode == "true") {
|
||||||
target.title = "Searching curent window...";
|
// In generateview
|
||||||
target.children[0].src = "../icons/window.png";
|
setSearchMode(target, "curent window", "window", false);
|
||||||
target.setAttribute("searchwindowsmode", "false");
|
|
||||||
} else {
|
} else {
|
||||||
target.title = "Searching all windows...";
|
setSearchMode(target, "all windows", "windows", true);
|
||||||
target.children[0].src = "../icons/windows.png";
|
|
||||||
target.setAttribute("searchwindowsmode", "true");
|
|
||||||
}
|
}
|
||||||
clearNodes(listZone);
|
clearNodes(listZone);
|
||||||
getTabs();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
const storageArea = browser.storage.local;
|
||||||
const tabsAction = browser.tabs;
|
const tabsAction = browser.tabs;
|
||||||
const searchBar = document.getElementById("searchBar");
|
const searchBar = document.getElementById("searchBar");
|
||||||
const errHandler = document.getElementById("errorZone");
|
const errHandler = document.getElementById("errorZone");
|
||||||
|
@ -33,13 +34,14 @@ function logTabs(tabs) {
|
||||||
windowIndex++;
|
windowIndex++;
|
||||||
createContainer(tab);
|
createContainer(tab);
|
||||||
} else {
|
} else {
|
||||||
|
createContainer(tab);
|
||||||
windowIndex = 1;
|
windowIndex = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newWinId = currentWinId;
|
newWinId = currentWinId;
|
||||||
}
|
}
|
||||||
|
|
||||||
newWinId = undefined;
|
newWinId = undefined;
|
||||||
// Set poped-out-window position and 100px up from selected elm
|
// Set poped-out-window position and 100px up from selected elm
|
||||||
oldElm.scrollIntoView();
|
oldElm.scrollIntoView();
|
||||||
window.scrollBy(0, -100);
|
window.scrollBy(0, -100);
|
||||||
|
@ -84,7 +86,7 @@ function createContainer(tab) {
|
||||||
|
|
||||||
// Set oldElm so eventListeners.js has starting ref
|
// Set oldElm so eventListeners.js has starting ref
|
||||||
if (tab.active == true) {
|
if (tab.active == true) {
|
||||||
spanTag.className = "block block-focused";
|
spanTag.className = "block block-focused";
|
||||||
if (oldElm) {
|
if (oldElm) {
|
||||||
oldElm.setAttribute("class", "block");
|
oldElm.setAttribute("class", "block");
|
||||||
}
|
}
|
||||||
|
@ -104,15 +106,49 @@ function createTab() {
|
||||||
function onError(error) { console.log(`Error: ${error}`); }
|
function onError(error) { console.log(`Error: ${error}`); }
|
||||||
|
|
||||||
function getTabs() {
|
function getTabs() {
|
||||||
var elm = document.getElementById("searchMode");
|
clearNodes(listZone);
|
||||||
var currentMode = (elm.getAttribute("searchwindowsmode") == "false");
|
|
||||||
|
|
||||||
if (currentMode == false) {
|
storageArea.get("searchMode").then((results) => {
|
||||||
tabsAction.query({}).then(logTabs, onError)
|
var target = document.getElementById("searchMode");
|
||||||
.then(resetWinIndex, onError);
|
if (Object.keys(results).length > 0) {
|
||||||
} else {
|
var fileKeys = Object.keys(results);
|
||||||
tabsAction.query({currentWindow: currentMode})
|
for (let fileKey of fileKeys) {
|
||||||
.then(logTabs, onError)
|
var key = results[fileKey];
|
||||||
|
|
||||||
|
if (key) {
|
||||||
|
target.title = "Searching curent windows...";
|
||||||
|
target.children[0].src = "../icons/windows.png";
|
||||||
|
target.setAttribute("searchwindowsmode", true);
|
||||||
|
|
||||||
|
tabsAction.query({}).then(logTabs, onError)
|
||||||
|
.then(resetWinIndex, onError);
|
||||||
|
} else {
|
||||||
|
target.title = "Searching curent window...";
|
||||||
|
target.children[0].src = "../icons/window.png";
|
||||||
|
target.setAttribute("searchwindowsmode", false);
|
||||||
|
|
||||||
|
tabsAction.query({currentWindow: true})
|
||||||
|
.then(logTabs, onError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setSearchMode(target, "curent window", "window", false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function setSearchMode(target, text, img, state) {
|
||||||
|
target.title = "Searching " + text + "...";
|
||||||
|
target.children[0].src = "../icons/" + img + ".png";
|
||||||
|
target.setAttribute("searchwindowsmode", state);
|
||||||
|
|
||||||
|
await storageArea.set({"searchMode": state });
|
||||||
|
getTabs(); // No loop b/c object keys will be greater than 0 after setup
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearNodes(targetNode) {
|
||||||
|
while (targetNode.firstChild) {
|
||||||
|
targetNode.removeChild(targetNode.firstChild);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,10 +39,19 @@ function searchTabs() {
|
||||||
var currentMode = (elm.getAttribute("searchwindowsmode") == "false");
|
var currentMode = (elm.getAttribute("searchwindowsmode") == "false");
|
||||||
clearNodes(listZone);
|
clearNodes(listZone);
|
||||||
|
|
||||||
if (currentMode == false) {
|
storageArea.get("searchMode").then((results) => {
|
||||||
tabsAction.query({}).then(findTabs, onError);
|
if (Object.keys(results).length > 0) {
|
||||||
} else {
|
var fileKeys = Object.keys(results);
|
||||||
tabsAction.query({currentWindow: currentMode})
|
for (let fileKey of fileKeys) {
|
||||||
.then(findTabs, onError)
|
var key = results[fileKey];
|
||||||
}
|
if (key) {
|
||||||
|
tabsAction.query({}).then(findTabs, onError)
|
||||||
|
.then(resetWinIndex, onError);
|
||||||
|
} else {
|
||||||
|
tabsAction.query({currentWindow: true})
|
||||||
|
.then(findTabs, onError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue