Fedi.CrowdedGames.Group/JS/expanded.js
CatAClock cda2765df1 Lots of changes
Images can now be shown. They are also shown on index.
The framework for boosting, favoriting, and replying have been layed out.
Bug fixes and a small rework to make things easier.
2025-05-10 19:36:57 -07:00

56 lines
2.4 KiB
JavaScript

import * as MastodonAPI from "./MastodonAPI.js";
import * as BlueskyAPI from "./BlueskyAPI.js";
import * as TumblrAPI from "./TumblrAPI.js";
import * as Variables from "./Variables.js";
// Buttons
let Favorite = document.getElementsByClassName("Favorite")[0];
let Boost = document.getElementsByClassName("Boost")[0];
let Reply = document.getElementsByClassName("Reply")[0];
// Variables
let website = document.location.href.split("website=")[1];
let post = JSON.parse(localStorage.getItem("post"));
document.getElementsByClassName("Origin")[0].innerHTML = website;
GetPost();
// Button stuff
// Functions and things.
async function GetPost() {
console.log(post);
if (website == "Mastodon") {
// Check for a reblog.
if (post.reblog != null) {
document.getElementsByClassName("PostText")[0].innerHTML = post.reblog.content;
document.getElementsByClassName("Handle")[0].innerHTML = post.reblog.account.username + " ( R: " + post.account.username + " )";
} else {
document.getElementsByClassName("PostText")[0].innerHTML = post.content;
document.getElementsByClassName("Handle")[0].innerHTML = post.account.username;
}
// Show the image if it exists.
if (post.media_attachments.length != 0) {
for (let i of post.media_attachments) {
document.getElementsByClassName("Images")[0].innerHTML = document.getElementsByClassName("Images")[0].innerHTML + "<img src=" + i.remote_url + " alt='" + i.description + "'/>";
}
}
} else if (website == "Bluesky") {
// Check for a reblog.
if (post.hasOwnProperty("reason") && post.reason.$type == "app.bsky.feed.defs#reasonRepost") {
document.getElementsByClassName("PostText")[0].innerHTML = post.post.record.text;
document.getElementsByClassName("Handle")[0].innerHTML = post.post.author.handle + " ( R: " + post.reason.by.handle + " )";
} else {
document.getElementsByClassName("PostText")[0].innerHTML = post.post.record.text;
document.getElementsByClassName("Handle")[0].innerHTML = post.post.author.handle;
}
// Show the image if it exists.
if (post.post.record.hasOwnProperty("embed") && post.post.record.embed.$type == "app.bsky.embed.images") {
for (let i of post.post.embed.images) {
document.getElementsByClassName("Images")[0].innerHTML = document.getElementsByClassName("Images")[0].innerHTML + "<img src=" + i.fullsize + " alt='" + i.alt + "'/>";
}
}
} else {
document.getElementsByClassName("PostText")[0].innerHTML = "Nothing to load.";
}
}