2020-10-12 12:35:54 +00:00
|
|
|
import {q, ElemJS, ejs} from "./basic.js"
|
|
|
|
|
2020-10-12 13:26:10 +00:00
|
|
|
class ActiveGroupMarker extends ElemJS {
|
|
|
|
constructor() {
|
|
|
|
super(q("#c-group-marker"))
|
|
|
|
}
|
|
|
|
|
|
|
|
follow(group) {
|
|
|
|
this.style("transform", `translateY(${group.element.offsetTop}px)`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const activeGroupMarker = new ActiveGroupMarker()
|
|
|
|
|
2020-10-12 12:35:54 +00:00
|
|
|
class Group extends ElemJS {
|
|
|
|
constructor(groups, data) {
|
|
|
|
super("div")
|
|
|
|
|
|
|
|
this.groups = groups
|
|
|
|
this.data = data
|
2020-10-12 13:26:10 +00:00
|
|
|
this.active = false
|
2020-10-12 12:35:54 +00:00
|
|
|
|
|
|
|
this.on("click", this.onClick.bind(this))
|
|
|
|
|
|
|
|
this.class("c-group")
|
|
|
|
this.child(
|
|
|
|
(this.data.icon
|
|
|
|
? ejs("img").class("c-group__icon").attribute("src", this.data.icon)
|
|
|
|
: ejs("div").class("c-group__icon")
|
|
|
|
),
|
|
|
|
ejs("div").class("c-group__name").text(this.data.name)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-10-12 13:26:10 +00:00
|
|
|
setActive(active) {
|
|
|
|
this.active = active
|
|
|
|
this.element.classList[active ? "add" : "remove"]("c-group--active")
|
|
|
|
}
|
|
|
|
|
2020-10-12 12:35:54 +00:00
|
|
|
onClick() {
|
|
|
|
this.groups.setGroup(this)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Room extends ElemJS {
|
|
|
|
constructor(name) {
|
|
|
|
super("div")
|
|
|
|
|
|
|
|
this.name = name
|
|
|
|
|
|
|
|
this.class("c-room")
|
|
|
|
this.child(
|
|
|
|
ejs("div").class("c-room__icon"),
|
|
|
|
ejs("div").class("c-room__name").text(this.name)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class Rooms extends ElemJS {
|
|
|
|
constructor() {
|
|
|
|
super(q("#c-rooms"))
|
|
|
|
|
|
|
|
this.rooms = []
|
|
|
|
|
|
|
|
this.render()
|
|
|
|
}
|
|
|
|
|
|
|
|
setRooms(rooms) {
|
|
|
|
this.rooms = rooms
|
|
|
|
this.render()
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
this.clearChildren()
|
|
|
|
for (const room of this.rooms) {
|
|
|
|
this.child(new Room(room.name))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const rooms = new Rooms()
|
|
|
|
|
|
|
|
class Groups extends ElemJS {
|
|
|
|
constructor() {
|
|
|
|
super(q("#c-groups-list"))
|
2020-10-12 13:26:10 +00:00
|
|
|
this.groupData = [
|
2020-10-12 12:35:54 +00:00
|
|
|
{name: "Directs", icon: "/static/directs.svg", rooms: [
|
|
|
|
{name: "riley"},
|
|
|
|
{name: "BadAtNames"},
|
|
|
|
{name: "lynxano"},
|
|
|
|
{name: "quarky"},
|
|
|
|
{name: "lepton"},
|
|
|
|
{name: "ash"},
|
|
|
|
{name: "mewmew"},
|
|
|
|
{name: "Toniob"},
|
|
|
|
{name: "cockandball"}
|
|
|
|
]},
|
|
|
|
{name: "Channels", icon: "/static/channels.svg", rooms: [
|
|
|
|
{name: "Carbon brainstorming"},
|
|
|
|
{name: "Bibliogram"},
|
|
|
|
{name: "Monsters Inc Debate Hall"},
|
|
|
|
{name: "DRB clan"},
|
|
|
|
{name: "mettaton simp zone"}
|
|
|
|
]},
|
|
|
|
{name: "Fediverse Drama Museum", rooms: [
|
|
|
|
{name: "witches"},
|
|
|
|
{name: "snouts"},
|
|
|
|
{name: "monads"},
|
|
|
|
{name: "radical"},
|
|
|
|
{name: "blobcat"}
|
|
|
|
]},
|
|
|
|
{name: "Epicord", rooms: [
|
|
|
|
{name: "main"},
|
|
|
|
{name: "gaming"},
|
|
|
|
{name: "inhalers"},
|
|
|
|
{name: "minecraft"},
|
|
|
|
{name: "osu"},
|
|
|
|
{name: "covid"}
|
|
|
|
]},
|
|
|
|
{name: "Invidious", rooms: [
|
|
|
|
]}
|
|
|
|
]
|
2020-10-12 13:26:10 +00:00
|
|
|
this.groups = []
|
2020-10-12 12:35:54 +00:00
|
|
|
this.render()
|
|
|
|
this.setGroup(this.children[0])
|
|
|
|
}
|
|
|
|
|
|
|
|
setGroup(group) {
|
|
|
|
rooms.setRooms(group.data.rooms)
|
2020-10-12 13:26:10 +00:00
|
|
|
this.groups.forEach(g => g.setActive(g === group))
|
|
|
|
activeGroupMarker.follow(group)
|
2020-10-12 12:35:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2020-10-12 13:26:10 +00:00
|
|
|
this.groups = this.groupData.map(data => new Group(this, data))
|
2020-10-12 12:35:54 +00:00
|
|
|
for (const group of this.groups) {
|
2020-10-12 13:26:10 +00:00
|
|
|
this.child(group)
|
2020-10-12 12:35:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const groups = new Groups()
|