-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
40 lines (33 loc) · 1.03 KB
/
popup.js
File metadata and controls
40 lines (33 loc) · 1.03 KB
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
function openTab(id) {
if (id == "archive") {
app.archiveUI.refresh()
} else {
app.tabs.refresh()
}
document.querySelectorAll("nav > button").forEach((btn) => {
const section = document.getElementById(btn.dataset.targetId)
if (btn.dataset.targetId == id) {
btn.classList.add("active")
section.style.display = "block"
} else {
btn.classList.remove("active")
section.style.display = "none"
}
})
}
document.addEventListener("DOMContentLoaded", () => {
app.nodes.tabsList = document.querySelector("#tabs > .tabs-list")
app.nodes.archive = document.querySelector("#archive > .tabs-list")
let search = document.querySelector("#tabs > .search-bar > input")
search.addEventListener("keyup", app.search)
document.querySelectorAll("nav > button").forEach((btn) => {
btn.onclick = () => {
if (btn.classList.contains("active")) {
return
}
localStorage.setItem("TabsTreeActiveTab", btn.dataset.targetId)
openTab(btn.dataset.targetId)
}
})
openTab(localStorage.getItem("TabsTreeActiveTab") || "tabs")
})