AstroCom-API/public/assets/js/landing.js
2024-12-16 20:35:15 -07:00

51 lines
1.4 KiB
JavaScript

// dotbrew 2024
let ass = 0;
function switchit() {
document.querySelector(".text-wrapper").style = "";
document.querySelector(".text-wrapper").firstElementChild.remove();
var c = document.querySelector(".text-wrapper").firstElementChild.cloneNode(true);
c.innerHTML = "";
document.querySelector(".text-wrapper").appendChild(c);
};
function scroll() {
document.querySelector(".text-wrapper").style.transition = "top 0.5s ease";
document.querySelector(".text-wrapper").style.top = "-50px";
setTimeout(switchit, 510)
};
function chgtext(tex) {
var c = document.querySelector(".text-wrapper").lastElementChild.innerHTML = tex;
scroll();
};
$(document).ready(function () {
$(".fadein").fadeIn(1250);
});
$("#signin").on("click", function () {
$(".signinmenu").slideDown();
});
// Pull analytics from /api/analytics
var lastText = "";
setInterval(() => {
fetch('/api/analytics')
.then(response => response.json())
.then(data => {
estCallsMadeStat = data.total.find(stat => stat.tag === "estCallsMade")?.count;
currentDailyCallsMadeStat = data.daily.find(stat => stat.tag === "dailyCallsMade" && stat.current === true)?.count;
var newText = `Total calls made: ${estCallsMadeStat}<br>Today's calls made: ${currentDailyCallsMadeStat}`;
if (lastText !== newText) {
chgtext(newText);
lastText = newText;
}
})
.catch(error => console.error('Error fetching analytics:', error));
}, 2000)