add: more mod panel stats add: show user invite in mod panel add:

ability to share to twitter/bluesky
This commit is contained in:
trisua 2025-06-24 13:18:52 -04:00
parent 66beef6b1d
commit 2676340fba
8 changed files with 201 additions and 22 deletions

View file

@ -1227,7 +1227,14 @@ ${option.input_element_type === "textarea" ? `${option.value}</textarea>` : ""}
).text();
self.IO_DATA_WAITING = false;
self.IO_DATA_ELEMENT.querySelector("[ui_ident=loading_skel]").remove();
const loading_skel = self.IO_DATA_ELEMENT.querySelector(
"[ui_ident=loading_skel]",
);
if (loading_skel) {
loading_skel.remove();
}
if (
text.includes(`!<!-- observer_disconnect_${window.BUILD_CODE} -->`)

View file

@ -531,6 +531,78 @@
return out;
});
// share intents
self.define(
"gen_share",
(
_,
ids = { q: "0", p: "0" },
target_length = 280,
include_link = true,
) => {
const part_1 = (
document.getElementById(`question_content:${ids.q}`) || {
innerText: "",
}
).innerText;
const part_2 = document.getElementById(
`post_content:${ids.p}`,
).innerText;
// ...
const link =
include_link !== false
? `${window.location.origin}/post/${ids.p}`
: "";
const link_size = link.length;
target_length -= link_size;
let out = "";
const separator = " — ";
const part_2_size = target_length / 2 - 1;
const sep_size = separator.length;
const part_1_size = target_length / 2 - sep_size;
if (part_1 !== "") {
out +=
part_1_size > part_1.length
? part_1
: part_1.substring(0, part_1_size);
out += separator;
}
if (part_2 !== "") {
out +=
part_2_size > part_2.length
? part_2
: part_2.substring(0, part_2_size);
}
out += ` ${link}`;
return out;
},
);
self.define("intent_twitter", (_, text) => {
window.open(
`https://twitter.com/intent/tweet?text=${encodeURIComponent(text)}`,
);
trigger("atto::toast", ["success", "Opened intent!"]);
});
self.define("intent_bluesky", (_, text) => {
window.open(
`https://bsky.app/intent/compose?text=${encodeURIComponent(text)}`,
);
trigger("atto::toast", ["success", "Opened intent!"]);
});
// token switcher
self.define("append_associations", (_, tokens) => {
fetch("/api/v1/auth/user/me/append_associations", {