40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
// Set click events for tab blocks
|
|
document.addEventListener("click", (e) => {
|
|
var target = e.target;
|
|
var targetID = target.id;
|
|
var parentElm = target.parentElement;
|
|
var id = 0;
|
|
|
|
if (targetID == "closeBttn") {
|
|
id = parseInt(parentElm.getAttribute("tabID"));
|
|
|
|
browser.tabs.remove(id);
|
|
|
|
parentElm.parentElement.removeChild(parentElm);
|
|
} else if (targetID == "iconElm" || targetID == "faveIcon") {
|
|
if (targetID == "faveIcon")
|
|
target = parentElm.parentElement;
|
|
|
|
id = parseInt(target.getAttribute("tabID"));
|
|
browser.tabs.update(id, { active: true });
|
|
|
|
oldElm.setAttribute("class", "block");
|
|
oldElm = target;
|
|
target.setAttribute("class", "block block-focused");
|
|
} else if (targetID == "goTop") {
|
|
window.scrollTo(0,0);
|
|
} else if (targetID == "goBottom") {
|
|
window.scrollTo(0,document.body.scrollHeight);
|
|
} else if (targetID == "goToTab") {
|
|
// Go to selected and 100px up
|
|
oldElm.scrollIntoView();
|
|
window.scrollBy(0, -100);
|
|
} else if (targetID == "newTab") {
|
|
createTab();
|
|
}
|
|
});
|
|
|
|
document.getElementById("searchBar").onkeypress = function () {
|
|
searchTabs();
|
|
}
|