fix clan badge ( primary_guild), add timezone api, move robots to public/custom support, move to atums/echo for logging instead
All checks were successful
Code quality checks / biome (push) Successful in 9s
All checks were successful
Code quality checks / biome (push) Successful in 9s
This commit is contained in:
parent
eb2bec6649
commit
3cb3b76a2b
13 changed files with 269 additions and 123 deletions
|
@ -995,3 +995,37 @@ ul {
|
|||
height: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
/* timezone display */
|
||||
|
||||
.timezone-wrapper {
|
||||
position: fixed;
|
||||
top: 1rem;
|
||||
right: 1rem;
|
||||
background-color: var(--card-bg);
|
||||
color: var(--text-color);
|
||||
font-size: 0.9rem;
|
||||
padding: 0.4rem 0.8rem;
|
||||
border-radius: 6px;
|
||||
border: 1px solid var(--border-color);
|
||||
box-shadow: 0 0 8px rgba(0, 0, 0, 0.2);
|
||||
z-index: 100;
|
||||
user-select: none;
|
||||
opacity: 0.85;
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.timezone-wrapper:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.timezone-label {
|
||||
color: var(--text-muted);
|
||||
margin-right: 0.4rem;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.timezone-label {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ const userId = head?.dataset.userId;
|
|||
const activityProgressMap = new Map();
|
||||
|
||||
const reviewURL = head?.dataset.reviewDb;
|
||||
const timezoneApiUrl = head?.dataset.timezoneApi;
|
||||
let instanceUri = head?.dataset.instanceUri;
|
||||
let badgeURL = head?.dataset.badgeUrl;
|
||||
let socket;
|
||||
|
@ -209,6 +210,60 @@ async function populateReviews(userId) {
|
|||
}
|
||||
}
|
||||
|
||||
function populateTimezone(userId) {
|
||||
if (!userId || !timezoneApiUrl) return;
|
||||
|
||||
let currentTimezone = null;
|
||||
|
||||
async function fetchTimezone() {
|
||||
try {
|
||||
const res = await fetch(
|
||||
`${timezoneApiUrl}/get?id=${encodeURIComponent(userId)}`,
|
||||
);
|
||||
if (!res.ok) throw new Error("Failed to fetch timezone");
|
||||
|
||||
const json = await res.json();
|
||||
if (!json || typeof json.timezone !== "string") return;
|
||||
|
||||
currentTimezone = json.timezone;
|
||||
updateTime();
|
||||
} catch (err) {
|
||||
console.error("Failed to populate timezone", err);
|
||||
}
|
||||
}
|
||||
|
||||
function updateTime() {
|
||||
if (!currentTimezone) return;
|
||||
|
||||
const timezoneEl = document.querySelector(".timezone-value");
|
||||
if (!timezoneEl) return;
|
||||
|
||||
const now = new Date();
|
||||
|
||||
const time24 = now.toLocaleTimeString("en-GB", {
|
||||
timeZone: currentTimezone,
|
||||
hour12: false,
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
});
|
||||
|
||||
const time12 = now.toLocaleTimeString("en-US", {
|
||||
timeZone: currentTimezone,
|
||||
hour12: true,
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
second: "2-digit",
|
||||
});
|
||||
|
||||
timezoneEl.textContent = time24;
|
||||
timezoneEl.title = `${time12} (${currentTimezone})`;
|
||||
}
|
||||
|
||||
fetchTimezone();
|
||||
setInterval(updateTime, 1000);
|
||||
}
|
||||
|
||||
function setupReviewScrollObserver(userId) {
|
||||
const sentinel = document.createElement("div");
|
||||
sentinel.className = "review-scroll-sentinel";
|
||||
|
@ -593,6 +648,14 @@ async function updatePresence(initialData) {
|
|||
setupReviewScrollObserver(userId);
|
||||
}
|
||||
|
||||
if (kv.timezone !== "false" && userId && timezoneApiUrl) {
|
||||
populateTimezone(userId);
|
||||
const timezoneEl = document.querySelector(".timezone-value");
|
||||
if (timezoneEl) {
|
||||
timezoneEl.classList.remove("hidden");
|
||||
}
|
||||
}
|
||||
|
||||
const platform = {
|
||||
mobile: data.active_on_discord_mobile,
|
||||
web: data.active_on_discord_web,
|
||||
|
@ -755,7 +818,7 @@ function updateClanBadge(data) {
|
|||
const userInfoInner = document.querySelector(".user-info-inner");
|
||||
if (!userInfoInner) return;
|
||||
|
||||
const clan = data?.discord_user?.clan;
|
||||
const clan = data?.discord_user?.primary_guild;
|
||||
if (!clan || !clan.tag || !clan.identity_guild_id || !clan.badge) return;
|
||||
|
||||
const existing = userInfoInner.querySelector(".clan-badge");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue