-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
50 lines (48 loc) · 1.73 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
var tabList = document.getElementById("tablist");
var tabArray;
var ele;
function tabNode(titleString){
var template = document.createElement("div");
var tabLabel = document.createElement("label");
var tabName = document.createTextNode(titleString);
var checkBox = document.createElement("input");
checkBox.type = "checkbox";
checkBox.name = "selectedTabs[]";
checkBox.value = "pair";
tabLabel.appendChild(checkBox);
tabLabel.appendChild(tabName);
template.appendChild(tabLabel);
template.style.boxShadow = '0 4px 8px 0 rgba(0,0,0,0.2)';
template.style.transition = '0.3s';
//template.style.borderRadius = '5px';
//template.appendChild(listElement);
return template;
//tabList.appendChild(template);
}
function selectAllChange(){
var checkboxes = document.getElementsByName("selectedTabs[]");
for(var i=0; i<checkboxes.length; i++){
checkboxes[i].checked = ele.checked;
console.log(checkboxes[i].checked);
}
}
function reloadTabs(){
var checkboxes = document.getElementsByName("selectedTabs[]");
for(var i=0; i<checkboxes.length; i++){
if(checkboxes[i].checked)
chrome.tabs.reload(tabArray[i].id);
}
}
document.addEventListener('DOMContentLoaded', function(){
document.querySelector('#reload').addEventListener('click',reloadTabs);
ele = document.querySelector('#selectAll');
ele.addEventListener('click',selectAllChange);
});
console.log("breakpoint");
chrome.tabs.getAllInWindow(null, function(tabsfetched){
tabArray = tabsfetched;
tabArray.forEach(function(element) {
tabList.appendChild(tabNode(element.title));
console.log(element.title);
}, this);
});