New version plus look.
This commit is contained in:
53
src/scripts/generateView.js
Normal file
53
src/scripts/generateView.js
Normal file
@@ -0,0 +1,53 @@
|
||||
const tabQuery = browser.tabs.query({currentWindow: true});
|
||||
const searchBar = document.getElementById("searchBar");
|
||||
const errHandler = document.getElementById("errorZone");
|
||||
const listZone = document.getElementById("listZone");
|
||||
const notFoundText = document.createTextNode("Search not found...");
|
||||
|
||||
|
||||
function logTabs(tabs) {
|
||||
// tab.url requires the `tabs` permission
|
||||
for (let tab of tabs) {
|
||||
createContainer(tab);
|
||||
}
|
||||
// Set window position to bottom of list
|
||||
window.scrollTo(0,document.body.scrollHeight);
|
||||
}
|
||||
|
||||
function createContainer(tab) {
|
||||
var id = tab.id;
|
||||
var spanTag = document.createElement("SPAN");
|
||||
var iconText = document.createTextNode(tab.title);
|
||||
var centerTag = document.createElement("CENTER");
|
||||
var closeImgTag = document.createElement("IMG");
|
||||
var icoImgTag = document.createElement("IMG");
|
||||
|
||||
spanTag.title = tab.title;
|
||||
spanTag.id = "iconElm";
|
||||
spanTag.className = "block";
|
||||
spanTag.setAttribute("tabID",tab.id);
|
||||
|
||||
closeImgTag.id = "closeBttn";
|
||||
closeImgTag.className = "closeImg";
|
||||
closeImgTag.src = "../icons/x.png";
|
||||
|
||||
icoImgTag.id = "faveIcon";
|
||||
icoImgTag.className = "thumbImg";
|
||||
if (tab.favIconUrl == null || tab.favIconUrl == "") {
|
||||
icoImgTag.src = "../icons/tab.png";
|
||||
} else {
|
||||
icoImgTag.src = tab.favIconUrl;
|
||||
}
|
||||
|
||||
centerTag.appendChild(icoImgTag);
|
||||
spanTag.appendChild(closeImgTag);
|
||||
spanTag.appendChild(centerTag);
|
||||
spanTag.appendChild(iconText);
|
||||
listZone.appendChild(spanTag);
|
||||
}
|
||||
|
||||
|
||||
function onError(error) { console.log(`Error: ${error}`); }
|
||||
function getAllTabs() { tabQuery.then(logTabs, onError); }
|
||||
|
||||
getAllTabs();
|
||||
Reference in New Issue
Block a user