fixed replies multi-lined

This commit is contained in:
MathMan05 2024-06-28 14:47:07 -05:00
parent d01e3d57a2
commit f6bd7423d3
9 changed files with 97 additions and 39 deletions

View file

@ -178,14 +178,14 @@ class Embed {
const description = document.createElement("p");
description.textContent = this.json.description;
div.append(description);
{
if (this.json.thumbnail) {
const img = document.createElement("img");
img.classList.add("bigembedimg");
img.onclick = function () {
const full = new Fullscreen(["img", img.src, ["fit"]]);
full.show();
};
img.src = this.json.thumbnail.proxy_url;
img.src = this.json.thumbnail.proxy_url || this.json.thumbnail.url;
div.append(img);
}
colordiv.append(div);

View file

@ -221,7 +221,7 @@ class Localuser {
clearInterval(this.wsinterval);
console.log('WebSocket closed');
console.warn(event);
if (event.code !== 4000 && this === this) {
if (event.code !== 4000) {
this.unload();
document.getElementById("loading").classList.remove("doneloading");
document.getElementById("loading").classList.add("loading");

View file

@ -1,5 +1,5 @@
export { markdown };
function markdown(text, keep = false) {
function markdown(text, { keep = false, stdsize = false } = {}) {
let txt;
if ((typeof txt) === "string") {
txt = text.split("");
@ -55,17 +55,20 @@ function markdown(text, keep = false) {
}
if (keepys) {
appendcurrent();
if (!first) {
if (!first && !stdsize) {
span.appendChild(document.createElement("br"));
}
const build = [];
for (; txt[i] !== "\n" && txt[i] !== undefined; i++) {
build.push(txt[i]);
}
if (stdsize) {
element = document.createElement("span");
}
if (keep) {
element.append(keepys);
}
element.appendChild(markdown(build, keep));
element.appendChild(markdown(build, { keep: keep, stdsize: stdsize }));
span.append(element);
i--;
continue;
@ -76,7 +79,15 @@ function markdown(text, keep = false) {
}
if (txt[i] === "\n") {
appendcurrent();
span.append(document.createElement("br"));
if (!stdsize) {
span.append(document.createElement("br"));
}
else {
const s = document.createElement("span");
s.textContent = "...";
span.append(s);
return span;
}
continue;
}
if (txt[i] === "`") {
@ -121,7 +132,7 @@ function markdown(text, keep = false) {
if (keep) {
build += "`".repeat(find);
}
if (count !== 3) {
if (count !== 3 && !stdsize) {
const samp = document.createElement("samp");
samp.textContent = build;
span.appendChild(samp);
@ -173,7 +184,7 @@ function markdown(text, keep = false) {
if (keep) {
i.append(stars);
}
i.appendChild(markdown(build, keep));
i.appendChild(markdown(build, { keep: keep, stdsize: stdsize }));
if (keep) {
i.append(stars);
}
@ -184,7 +195,7 @@ function markdown(text, keep = false) {
if (keep) {
b.append(stars);
}
b.appendChild(markdown(build, keep));
b.appendChild(markdown(build, { keep: keep, stdsize: stdsize }));
if (keep) {
b.append(stars);
}
@ -196,7 +207,7 @@ function markdown(text, keep = false) {
if (keep) {
b.append(stars);
}
b.appendChild(markdown(build, keep));
b.appendChild(markdown(build, { keep: keep, stdsize: stdsize }));
if (keep) {
b.append(stars);
}
@ -239,7 +250,7 @@ function markdown(text, keep = false) {
if (keep) {
i.append(underscores);
}
i.appendChild(markdown(build, keep));
i.appendChild(markdown(build, { keep: keep, stdsize: stdsize }));
if (keep) {
i.append(underscores);
}
@ -250,7 +261,7 @@ function markdown(text, keep = false) {
if (keep) {
u.append(underscores);
}
u.appendChild(markdown(build, keep));
u.appendChild(markdown(build, { keep: keep, stdsize: stdsize }));
if (keep) {
u.append(underscores);
}
@ -262,7 +273,7 @@ function markdown(text, keep = false) {
if (keep) {
i.append(underscores);
}
i.appendChild(markdown(build, keep));
i.appendChild(markdown(build, { keep: keep, stdsize: stdsize }));
if (keep) {
i.append(underscores);
}
@ -299,7 +310,7 @@ function markdown(text, keep = false) {
if (keep) {
s.append(underscores);
}
s.appendChild(markdown(build, keep));
s.appendChild(markdown(build, { keep: keep, stdsize: stdsize }));
if (keep) {
s.append(underscores);
}
@ -334,7 +345,7 @@ function markdown(text, keep = false) {
if (keep) {
j.append(underscores);
}
j.appendChild(markdown(build, keep));
j.appendChild(markdown(build, { keep: keep, stdsize: stdsize }));
j.classList.add("spoiler");
j.onclick = markdown.unspoil;
if (keep) {

View file

@ -197,7 +197,7 @@ class Message {
replyline.classList.add("replyflex");
fetch(this.info.api.toString() + "/v9/channels/" + this.message_reference.channel_id + "/messages?limit=1&around=" + this.message_reference.message_id, { headers: this.headers }).then(responce => responce.json()).then(responce => {
const author = new User(responce[0].author, this.localuser);
reply.appendChild(markdown(responce[0].content));
reply.appendChild(markdown(responce[0].content, { stdsize: true }));
minipfp.src = author.getpfpsrc();
author.profileclick(minipfp);
username.textContent = author.username;