Cleaned up code logic and wording.
This commit is contained in:
parent
4f5173f7f9
commit
7feec057a5
|
@ -1,3 +1,7 @@
|
||||||
|
document.getElementById("searchBar").onkeypress = function () {
|
||||||
|
searchTabs();
|
||||||
|
}
|
||||||
|
|
||||||
// Set click events for tab blocks
|
// Set click events for tab blocks
|
||||||
document.addEventListener("click", (e) => {
|
document.addEventListener("click", (e) => {
|
||||||
var target = (!e.target.className.includes("pTagTitleText")) ? e.target : e.target.parentElement;
|
var target = (!e.target.className.includes("pTagTitleText")) ? e.target : e.target.parentElement;
|
||||||
|
@ -6,75 +10,87 @@ document.addEventListener("click", (e) => {
|
||||||
var id = 0;
|
var id = 0;
|
||||||
|
|
||||||
if (targetID == "closeBttn") {
|
if (targetID == "closeBttn") {
|
||||||
if (parentElm == oldElm) {
|
closeBttnAction(target, targetID, parentElm, id);
|
||||||
var index = Array.from(parentElm.parentElement.children).indexOf(parentElm);
|
|
||||||
(index - 1 < 0) ? index++ : index-- ; // Check what index to chose
|
|
||||||
var newElm = parentElm.parentElement.children[index];
|
|
||||||
|
|
||||||
id = parseInt(newElm.getAttribute("tabID"));
|
|
||||||
browser.tabs.update(id, { active: true });
|
|
||||||
setOldElm(newElm);
|
|
||||||
}
|
|
||||||
|
|
||||||
id = parseInt(parentElm.getAttribute("tabID"));
|
|
||||||
browser.tabs.remove(id);
|
|
||||||
|
|
||||||
parentElm.parentElement.removeChild(parentElm);
|
|
||||||
} else if (targetID == "iconElm") {
|
} else if (targetID == "iconElm") {
|
||||||
id = parseInt(target.getAttribute("tabID"));
|
setNewTabAction(target, targetID, parentElm, id);
|
||||||
tabsAction.get(id).then((tab) => {
|
|
||||||
browser.windows.update(tab.windowId, {focused: true});
|
|
||||||
browser.tabs.update(id, { active: true });
|
|
||||||
},id);
|
|
||||||
|
|
||||||
setOldElm(target);
|
|
||||||
} else if (targetID == "goTop") {
|
} else if (targetID == "goTop") {
|
||||||
window.scrollTo(0,0);
|
window.scrollTo(0,0);
|
||||||
} else if (targetID == "goBottom") {
|
} else if (targetID == "goBottom") {
|
||||||
window.scrollTo(0, document.body.scrollHeight);
|
window.scrollTo(0, document.body.scrollHeight);
|
||||||
} else if (targetID == "goToTab") {
|
} else if (targetID == "goToTab") {
|
||||||
// Go to selected and 100px up
|
// Go to selected and 100px up
|
||||||
oldElm.scrollIntoView();
|
oldElm.scrollIntoView();
|
||||||
window.scrollBy(0, -100);
|
window.scrollBy(0, -100);
|
||||||
} else if (targetID == "newTab") {
|
} else if (targetID == "newTab") {
|
||||||
createTab();
|
createTab();
|
||||||
} else if (targetID == "hideTgglBttn") {
|
} else if (targetID == "hideTgglBttn") {
|
||||||
id = parseInt(parentElm.getAttribute("tabID"));
|
hideSelectedTabAction(target, targetID, parentElm, id);
|
||||||
|
|
||||||
if (id != oldElm.getAttribute("tabID")) {
|
|
||||||
if (target.src.includes("eyeClosed.png")) {
|
|
||||||
parentElm.setAttribute("class", "block");
|
|
||||||
target.src = "../icons/eyeOpen.png"
|
|
||||||
unhideSelectedTab(id);
|
|
||||||
} else {
|
|
||||||
parentElm.setAttribute("class", "block hiddenBGColor");
|
|
||||||
target.src = "../icons/eyeClosed.png"
|
|
||||||
hideSelectedTab(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (targetID == "hideAllBttn") {
|
} else if (targetID == "hideAllBttn") {
|
||||||
doAllTabs(0)
|
showHideTabsAction(0)
|
||||||
} else if (targetID == "showAllBttn") {
|
} else if (targetID == "showAllBttn") {
|
||||||
doAllTabs(1);
|
showHideTabsAction(1);
|
||||||
} else if (targetID == "searchMode") {
|
} else if (targetID == "searchMode") {
|
||||||
var currentMode = target.getAttribute("searchwindowsmode");
|
setSearchModeAction(target, targetID, parentElm, id);
|
||||||
if (currentMode == "true") {
|
|
||||||
// In generateview
|
|
||||||
setSearchMode(target, "curent window", "window", false);
|
|
||||||
} else {
|
|
||||||
setSearchMode(target, "all windows", "windows", true);
|
|
||||||
}
|
|
||||||
clearNodes(listZone);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function closeBttnAction(var target, var targetID, var parentElm, var id) {
|
||||||
|
if (parentElm == oldElm) {
|
||||||
|
var index = Array.from(parentElm.parentElement.children).indexOf(parentElm);
|
||||||
|
(index - 1 < 0) ? index++ : index-- ; // Check what index to chose
|
||||||
|
var newElm = parentElm.parentElement.children[index];
|
||||||
|
|
||||||
|
id = parseInt(newElm.getAttribute("tabID"));
|
||||||
|
browser.tabs.update(id, { active: true });
|
||||||
|
setOldElm(newElm);
|
||||||
|
}
|
||||||
|
|
||||||
|
id = parseInt(parentElm.getAttribute("tabID"));
|
||||||
|
browser.tabs.remove(id);
|
||||||
|
|
||||||
|
parentElm.parentElement.removeChild(parentElm);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setNewTabAction(var target, var targetID, var parentElm, var id) {
|
||||||
|
id = parseInt(target.getAttribute("tabID"));
|
||||||
|
tabsAction.get(id).then((tab) => {
|
||||||
|
browser.windows.update(tab.windowId, {focused: true});
|
||||||
|
browser.tabs.update(id, { active: true });
|
||||||
|
},id);
|
||||||
|
|
||||||
|
setOldElm(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideSelectedTabAction(var target, var targetID, var parentElm, var id) {
|
||||||
|
id = parseInt(parentElm.getAttribute("tabID"));
|
||||||
|
|
||||||
|
if (id != oldElm.getAttribute("tabID")) {
|
||||||
|
if (target.src.includes("eyeClosed.png")) {
|
||||||
|
parentElm.setAttribute("class", "block");
|
||||||
|
target.src = "../icons/eyeOpen.png"
|
||||||
|
unhideSelectedTab(id);
|
||||||
|
} else {
|
||||||
|
parentElm.setAttribute("class", "block hiddenBGColor");
|
||||||
|
target.src = "../icons/eyeClosed.png"
|
||||||
|
hideSelectedTab(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setSearchModeAction(var target, var targetID, var parentElm, var id) {
|
||||||
|
var currentMode = target.getAttribute("searchwindowsmode");
|
||||||
|
if (currentMode == "true") {
|
||||||
|
// In generateview
|
||||||
|
setSearchMode(target, "curent window", "window", false);
|
||||||
|
} else {
|
||||||
|
setSearchMode(target, "all windows", "windows", true);
|
||||||
|
}
|
||||||
|
clearNodes(listZone);
|
||||||
|
}
|
||||||
|
|
||||||
function setOldElm(target) {
|
function setOldElm(target) {
|
||||||
target.querySelectorAll(".hiderImg")[0].src = "../icons/eyeOpen.png";
|
target.querySelectorAll(".hiderImg")[0].src = "../icons/eyeOpen.png";
|
||||||
oldElm.setAttribute("class", "block");
|
oldElm.setAttribute("class", "block");
|
||||||
oldElm = target;
|
oldElm = target;
|
||||||
target.setAttribute("class", "block block-focused");
|
target.setAttribute("class", "block block-focused");
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById("searchBar").onkeypress = function () {
|
|
||||||
searchTabs();
|
|
||||||
}
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ function errMsg(ev) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function doAllTabs(doType) {
|
function showHideTabsAction(doType) {
|
||||||
// 0 == hide and 1 == unhide
|
// 0 == hide and 1 == unhide
|
||||||
tabsAction.query({currentWindow: true}).then((tabs) => {
|
tabsAction.query({currentWindow: true}).then((tabs) => {
|
||||||
var tabCollectionIDs = [];
|
var tabCollectionIDs = [];
|
||||||
|
|
Loading…
Reference in New Issue