diff --git a/JS/expanded.js b/JS/expanded.js
index 63cee9d..57a5dd1 100644
--- a/JS/expanded.js
+++ b/JS/expanded.js
@@ -83,61 +83,32 @@ async function SetThreadPost(element, i) {
// Functions and things.
async function GetPost() {
if (website == "Mastodon") {
- // Check for a reblog.
- if (post.reblog != null) {
- document.getElementsByClassName("PostText Regular")[0].innerHTML = post.reblog.content;
- document.getElementsByClassName("Handle Regular")[0].innerHTML = post.reblog.account.username + " ( R: " + post.account.username + " )";
- if (post.reblog.media_attachments.length != 0) {
- for (let i of post.reblog.media_attachments) {
- ApplyMedia(i, document.getElementsByClassName("Images Regular")[0]);
- }
- }
- } else {
- document.getElementsByClassName("PostText Regular")[0].innerHTML = post.content;
- document.getElementsByClassName("Handle Regular")[0].innerHTML = post.account.username;
- // Show the image if it exists.
- if (post.media_attachments.length != 0) {
- for (let i of post.media_attachments) {
- ApplyMedia(i, document.getElementsByClassName("Images Regular")[0]);
- }
- }
- }
// Set the texts. It's opposite because "setting" causes it to switch.
post = await MastodonAPI.GetStatus(post.id);
FavoriteFlipper = !(post.favourited);
BoostFlipper = !(post.reblogged);
SetFavorite();
SetBoost();
+ // Check for a reblog.
+ if (post.reblog != null) {
+ document.getElementsByClassName("Handle Regular")[0].innerHTML = post.reblog.account.username + " ( R: " + post.account.username + " )";
+ post = post.reblog;
+ } else {
+ document.getElementsByClassName("Handle Regular")[0].innerHTML = post.account.username;
+ }
+ document.getElementsByClassName("PostText Regular")[0].innerHTML = post.content;
+ // Show the image if it exists.
+ if (post.media_attachments.length != 0) {
+ for (let i of post.media_attachments) {
+ ApplyMedia(i, document.getElementsByClassName("Images Regular")[0]);
+ }
+ }
// Now time to see if there are any parents
if (post.in_reply_to_id != null) {
- Parentpost = await MastodonAPI.GetStatus(post.in_reply_to_id);
- document.getElementsByClassName("Origin Parent")[0].innerHTML = website;
- document.getElementsByClassName("Handle Parent")[0].innerHTML = Parentpost.account.username;
- if (Parentpost.spoiler_text != "") {
- document.getElementsByClassName("PostText Parent")[0].innerHTML = "WARNING: " + Parentpost.spoiler_text;
- } else {
- document.getElementsByClassName("PostText Parent")[0].innerHTML = Parentpost.content;
- }
- if (Parentpost.media_attachments.length != 0) {
- for (let i of Parentpost.media_attachments) {
- ApplyMedia(i, document.getElementsByClassName("Images Parent")[0]);
- }
- }
+ let ParentPost = await MastodonReplylFunction("Parent", post.in_reply_to_id);
// Now time to see if there are any grandparents
- if (Parentpost.in_reply_to_id != null) {
- GrandParentpost = await MastodonAPI.GetStatus(Parentpost.in_reply_to_id);
- document.getElementsByClassName("Origin GrandParent")[0].innerHTML = website;
- document.getElementsByClassName("Handle GrandParent")[0].innerHTML = GrandParentpost.account.username;
- if (GrandParentpost.spoiler_text != "") {
- document.getElementsByClassName("PostText GrandParent")[0].innerHTML = "WARNING: " + GrandParentpost.spoiler_text;
- } else {
- document.getElementsByClassName("PostText GrandParent")[0].innerHTML = GrandParentpost.content;
- }
- if (GrandParentpost.media_attachments.length != 0) {
- for (let i of GrandParentpost.media_attachments) {
- ApplyMedia(i, document.getElementsByClassName("Images GrandParent")[0]);
- }
- }
+ if (ParentPost == undefined && ParentPost.in_reply_to_id != null) {
+ MastodonReplylFunction("GrandParent", ParentPost.in_reply_to_id);
}
}
} else if (website == "Bluesky") {
@@ -214,6 +185,24 @@ async function GetPost() {
}
}
+// Because of repeat code, we can put it into it's own function. Hell, more of a thread can be added later.
+async function MastodonReplylFunction(ClassName, post) {
+ let OtherPost = await MastodonAPI.GetStatus(post);
+ document.getElementsByClassName("Origin " + ClassName)[0].innerHTML = website;
+ document.getElementsByClassName("Handle " + ClassName)[0].innerHTML = OtherPost.account.username;
+ if (OtherPost.spoiler_text != "") {
+ document.getElementsByClassName("PostText " + ClassName)[0].innerHTML = "WARNING: " + OtherPost.spoiler_text;
+ } else {
+ document.getElementsByClassName("PostText " + ClassName)[0].innerHTML = OtherPost.content;
+ }
+ if (OtherPost.media_attachments.length != 0) {
+ for (let i of OtherPost.media_attachments) {
+ ApplyMedia(i, document.getElementsByClassName("Images " + ClassName)[0]);
+ }
+ }
+ return OtherPost;
+}
+
// Applyers. Essentially applies a thing to an operation.
// Finds any associated media and applies it to the post.
async function ApplyMedia(Media, Element, Author = undefined) {
diff --git a/JS/index.js b/JS/index.js
index 11ef9c0..d1a719d 100644
--- a/JS/index.js
+++ b/JS/index.js
@@ -221,22 +221,19 @@ async function PosterContainerUpdate(Direction) {
}
MastodonLoadedFeed = MastodonLoadedFeed.concat(TempFeed);
}
- // Check for images. Reblog roundabout fix included.
+ // put the reblog into the regular post; Make changes as necessary.
if (MastodonLoadedFeed[CurrentThing + counter].reblog != null) {
- if (MastodonLoadedFeed[CurrentThing + counter].reblog.media_attachments.length != 0) {
- if (MastodonLoadedFeed[CurrentThing + counter].reblog.media_attachments[0].type == "image") {
- i.getElementsByClassName("PostContent")[0].innerHTML += "This post has an image!
";
- } else if (MastodonLoadedFeed[CurrentThing + counter].reblog.media_attachments[0].type == "video" || MastodonLoadedFeed[CurrentThing + counter].reblog.media_attachments[0].type == "gifv") {
- i.getElementsByClassName("PostContent")[0].innerHTML += "This post has a video!
";
- }
- }
+ i.getElementsByClassName("Username")[0].innerHTML = MastodonLoadedFeed[CurrentThing + counter].reblog.account.username + " ( R: " + MastodonLoadedFeed[CurrentThing + counter].account.username + " )";
+ MastodonLoadedFeed[CurrentThing + counter] = MastodonLoadedFeed[CurrentThing + counter].reblog;
} else {
- if (MastodonLoadedFeed[CurrentThing + counter].media_attachments.length != 0) {
- if (MastodonLoadedFeed[CurrentThing + counter].media_attachments[0].type == "image") {
- i.getElementsByClassName("PostContent")[0].innerHTML += "This post has an image!
";
- } else if (MastodonLoadedFeed[CurrentThing + counter].media_attachments[0].type == "video" || MastodonLoadedFeed[CurrentThing + counter].media_attachments[0].type == "gifv") {
- i.getElementsByClassName("PostContent")[0].innerHTML += "This post has a video!
";
- }
+ i.getElementsByClassName("Username")[0].innerHTML = MastodonLoadedFeed[CurrentThing + counter].account.username
+ }
+ // Check for images.
+ if (MastodonLoadedFeed[CurrentThing + counter].media_attachments.length != 0) {
+ if (MastodonLoadedFeed[CurrentThing + counter].media_attachments[0].type == "image") {
+ i.getElementsByClassName("PostContent")[0].innerHTML += "This post has an image!
";
+ } else if (MastodonLoadedFeed[CurrentThing + counter].media_attachments[0].type == "video" || MastodonLoadedFeed[CurrentThing + counter].media_attachments[0].type == "gifv") {
+ i.getElementsByClassName("PostContent")[0].innerHTML += "This post has a video!
";
}
}
// Check for a thread.
@@ -249,14 +246,7 @@ async function PosterContainerUpdate(Direction) {
i.getElementsByClassName("Username")[0].innerHTML = MastodonLoadedFeed[CurrentThing + counter].account.username;
break;
}
- // Check for a reblog.
- if (MastodonLoadedFeed[CurrentThing + counter].reblog != null) {
- i.getElementsByClassName("PostContent")[0].innerHTML += MastodonLoadedFeed[CurrentThing + counter].reblog.content;
- i.getElementsByClassName("Username")[0].innerHTML = MastodonLoadedFeed[CurrentThing + counter].reblog.account.username + " ( R: " + MastodonLoadedFeed[CurrentThing + counter].account.username + " )";
- } else {
- i.getElementsByClassName("PostContent")[0].innerHTML += MastodonLoadedFeed[CurrentThing + counter].content;
- i.getElementsByClassName("Username")[0].innerHTML = MastodonLoadedFeed[CurrentThing + counter].account.username;
- }
+ i.getElementsByClassName("PostContent")[0].innerHTML += MastodonLoadedFeed[CurrentThing + counter].content;
break;
// Bsky
case 1:
@@ -326,7 +316,7 @@ function CheckForDups(Timeline, DupeArray, counter) {
for (let j of DupeArray) {
if (j == Timeline[counter].post.uri) {
Timeline.splice(counter, 1);
- console.log("Culled a duplicate post.")
+ console.log("Culled a duplicate post.");
Timeline = CheckForDups(Timeline, DupeArray, counter);
}
}