Skip to content
This repository has been archived by the owner on Mar 22, 2024. It is now read-only.

Commit

Permalink
major aesthetics overhaul, now it looks decent
Browse files Browse the repository at this point in the history
  • Loading branch information
ERROR-404-NULL-NOT-FOUND authored Mar 10, 2022
1 parent 1c848ce commit 2d87f94
Showing 1 changed file with 134 additions and 85 deletions.
219 changes: 134 additions & 85 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,94 @@ <h4 id="descri">The revolt.chat client re-taped from the one that's held togethe
<br />
<div id="loginoe">
<input id="token" alt="aaa" type="password" autocomplete="on" placeholder="Token">
<br><input id="channel" placeholder="Channel ID">
<br><input id="server" placeholder="Server ID">
<br><input id="refresh" placeholder="Refresh time (default 7 sec)">
<br><input id="inputTheme" placeholder="Theme">
<br><button onclick="login();">ok</button>
<br /><br /><br />
</div>

<div id="logged" hidden="true">

<div id="info">
<div id="dms"></div>
<br>
<div id="servers"></div>
<br>
<div id="channels"></div>
</div>

<div id="channelInfo">
<h2 id="chanName"></h2>
<h3 id="chanDesc"></h3>
</div>
<button onclick="getmessage()">Get messages</button>
<button onclick="getchannel()">Get channels</button>
<button onclick="embedmessage()">Send embed</button>
<br>
<input type="text" autocomplete="off" placeholder="Title" id="title" hidden="true" />
<input type="text" autocomplete="off" placeholder="Description" id="desc" hidden="true" />
<input type="text" autocomplete="off" placeholder="Color" id="color" hidden="true" />
<h5 id="error" hidden="true"></h5>
<h5 id="replymsg" hidden="true"></h5>
<input type="file" id="upload" accept=".jpg, .jpeg, .png"></input>
<div id="messagebar">
<button onclick="contentToJson()">JSON</button>
<input type="text" style="width: 90%;" autocomplete="off" placeholder="Speak in channel" id="a" />
<button onclick="sendmessage()">Send</button>

<div id="central">

<button onclick="getmessage()">Get messages</button>
<button onclick="getchannel()">Get channels</button>
<button onclick="embedmessage()">Send embed</button>

<br>

<input type="text" autocomplete="off" placeholder="Title" id="title" hidden="true" />
<input type="text" autocomplete="off" placeholder="Description" id="desc" hidden="true" />
<input type="text" autocomplete="off" placeholder="Color" id="color" hidden="true" />

<h5 id="error" hidden="true"></h5>
<h5 id="replymsg" hidden="true"></h5>
<input type="file" id="upload" accept=".jpg, .jpeg, .png"></input>

<div id="messagebar">
<button onclick="contentToJson()">JSON</button>
<input type="text" style="width: 90%;" autocomplete="off" placeholder="Speak in channel" id="a" />
<button onclick="sendmessage()">Send</button>
</div>
<div id="messages" hidden="true"></div>
</div>
<br>
</div>
<h2 id="theme"></h2>
<br />
<div id="messages" hidden="true">

<h2 id="theme"></h2>
</div>

<style>
#info {
display: block;
}

[id^=server],
[id^=chan],
[id^=dm] {
width: 15em
}

[id^=a],
#reply {
display: inline-block;
}

#central {
display: block;
flex-direction: column;
padding-left: 8%;
}

#channelInfo {
padding-left: 2%;
width: 10%;
word-break: break-all;
}

#logged {

flex-direction: row;
align-items: flex-start;
}

#messages {
display: inline;
vertical-align: top;
padding-left: 4%;
}

#replymsg {
padding-bottom: 0px;
}
Expand Down Expand Up @@ -82,17 +130,17 @@ <h2 id="theme"></h2>
}

#channels {
display: block;
display: inline-block;

}

#message {
text-align: left
button {
background-color: #000000;
color: #FFFFFF
}

h5 {
border-style: solid;
border-width: 1px;
#message {
text-align: left
}
</style>

