add: profile connections, spotify connection

This commit is contained in:
trisua 2025-04-26 16:27:18 -04:00
parent a5c2356940
commit 33ba576d4a
31 changed files with 931 additions and 19 deletions

View file

@ -130,7 +130,10 @@ media_theme_pref();
let pretty = $.rel_date(then);
if (screen.width < 900 && pretty !== undefined) {
if (
(screen.width < 900 && pretty !== undefined) |
element.classList.contains("short")
) {
// shorten dates even more for mobile
pretty = pretty
.replaceAll(" minutes ago", "m")
@ -381,6 +384,45 @@ media_theme_pref();
}
});
self.define("hooks::spotify_time_text", (_) => {
for (const element of Array.from(
document.querySelectorAll("[hook=spotify_time_text]") || [],
)) {
function render() {
const updated = element.getAttribute("hook-arg:updated");
const progress = element.getAttribute("hook-arg:progress");
const duration = element.getAttribute("hook-arg:duration");
const display =
element.getAttribute("hook-arg:display") || "full";
element.innerHTML = trigger("spotify::timestamp", [
updated,
progress,
duration,
display,
]);
}
setInterval(() => {
element.setAttribute(
"hook-arg:updated",
Number.parseInt(element.getAttribute("hook-arg:updated")) +
1000,
);
element.setAttribute(
"hook-arg:progress",
Number.parseInt(element.getAttribute("hook-arg:progress")) +
1000,
);
render();
}, 1000);
render();
}
});
self.define("last_seen_just_now", (_, last_seen) => {
const now = new Date().getTime();
const maximum_time_to_be_considered_online = 60000 * 2; // 2 minutes
@ -999,7 +1041,7 @@ ${option.input_element_type === "textarea" ? `${option.value}</textarea>` : ""}
// open page
if (warning_page !== "") {
window.location.href = warning_page;
Turbo.visit(warning_page);
return;
}
},