This repository has been archived by the owner on Jun 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.js
90 lines (45 loc) · 1.55 KB
/
client.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
let domainName;
let authUrl;
let addBotLink;
const domainNameTitle = document.getElementsByClassName("domain-name-title");
const addBotCopy = document.getElementById("add-bot-link");
const oauthUrl = document.getElementById("oauth-url");
const oauthUrlGo = document.getElementById("oauth-url-go");
const noClientFound = document.getElementById("no-client-found");
noClientFound.style.display = "none";
const clientFound = document.getElementById("client-found");
clientFound.style.display = "none";
const readmeFileLink = document.getElementById("readme-file-link");
function getDomain() {
console.log("test");
return fetch("/botinfo/")
.then(res => res.json())
.then(resJson => {
if (resJson.error) {
console.log(resJson.error);
} else {
domainName = resJson.domain;
authUrl = resJson.url;
console.log("domain name " + domainName);
readmeFileLink.href = "https://glitch.com/edit/#!/" + domainName + "?path=readme.md:2:0";
[...domainNameTitle].forEach(function(element) {
element.innerHTML = domainName;
});
console.log(resJson);
if (authUrl) {
oauthUrl.value = authUrl;
oauthUrlGo.href = authUrl;
clientFound.style.display = "block";
} else {
noClientFound.style.display = "block";
}
}
return Promise.resolve();
});
}
getDomain();
function clipboard(element) {
let copyText = document.getElementById(element);
copyText.select();
document.execCommand("Copy");
}