diff --git a/CSS/index.css b/CSS/index.css index 625db26..488ba1f 100644 --- a/CSS/index.css +++ b/CSS/index.css @@ -247,6 +247,11 @@ html { .Time { font-size: 4ch; + text-decoration: none; +} + +.Time:hover { + text-decoration: underline; } .MainFooter, .MainBlackedFooter { @@ -260,6 +265,8 @@ html { border-width: 2px; border-color: #00FFFF; + padding: auto; + height: 20vh; } diff --git a/HTML/account.html b/HTML/account.html index ba539fc..8ecbc11 100644 --- a/HTML/account.html +++ b/HTML/account.html @@ -17,12 +17,16 @@

- +

Block!

+

+ +

+

Not implemented. Posts should populate here.

diff --git a/JS/MastodonAPI.js b/JS/MastodonAPI.js index ae3b1c2..3672d30 100644 --- a/JS/MastodonAPI.js +++ b/JS/MastodonAPI.js @@ -93,6 +93,42 @@ export async function GetStatus(ID) { .then((response) => response.json()); } +// Get your own account by verifying your credentials. +export async function GetOwnAccount() { + if (Token == null || TokenType == null) { + return ""; + } + return await fetch(localStorage.getItem(Variables.MastodonWebsite) + "/api/v1/accounts/verify_credentials", {method: "GET", headers: {"Authorization": TokenType + " " + Token}}) + .then((response) => response.json()); +} + +// Get your own account blocks. +export async function GetOwnAccountBlocks() { + if (Token == null || TokenType == null) { + return ""; + } + return await fetch(localStorage.getItem(Variables.MastodonWebsite) + "/api/v1/blocks/", {method: "GET", headers: {"Authorization": TokenType + " " + Token}}) + .then((response) => response.json()); +} + +// Get another account's statuses. +export async function GetAccountStatuses(ID) { + if (Token == null || TokenType == null) { + return ""; + } + return await fetch(localStorage.getItem(Variables.MastodonWebsite) + "/api/v1/accounts/" + ID + "/statuses", {method: "GET", headers: {"Authorization": TokenType + " " + Token}}) + .then((response) => response.json()); +} + +// Get another account. +export async function GetAccount(ID) { + if (Token == null || TokenType == null) { + return ""; + } + return await fetch(localStorage.getItem(Variables.MastodonWebsite) + "/api/v1/accounts/" + ID, {method: "GET", headers: {"Authorization": TokenType + " " + Token}}) + .then((response) => response.json()); +} + // Creators // Make a status export async function CreateStatus(Text, Visibility = "public", SpoilerText = undefined, ReplyID = undefined) { diff --git a/JS/account.js b/JS/account.js index a0da97c..0f52635 100644 --- a/JS/account.js +++ b/JS/account.js @@ -10,6 +10,9 @@ let post = JSON.parse(localStorage.getItem("post")); let AccountName = document.getElementsByClassName("Account")[0]; let AccountImage = document.getElementsByClassName("AccountImage")[0]; let AccountDescription = document.getElementsByClassName("AccountDescription")[0]; +let AlternateAccountName = document.getElementsByClassName("Account")[1]; +let AlternateAccountImage = document.getElementsByClassName("AccountImage")[1]; +let AlternateAccountDescription = document.getElementsByClassName("AccountDescription")[1]; let FollowButton = document.getElementsByClassName("Follow")[0]; let BlockButton = document.getElementsByClassName("Block")[0]; @@ -17,8 +20,10 @@ let BlockButton = document.getElementsByClassName("Block")[0]; let Following = false; let Blocking = false; +// SPAWN GetAccount(); +// The interaction is given to another function for async. FollowButton.onclick = (event) => { FollowBoop(); } @@ -33,6 +38,7 @@ async function FollowBoop() { SetFollow(); } +// Extra thing for the frontend to say "hey I am the follow meister". function SetFollow() { Following = !(Following); if (Following == true) { @@ -42,6 +48,7 @@ function SetFollow() { } } +// The interaction is given to another function for async. BlockButton.onclick = (event) => { BlockBoop(); } @@ -56,6 +63,7 @@ async function BlockBoop() { SetBlock(); } +// Extra thing for the frontend to say "hey I am the block meister". function SetBlock() { Blocking = !(Blocking); if (Blocking == true) { @@ -108,5 +116,33 @@ async function GetAccount() { AccountName.innerHTML = account.handle; AccountDescription.innerHTML = account.description; AccountImage.setAttribute("src", account.avatar); + } else { + FollowButton.setAttribute("hidden", ""); + BlockButton.setAttribute("hidden", ""); + // This is meant for the regular account. A big ol' you :3 + let Token = localStorage.getItem(Variables.MastodonAccessToken); + if (Token != null) { + let MastoProfile = await MastodonAPI.GetOwnAccount(); + AccountName.innerHTML = MastoProfile.username; + AccountDescription.innerHTML = MastoProfile.note; + AccountImage.setAttribute("src", MastoProfile.avatar); + // Build the fields + let Field = "
"; + for (let i of MastoProfile.fields) { + Field += "" + i.name + "" + i.value + ""; + } + Field += "
"; + AccountDescription.innerHTML += Field; + } + Token = localStorage.getItem(Variables.BlueskyAccessToken); + if (Token != null) { + let BlueProfile = await BlueskyAPI.GetProfile(localStorage.getItem(Variables.BlueskyDID)); + AlternateAccountImage.setAttribute("width", "20%"); + AlternateAccountImage.setAttribute("height", "20%"); + AlternateAccountName.innerHTML = BlueProfile.handle; + AlternateAccountDescription.innerHTML = BlueProfile.description; + AlternateAccountImage.setAttribute("src", BlueProfile.avatar); + } } + } diff --git a/JS/index.js b/JS/index.js index 0a27a47..d34793b 100644 --- a/JS/index.js +++ b/JS/index.js @@ -19,6 +19,7 @@ let SettingButton = document.getElementsByClassName("Setting")[0]; let MailButton = document.getElementsByClassName("Mail")[0]; let PostingButton = document.getElementsByClassName("Posting")[0]; let FeedButton = document.getElementsByClassName("Feed")[0]; +let TimeAccountButton = document.getElementsByClassName("Time")[0]; // Sounds const ButtonSound = new Audio("Audio/button-305770.mp3"); @@ -340,6 +341,12 @@ MailButton.onclick = (event) => { window.location.href = "./HTML/mail.html"; } +// A quick way of opening the account. +// In theory, this should be in another "channel" or the mail area, but those areas are crowded. +TimeAccountButton.onclick = (event) => { + window.location.href = "./HTML/account.html"; +} + // Open the posting area. PostingButton.onclick = (event) => { window.location.href = "./HTML/post.html";