This commit is contained in:
MathMan05 2024-07-20 12:11:48 -05:00
commit daa2bd6159
5 changed files with 46 additions and 11 deletions

View file

@ -1,5 +1,7 @@
import {Fullscreen} from "./fullscreen.js"; import {Fullscreen} from "./fullscreen.js";
import {Message} from "./message.js"; import {Message} from "./message.js";
import {markdown} from "./markdown.js";
class Embed{ class Embed{
type:string; type:string;
owner:Message; owner:Message;
@ -48,7 +50,7 @@ class Embed{
authorline.append(img); authorline.append(img);
} }
const a=document.createElement("a"); const a=document.createElement("a");
a.innerText=this.json.author.name a.textContent=this.json.author.name
if(this.json.author.url){ if(this.json.author.url){
a.href=this.json.author.url a.href=this.json.author.url
} }
@ -57,7 +59,7 @@ class Embed{
embed.append(authorline); embed.append(authorline);
} }
const title=document.createElement("a"); const title=document.createElement("a");
title.textContent=this.json.title; title.append(markdown(this.json.title));
if(this.json.url){ if(this.json.url){
title.href=this.json.url; title.href=this.json.url;
} }
@ -66,7 +68,7 @@ class Embed{
if(this.json.description){ if(this.json.description){
const p=document.createElement("p"); const p=document.createElement("p");
p.textContent=this.json.description; p.append(markdown(this.json.description));
embed.append(p); embed.append(p);
} }
@ -77,9 +79,8 @@ class Embed{
const b=document.createElement("b"); const b=document.createElement("b");
b.textContent=thing.name; b.textContent=thing.name;
div.append(b); div.append(b);
let p; const p=document.createElement("p")
p=document.createElement("p") p.append(markdown(thing.value));
p.textContent=thing.value;
p.classList.add("embedp"); p.classList.add("embedp");
div.append(p); div.append(p);

View file

@ -59,7 +59,7 @@ class Fullscreen{
const checkbox = document.createElement('input'); const checkbox = document.createElement('input');
div.appendChild(checkbox) div.appendChild(checkbox)
const label=document.createElement("span"); const label=document.createElement("span");
checkbox.value=array[2]; checkbox.checked=array[2];
label.textContent=array[1]; label.textContent=array[1];
div.appendChild(label); div.appendChild(label);
checkbox.addEventListener("change",array[3]); checkbox.addEventListener("change",array[3]);

View file

@ -360,6 +360,42 @@ function markdown(text : string|string[],{keep=false,stdsize=false} = {}){
} }
} }
if (txt[i] === "<" && (txt[i + 1] === ":" || (txt[i + 1] === "a" && txt[i + 2] === ":"))) {
let found=false;
const build = txt[i + 1] === "a" ? ["<","a",":"] : ["<",":"];
let j = i+build.length;
for (; txt[j] !== void 0; j++) {
build.push(txt[j]);
if (txt[j]===">") {
found=true;
break;
}
}
if (found) {
const parts=build.join("").match(/^<(a)?:\w+:(\d{10,30})>$/);
if (parts && parts[2]) {
appendcurrent();
i=j;
const isEmojiOnly = txt.join("").trim()===build.join("").trim();
const emojiElem=document.createElement("img");
emojiElem.classList.add("md-emoji");
emojiElem.width=isEmojiOnly ? 48 : 22;
emojiElem.height=isEmojiOnly ? 48 : 22;
emojiElem.crossOrigin="anonymous";
emojiElem.src=this.info.cdn.toString() + "/emojis/" + parts[2] + "." + (parts[1] ? "gif" : "png") + "?size=32";
emojiElem.alt="";
emojiElem.loading="lazy";
span.appendChild(emojiElem);
continue;
}
}
}
current.textContent+=txt[i]; current.textContent+=txt[i];
} }
appendcurrent(); appendcurrent();

View file

@ -83,7 +83,7 @@ class PermissionToggle{
div.append(this.generateCheckbox()); div.append(this.generateCheckbox());
const p=document.createElement("p"); const p=document.createElement("p");
p.innerText=this.rolejson.description; p.textContent=this.rolejson.description;
div.appendChild(p); div.appendChild(p);
return div; return div;
} }

View file

@ -215,8 +215,6 @@ img {
vertical-align: middle; vertical-align: middle;
max-width: 3in; max-width: 3in;
max-height: 3in; max-height: 3in;
width: auto;
height: auto;
} }
#page { #page {
@ -1352,4 +1350,4 @@ span {
width: 100%; width: 100%;
flex-direction: row; flex-direction: row;
max-height:100in; max-height:100in;
} }