Files
selmer-bot-website/myGuilds.html
T

161 lines
6.3 KiB
HTML
Raw Normal View History

2022-07-24 08:49:29 +03:00
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Selmer Bot Web Dashboard</title>
<link rel="shortcut icon" href="https://github.com/ION606/selmer-bot-website/blob/main/assets/favicon.ico?raw=true" type="image/x-icon">
2022-07-24 08:49:29 +03:00
<style>
html { width:100%; height:100%; margin:0; padding:0; }
body {
background-color: rgb(41, 42, 48);
width:100%; height:100%; margin:0; padding:0;
}
.server {
padding: 30px;
width: 100px;
height: 100px;
align-content: top;
object-fit:scale-down;
}
.serverImgIn {
width: 100px;
height: 100px;
object-fit:scale-down;
border-radius:50%;
cursor: pointer;
}
.serverImgOut {
width: 100px;
height: 100px;
object-fit:scale-down;
border-radius:50%;
cursor: pointer;
filter: grayscale(100%);
}
.serverRow {
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
</style>
<script>
function createServerPage() {
var tempPage = "<html>" + "HELLO WORLD, I'M A BLANK PAGE!" + "</html>";
var w = window.open('TEMP');
w.document.write(tempPage);
}
</script>
<script>
2022-08-12 20:01:29 -07:00
function getSessionData() {
return new Promise((resolve, reject) => {
var xhrsess = new XMLHttpRequest();
xhrsess.open('post', 'http://www.selmerbot.com/getSessionInfo/', true);
xhrsess.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
xhrsess.setRequestHeader('session', window.localStorage.getItem('sessionId'));
//Reminder that this will return a map of strings (you'll have to use JSON.parse() again)
xhrsess.onloadend = (e) => {
resolve(JSON.parse(xhrsess.response));
2022-08-12 10:29:57 -07:00
}
2022-08-12 20:01:29 -07:00
xhrsess.send();
});
}
window.onload = async () => {
//#region GUILDS
const sessionDataPromise = getSessionData();
sessionDataPromise.then((sessionData) => {
const guilds = JSON.parse(sessionData.guilds);
if (!guilds) {
alert("Please log in to continue");
if (window.location.href.indexOf('localhost') != -1) {
window.location = 'https://discord.com/api/oauth2/authorize?client_id=926551095352901632&redirect_uri=http%3A%2F%2Flocalhost%3A53134%2F&response_type=token&scope=identify%20guilds';
} else {
window.location = 'https://discord.com/api/oauth2/authorize?client_id=944046902415093760&redirect_uri=http%3A%2F%2Fwww.selmerbot.com%2F&response_type=token&scope=identify%20guilds';
}
2022-07-24 08:49:29 +03:00
}
2022-08-12 20:01:29 -07:00
var wrapper = document.getElementById('wrapper');
var row = document.createElement("servers_row");
row.innerHTML = ""; // clear images
row.classList.add('serverRow');
for (let i = 0; i < guilds.length; i++) {
//New row every 10 servers
if (i % 10 == 0) {
wrapper.appendChild(row);
row.innerHTML = "";
row.classList.add('serverRow');
}
2022-07-24 08:49:29 +03:00
2022-08-12 20:01:29 -07:00
var div = document.createElement("div");
var imagem = document.createElement("img");
var name = document.createElement("p");
name.innerText = guilds[i].name;
name.style = "color: white";
2022-07-24 08:49:29 +03:00
2022-08-12 20:01:29 -07:00
if (guilds[i].icon) {
imagem.src = `https://cdn.discordapp.com/icons/${guilds[i].id}/${guilds[i].icon}.png`;
} else {
imagem.src = 'https://github.com/ION606/selmer-bot-website/blob/main/assets/circleOutline.png?raw=true';
2022-07-24 08:49:29 +03:00
}
2022-08-12 20:01:29 -07:00
if (guilds[i].inServer) {
imagem.className = 'serverImgIn';
imagem.onclick = function() {
var xhr = new XMLHttpRequest();
2022-08-16 14:15:12 -07:00
xhr.open('post', 'http://www.selmerbot.com/setCurrentServer/', true);
2022-08-12 20:01:29 -07:00
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
xhr.setRequestHeader('serverNumber', guilds[i].id);
2022-08-16 14:15:12 -07:00
xhr.setRequestHeader('sessionid', window.localStorage.getItem("sessionId"));
xhr.onloadend = (e) => {
// window.sessionStorage.setItem('serverInfo', (xhr.response));
window.location = 'http://www.selmerbot.com/dashboard.html';
}
2022-08-12 20:01:29 -07:00
xhr.send();
}
} else {
// imagem.classList.add('serverImgOut');
imagem.className = 'serverImgOut';
imagem.onclick = function() {
window.open('https://discord.com/oauth2/authorize?client_id=926551095352901632&scope=applications.commands+bot&permissions=549755289087');
}//OPEN A NEW WINDOW WITH SERVER INVITE
}
2022-07-24 08:49:29 +03:00
2022-08-12 20:01:29 -07:00
div.appendChild(imagem);
div.appendChild(name);
2022-07-24 08:49:29 +03:00
2022-08-12 20:01:29 -07:00
div.classList.add('server');
2022-07-24 08:49:29 +03:00
2022-08-12 20:01:29 -07:00
row.appendChild(div);
}
2022-07-24 08:49:29 +03:00
2022-08-12 20:01:29 -07:00
wrapper.appendChild(row);
wrapper.appendChild(document.createElement('div'));
});
//#endregion
2022-07-24 08:49:29 +03:00
}
</script>
</head>
<body>
<div id="wrapper">
<!-- PLACEHOLDER TEXT HERE -->
<!-- <img id="1" src="https://cdn.discordapp.com/icons/930148608400035860/76aab371cf5393ee9ae56c7493c656d4.png" alt="" title="" style="cursor: pointer; border-radius: 50%; border: 3px solid rgb(106, 255, 170);" width="128" height="128"> -->
</div>
</body>