Fedi.CrowdedGames.Group/JS/index.js
CatAClock 9dec1ad6cc multiple things.
Added docker file so you can build it.
Added Organization
Brutally forced the index.js to be a module for ease-of-access
Got some of the federation to work. Just some.
2025-04-21 16:04:42 -07:00

117 lines
3.7 KiB
JavaScript

import * as ActivityPub from "./ActivityPub.js";
// GLOBAL VARS
// fuck you. I see why website developers use divs so fucking often.
let Warning = document.getElementsByClassName("WarningMessage")[0];
let Main = document.getElementsByClassName("MainBefore")[0];
let ContainerContainer = document.getElementsByClassName("PostContainerContainer")[0];
let BrowserWidth = window.innerWidth;
let BrowserHeight = window.innerHeight;
let ArrowsButton = document.getElementsByClassName("Arrow");
let SettingButton = document.getElementsByClassName("Setting")[0];
let MailButton = document.getElementsByClassName("Mail")[0];
// Sounds
const ButtonSound = new Audio("Audio/button-305770.mp3");
const WarningClick = new Audio("Audio/button-pressed-38129.mp3");
const BackgroundMusic = new Audio("Audio/soft-piano-music-312509.mp3");
// Update a timer
function UpdateTime() {
var TimeNow = new Date();
var Hour = TimeNow.getHours();
var Minute = TimeNow.getMinutes();
var WebsiteTime = document.getElementsByClassName("Time")[0]
WebsiteTime.innerHTML = "";
if (Hour < 10) {
WebsiteTime.innerHTML = WebsiteTime.innerHTML + "0" + Hour;
} else {
WebsiteTime.innerHTML = WebsiteTime.innerHTML + Hour;
}
WebsiteTime.innerHTML = WebsiteTime.innerHTML + ":";
if (Minute < 10) {
WebsiteTime.innerHTML = WebsiteTime.innerHTML + "0" + Minute;
} else {
WebsiteTime.innerHTML = WebsiteTime.innerHTML + Minute;
}
}
setInterval(UpdateTime, 1000);
// When the window is resized
onresize = (event) => {
BrowserWidth = window.innerWidth;
BrowserHeight = window.innerHeight;
window.dispatchEvent(new Event("load"));
}
// When the window finally reloads
onload = (event) => {
Warning.setAttribute("style", "height: " + BrowserHeight + "px; width: " + BrowserWidth + "px;");
Main.setAttribute("style", "height: " + BrowserHeight + "px; width: " + BrowserWidth + "px;");
ArrowsButton[1].setAttribute("style", "left: " + (BrowserWidth - 100) + "px;");
}
// On clicking the warning message
Warning.onclick = (event) => {
Warning.classList.add("WarningFadeOutAnimation");
// fixes a damn stupid bug
document.getElementsByClassName("BlinkAnimation")[0].classList.remove("BlinkAnimation");
Main.classList.add("MainFadeInAnimation");
Main.classList.remove("MainBefore");
WarningClick.play();
setTimeout(() => {
Main.classList.remove("MainFadeInAnimation");
Main.classList.add("MainAfter");
BackgroundMusic.play();
}, 5000);
Main = document.getElementsByClassName("MainFadeInAnimation")[0];
PosterContainerUpdate();
}
// Clicking the next button
ArrowsButton[1].onclick = (event) => {
if (!ContainerContainer.classList.contains("NextAnimation")) {
ContainerContainer.classList.add("NextAnimation");
ButtonSound.play();
console.log("loading next posts...");
setTimeout(() => {
ContainerContainer.classList.remove("NextAnimation");
}, 1000);
}
PosterContainerUpdate();
}
// Clicking the back button
ArrowsButton[0].onclick = (event) => {
if (!ContainerContainer.classList.contains("BackAnimation")) {
ContainerContainer.classList.add("BackAnimation");
ButtonSound.play();
console.log("getting previous posts...");
setTimeout(() => {
ContainerContainer.classList.remove("BackAnimation");
}, 1000);
}
PosterContainerUpdate();
}
async function PosterContainerUpdate() {
var Content = await ActivityPub.GetPublicTimelineContent();
var CenterContainer = document.getElementsByClassName("PostContainer")[1].children;
for (let i in CenterContainer) {
CenterContainer[i].getElementsByClassName("PostContent")[0].innerHTML = Content[i];
}
}
// Open the settings
SettingButton.onclick = (event) => {
window.location.href = "./HTML/setting.html";
}
// Open the notifs, private message, favorites, bookmarks
MailButton.onclick = (event) => {
window.location.href = "./HTML/mail.html";
}