-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
28 lines (25 loc) · 861 Bytes
/
index.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
const d = document,
$badge = d.getElementById("badge"),
$btn = d.getElementById("readAll")
const updateBadge = () => {
const unread = d.querySelectorAll("[data-unread]").length
$badge.textContent = unread
}
$btn.addEventListener("click", async () => {
elements = d.querySelectorAll("[data-unread]")
elements = Array.from(elements).reverse()
for ($el of elements) {
await new Promise(resolve => {
setTimeout(() => {
$el.removeAttribute("data-unread")
$el.classList.remove("bg-[#f7fafd]")
$el.classList.add("bg-transparent")
$el.querySelector("[data-circle]").classList.remove("bg-[#f65351]")
$el.querySelector("[data-circle]").classList.add("bg-transparent")
$el.querySelector("[data-circle]").removeAttribute("data-circle")
resolve()
}, 300)
})
}
updateBadge()
})