Expand All @@ -104,26 +152,27 @@ <h2 id="theme"></h2>
let thechannel = "";
let reply = "";
let image = "";
let theuser="";
let theuser = "";

async function login() {
let theme;
thetoken = document.getElementById("token").value;
await fetch("https://api.revolt.chat/users/@me", {
"credentials": "omit",
"headers": {
"Accept": "*/*",
"x-session-token": thetoken
},
"method": "GET"
})
"credentials": "omit",
"headers": {
"Accept": "*/*",
"x-session-token": thetoken
},
"method": "GET"
})
.then(response => response.json())
.then(data => theuser=data)
.catch(err=>showError(err))
thechannel = document.getElementById("channel").value;
theserver = document.getElementById("server").value;
.then(data => theuser = data)
.catch(err => showError(err))
document.getElementById("loginoe").hidden = true;
document.getElementById("logged").hidden = false;
document.getElementById("logged").style = "display:flex;"
document.getElementById("name").hidden = true;
document.getElementById("descri").hidden = true;
//if (!document.getElementById("inputTheme").value == '') { document.cookie = `theme=${document.getElementById("inputTheme").value};` }
//if (document.cookie) { let theme = document.cookie.split('; ').find(row => row.startsWith('theme=')).split('=')[1]; }
theme = document.getElementById("inputTheme").value
Expand All @@ -136,11 +185,11 @@ <h2 id="theme"></h2>
}


function showError(error){
document.getElementById("error").innerText=JSON.stringify(error)
document.getElementById("error").hidden=false
function showError(error) {
document.getElementById("error").innerText = JSON.stringify(error)
document.getElementById("error").hidden = false
}

async function uploadToAutumn() {
const files = document.getElementById("upload").files
const formData = new FormData()
Expand All @@ -158,36 +207,36 @@ <h2 id="theme"></h2>
showError(error)
})
}


function embedmessage() {
document.getElementById("title").hidden = false;
document.getElementById("desc").hidden = false;
document.getElementById("color").hidden = false;
embedSend = true;
}


document.getElementById("a").onkeypress = function (event) {
if (event.keyCode == 13 || event.which == 13) {
sendmessage();
}
};


function contentToJson() {
if (!sendRawJson) {
sendRawJson = true;
}
else { sendRawJson = false; }
}


function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}


