Fixed buttons and improved load times of list.

This commit is contained in:
2019-04-01 03:18:14 -05:00
parent 5afaf1d6a0
commit f0c2a51887
5 changed files with 39 additions and 52 deletions

View File

@@ -6,7 +6,6 @@ const listZone = document.getElementById("listZone");
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;
@@ -47,13 +46,15 @@ function logTabs(tabs) {
}
function createContainer(tab) {
var id = tab.id;
var spanTag = document.createElement("DIV");
var pTag = document.createElement("P");
var iconText = document.createTextNode(tab.title);
var closeImgTag = document.createElement("IMG");
var hidnStImgTag = document.createElement("IMG");
var icoImgTag = document.createElement("IMG"); // Used to properly set bg
var template = document.querySelector('#tabContainerTemplate');
var clone = document.importNode(template.content, true);
var spanTag = clone.querySelector("#iconElm");
var closeImgTag = clone.querySelector("#closeBttn");
var hidnStImgTag = clone.querySelector("#hideTgglBttn");
var pTag = clone.querySelector(".pTagTitleText");
var icoImgTag = document.createElement("IMG"); // Used to detect image load failure
var iconText = document.createTextNode(tab.title);
var id = tab.id;
// Set oldElm so eventListeners.js has starting ref
if (tab.active == true) {
@@ -70,13 +71,7 @@ function createContainer(tab) {
spanTag.setAttribute("tabID", tab.id);
spanTag.title = tab.title;
spanTag.id = "iconElm";
closeImgTag.id = "closeBttn";
closeImgTag.className = "closeImg";
closeImgTag.src = "../icons/x.png";
hidnStImgTag.id = "hideTgglBttn"
hidnStImgTag.className= "hiderImg";
pTag.className = "pTagTitleText";
if (!tab.hidden) {
spanTag.className = "block";
@@ -89,21 +84,15 @@ function createContainer(tab) {
spanTag.style.backgroundImage = "url(" + tab.favIconUrl + ")";
icoImgTag.src = tab.favIconUrl;
icoImgTag.onerror = function() { spanTag.style.backgroundImage = "url(" + tabImg + ")"; }
spanTag.appendChild(closeImgTag);
spanTag.appendChild(hidnStImgTag);
pTag.appendChild(iconText);
spanTag.appendChild(pTag);
listZone.appendChild(spanTag);
listZone.appendChild(clone);
}
function createTab() {
tabsAction.create({})
.then(function (tab) {
createContainer(tab);
}).then(function () {
listZone.appendChild(plusTag);
});
})
}
function onError(error) { console.log(`Error: ${error}`); }
@@ -120,14 +109,14 @@ function getTabs() {
if (key) {
target.title = "Searching curent windows...";
target.children[0].src = "../icons/windows.png";
target.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.src = "../icons/window.png";
target.setAttribute("searchwindowsmode", false);
tabsAction.query({currentWindow: true})
@@ -141,8 +130,8 @@ function getTabs() {
}
async function setSearchMode(target, text, img, state) {
target.title = "Searching " + text + "...";
target.children[0].src = "../icons/" + img + ".png";
target.title = "Searching " + text + "...";
target.src = "../icons/" + img + ".png";
target.setAttribute("searchwindowsmode", state);
await storageArea.set({"searchMode": state });