-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboard.js
55 lines (48 loc) · 1.44 KB
/
dashboard.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
51
52
53
54
55
ytcDashboard = (function(){
if (typeof ytcDashboard != 'undefined') {
return ytcDashboard;
}
console.log('Creating new dashboard');
var ytcOverlay = document.createElement('div');
var ytcDashboardItemList = document.createElement('ul');
var ytcCloseSelectedTabsBtn = document.createElement('a');
var state = 'closed';
var tab_ids = [];
ytcOverlay.id = 'youtubecontrolsOverlay';
ytcDashboardItemList.id = 'youtubecontrolsDashboardDeck';
ytcCloseSelectedTabsBtn.id = 'youtubecontrolsCloseSelectedTabsBtn';
ytcCloseSelectedTabsBtn.innerHTML = 'Close selected tabs';
ytcOverlay.appendChild(ytcDashboardItemList);
ytcOverlay.appendChild(ytcCloseSelectedTabsBtn);
return {
open: function() {
if (state != 'opened') {
document.body.appendChild(ytcOverlay);
state = 'opened';
}
},
close: function() {
if (state != 'closed') {
ytcOverlay.remove();
state = 'closed';
}
},
getState: function() { return state; },
getOverlay: function() { return ytcOverlay; },
getCardDeck: function() { return ytcDashboardItemList; },
getCloseSelectedTabsBtn: function() { return ytcCloseSelectedTabsBtn; },
getTabIds: function() { return tab_ids; },
addTabId: function(tabId) {
if (tab_ids.indexOf(tabId) == -1) {
tab_ids.push(tabId);
}
},
removeTabId: function(tabId) {
var tabIndex = tab_ids.indexOf(tabId);
if (tabIndex != -1) {
tab_ids.splice(tabIndex, 1);
}
}
};
})();
ytcDashboard.open();