-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathglobalchat.js
59 lines (59 loc) · 1.92 KB
/
globalchat.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
let gc_is_open = false
let gc_initialized = false
function make_iframe() {
const GlCHatplace = document.getElementById("global_chat_window")
let current_profile = get_config().profile
let current_theme = get_theme(current_profile);
if (username_override == null){
var placeholderTextGlChat = orig_name;
}
else {
var placeholderTextGlChat = username_override;
}
const query_string=get_theme_as_query_string(current_theme, ["color_base00", "color_base01", "color_base02", "color_base03", "color_accent", "color_text"]);
const GlCHatplaceHTML = `
<iframe style="width:100%; height:100%; border:none "src = 'https://ldev.eu.org/smpp/gc/v1?placeholder=${placeholderTextGlChat}${query_string}'></iframe>
`;
GlCHatplace.innerHTML = GlCHatplaceHTML
}
function make_gcwin(is_hidden){
global_chat_window_element = document.createElement("div")
global_chat_window_element.id = "global_chat_window"
global_chat_window_element.classList.add("global_chat_window");
if(is_hidden){
global_chat_window_element.classList.add("gc-hidden");
}
document.body.insertBefore(global_chat_window_element, document.body.childNodes[-1]);
gc_is_open = false;
document.addEventListener("click", function (e){
if (!gc_is_open){
return
}
if (e.target.id == "global_chat_button"){
return
}
gc_close()
})
make_iframe()
}
function open_global_chat(){
let win = document.getElementById("global_chat_window");
if (win){
win.classList.remove("gc-hidden")
}else{
make_gcwin(false);
}
gc_initialized = true
gc_is_open = true
}
function gc_close() {
gc_is_open = false;
let global_chat_window = document.getElementById("global_chat_window");
global_chat_window.classList.add("gc-hidden");
}
function remove_gcwin(){
let win = document.getElementById("global_chat_window");
if (win){
win.remove()
}
}