async function sendmessage() {
if (!(embedSend || sendRawJson || reply != "" || document.getElementById("upload").files[0])) {
fetch("https://api.revolt.chat/channels/" + thechannel + "/messages", {
Expand Down Expand Up @@ -292,8 +341,8 @@ <h2 id="theme"></h2>
}
getmessage();
}
async function getdms(){

async function getdms() {
await fetch(`https://api.revolt.chat/users/dms`, {
"credentials": "omit",
"headers": {
Expand All @@ -302,18 +351,18 @@ <h2 id="theme"></h2>
},
"method": "GET",
})
.then(response => response.json())
.then(response => response.json())
.then(data => dm = (data))
.catch(error => { showError(error) })

for (let i = 0; i < dm.length; i++) {
if(dm[i].channel_type=="Group"){
if (dm[i].channel_type == "Group") {
document.getElementById('dms').innerHTML = `<button onclick="thechannel = '${dm[i]._id}';getmessage()" id="dm${i}">${dm[i]["name"]}</button>` + document.getElementById('dms').innerHTML
}else{
} else {
document.getElementById('dms').innerHTML = `<button onclick="thechannel = '${dm[i]._id}';getmessage()" id="dm${i}">${dm[i].recipients[0]}</button>` + document.getElementById('dms').innerHTML
if(dm[i].recipients[0]==theuser._id){
id=dm[i].recipients[1]
}else{
if (dm[i].recipients[0] == theuser._id) {
id = dm[i].recipients[1]
} else {
id = dm[i].recipients[0]
}
fetch("https://api.revolt.chat/users/" + id, {
Expand All @@ -328,24 +377,24 @@ <h2 id="theme"></h2>
}
}
}

async function replacea() {
for (let i = 1; i < mess.length; i++) {
id = document.getElementById("a" + i).innerHTML;
fetch("https://api.revolt.chat/users/" + id, {
"credentials": "omit",
"headers": {
"Accept": "*/*",
"x-session-token": thetoken
},
"method": "GET",
}).then(response => response.json())
.then(data => {
document.getElementById("a" + i).innerText = (data.username)
})
fetch("https://api.revolt.chat/users/" + id, {
"credentials": "omit",
"headers": {
"Accept": "*/*",
"x-session-token": thetoken
},
"method": "GET",
}).then(response => response.json())
.then(data => {
document.getElementById("a" + i).innerText = (data.username)
})
}
}
async function getserver(){
async function getserver() {
await fetch(`https://api.revolt.chat/users/${theuser._id}/mutual`, {
"credentials": "omit",
"headers": {
Expand All @@ -355,7 +404,7 @@ <h2 id="theme"></h2>
"method": "GET",
}).then(response => response.json())
.then(data => server = (data.servers))
.catch(error => {showError(error)})
.catch(error => { showError(error) })
for (let i = 1; i < server.length; i++) {
document.getElementById(`servers`).innerHTML += `<button onclick="theserver = '${server[i - 1]}';getchannel()" id="server${i}">${server[i - 1]}</button>`;
}
Expand All @@ -370,13 +419,13 @@ <h2 id="theme"></h2>
"method": "GET",
}).then(response => response.json())
.then(data => document.getElementById(`server${i}`).innerText = data.name)
.catch(error => {showError(error)})
.catch(error => { showError(error) })
}
}


async function getchannel() {
document.getElementById(`channels`).innerHTML=""
document.getElementById(`channels`).innerHTML = ""
await fetch(`https://api.revolt.chat/servers/${theserver}/`, {
"credentials": "omit",
"headers": {
Expand All @@ -401,8 +450,8 @@ <h2 id="theme"></h2>
.then(data => { if (data.channel_type === "VoiceChannel") { document.getElementById(`chann${i}`).remove(); return; } document.getElementById(`chann${i}`).innerText = data.name });
}
}


async function getmessage() {
fetch(`https://api.revolt.chat/channels/${thechannel}`, {
"credentials": "omit",
Expand All @@ -413,10 +462,10 @@ <h2 id="theme"></h2>
"method": "GET",
}).then(response => response.json())
.then(data => {
document.getElementById("chanName").innerText = data.name;
if(data.description){document.getElementById("chanDesc").innerText = data.description};
if (data.channel_type == "DirectMessage") { document.getElementById("chanName").innerText = data.recipients[0] } else { document.getElementById("chanName").innerText = data.name; }
if (data.description) { document.getElementById("chanDesc").innerText = data.description };
})

document.getElementById("messages").hidden = false
await fetch(`https://api.revolt.chat/channels/${thechannel}/messages?include_users=true`, {
"credentials": "omit",
Expand All @@ -429,8 +478,8 @@ <h2 id="theme"></h2>
.then(data => mess = (data.messages))
document.getElementById("messages").innerHTML = ""
for (let i = 1; i <= mess.length; i++) {
document.getElementById("messages").innerHTML += `<h6 id="a${i}reply" hidden=true>reply</h6><div id="message"><h4 id="a${i}">author </h4>
<h5 id = "${i}msg" > message</h5 ><button id="reply" onclick="reply='${mess[i - 1]._id}';document.getElementById('replymsg').innerText='> ${mess[i - 1].content}';document.getElementById('replymsg').hidden=false">reply</button></div>`
document.getElementById("messages").innerHTML += `<div id="${i}cont"><h6 id="${i}reply" hidden=true>reply</h6><div id="message"><h4 id="a${i}">author </h4><button style="display: inline" id="reply" onclick="reply='${mess[i - 1]._id}';document.getElementById('replymsg').innerText='> ${mess[i - 1].content}';document.getElementById('replymsg').hidden=false">reply</button>
<h5 id = "${i}msg" > message</h5 ></div></div>`
}
try {
for (let i = 1; i <= mess.length; i++) {
Expand Down

0 comments on commit 2d87f94

Please sign in to comment.