-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchannel.js
67 lines (59 loc) · 2.33 KB
/
channel.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
56
57
58
59
60
61
62
63
64
65
66
67
class Channel
{
static active;
static element = {};
static addNew(name)
{
var chanButton = document.createElement('div');
chanButton.id = name + "-chan-block";
chanButton.classList.add('btn', 'btn-secondary', 'window-window');
chanButton.style.width = "100%";
chanButton.style.height = "50px";
chanButton.style.marginRight = "3px";
chanButton.innerHTML = `
<div class="">
<div scope="row" class="text-start">
<div id="`+name+`-channel-name" scope="col" class="pb-0 mt-0" style="padding:0px">#`+name+`</div>
<div id="`+name+`-channel-lastsaid" scope="col" class="text-start"></div>
</div>
<div id="`+name+`-channel-users"" class="text-start"></div>
<div id="`+name+`-channel-notif"" class="text-start"></div>
</div>`;
chanButton.addEventListener('click', (e)=>{
this.switchActive(name+"-channel-output");
});
document.getElementById("treebar").appendChild(chanButton);
var output = document.createElement('div');
output.id = name+"-channel-output";
output.classList.add('output', 'bg-nihao');
const chatwindow = document.getElementById('chatwindow');
chatwindow.appendChild(output);
this.switchActive(output.id);
}
static delete(id)
{
var chanButton = document.getElementById(id);
chanButton.remove();
}
static newTopic(id, topic)
{
var element = document.getElementById(id + "-channel-topic") ?? null;
if (!element)
return console.log("Couldn't find the channel we have a topic for: #"+id);
element.innerHTML = Escape(topic);
}
static switchActive(dest)
{
const outputs = document.querySelectorAll('.output');
outputs.forEach((o) => {
if (o.id == dest)
{
this.active = '#'+dest.split('-')[0];
o.removeAttribute('hidden');
me.active_window = '#'+dest.split('-')[0];
}
else
o.setAttribute('hidden', '');
});
}
}