2022-07-16 21:00:02 +00:00
|
|
|
function pinned_timestamp(id) {
|
|
|
|
const el = document.getElementById(id)
|
2022-09-04 23:15:37 +00:00
|
|
|
const pintooltip = el.getAttribute("data-bs-original-title")
|
2022-11-22 22:36:33 +00:00
|
|
|
if (!pintooltip.includes('until'))
|
|
|
|
{
|
|
|
|
const time = formatDate(new Date(parseInt(el.dataset.timestamp)*1000))
|
|
|
|
el.setAttribute("data-bs-original-title", `${pintooltip} until ${time}`)
|
|
|
|
}
|
2022-07-16 21:00:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const popClickBadgeTemplateDOM = document.createElement("IMG");
|
2022-11-12 10:44:13 +00:00
|
|
|
popClickBadgeTemplateDOM.classList.add("pop-badge");
|
2022-07-16 21:00:02 +00:00
|
|
|
popClickBadgeTemplateDOM.loading = "lazy";
|
|
|
|
popClickBadgeTemplateDOM.alt = "badge";
|
|
|
|
|
2023-02-02 20:07:14 +00:00
|
|
|
document.addEventListener('shown.bs.popover', (e) => {
|
|
|
|
let popover = document.getElementsByClassName("popover")
|
|
|
|
popover = popover[popover.length-1]
|
2022-09-04 23:15:37 +00:00
|
|
|
|
2023-02-02 20:07:14 +00:00
|
|
|
const author = JSON.parse(e.target.dataset.popInfo);
|
2022-07-16 21:00:02 +00:00
|
|
|
|
2023-02-02 20:07:14 +00:00
|
|
|
if (popover.getElementsByClassName('pop-username')[0].innerHTML == author["username"])
|
|
|
|
return
|
2022-09-04 23:15:37 +00:00
|
|
|
|
2023-02-02 20:07:14 +00:00
|
|
|
if (popover.getElementsByClassName('pop-badges')) {
|
|
|
|
const badgesDOM = popover.getElementsByClassName('pop-badges')[0];
|
|
|
|
badgesDOM.innerHTML = "";
|
|
|
|
for (const badge of author["badges"]) {
|
|
|
|
const badgeDOM = popClickBadgeTemplateDOM.cloneNode();
|
|
|
|
badgeDOM.src = badge + "?b=6";
|
2022-07-16 21:00:02 +00:00
|
|
|
|
2023-02-02 20:07:14 +00:00
|
|
|
badgesDOM.append(badgeDOM);
|
2022-07-20 01:16:59 +00:00
|
|
|
}
|
2023-02-02 20:07:14 +00:00
|
|
|
}
|
2022-07-16 21:00:02 +00:00
|
|
|
|
2023-02-02 20:07:14 +00:00
|
|
|
popover.getElementsByClassName('pop-banner')[0].src = author["bannerurl"]
|
|
|
|
popover.getElementsByClassName('pop-picture')[0].src = author["profile_url"]
|
|
|
|
if (author["hat"]) popover.getElementsByClassName('pop-hat')[0].src = author['hat'] + "?h=7"
|
|
|
|
popover.getElementsByClassName('pop-username')[0].innerHTML = author["username"]
|
|
|
|
if (popover.getElementsByClassName('pop-bio').length > 0) {
|
|
|
|
popover.getElementsByClassName('pop-bio')[0].innerHTML = author["bio_html"]
|
2022-07-16 21:00:02 +00:00
|
|
|
}
|
2023-02-02 20:07:14 +00:00
|
|
|
popover.getElementsByClassName('pop-postcount')[0].innerHTML = author["post_count"]
|
|
|
|
popover.getElementsByClassName('pop-commentcount')[0].innerHTML = author["comment_count"]
|
|
|
|
popover.getElementsByClassName('pop-coins')[0].innerHTML = author["coins"]
|
|
|
|
popover.getElementsByClassName('pop-view_more')[0].href = author["url"]
|
|
|
|
popover.getElementsByClassName('pop-created-date')[0].innerHTML = author["created_date"]
|
2023-03-11 10:24:17 +00:00
|
|
|
popover.getElementsByClassName('pop-id')[0].innerHTML = author["id"]
|
2023-02-02 20:07:14 +00:00
|
|
|
})
|
2022-07-16 21:00:02 +00:00
|
|
|
|
|
|
|
function post(url) {
|
2022-10-14 12:01:11 +00:00
|
|
|
const xhr = createXhrWithFormKey(url);
|
|
|
|
xhr[0].send(xhr[1]);
|
2022-07-16 21:00:02 +00:00
|
|
|
};
|
|
|
|
|
2022-09-05 23:33:58 +00:00
|
|
|
function poll_vote_0(oid, parentid, kind) {
|
2022-11-11 19:02:57 +00:00
|
|
|
for(let el of document.getElementsByClassName('presult-'+parentid)) {
|
|
|
|
el.classList.remove('d-none');
|
|
|
|
}
|
2022-09-05 23:33:58 +00:00
|
|
|
const full_oid = kind + '-' + oid
|
|
|
|
const type = document.getElementById(full_oid).checked;
|
|
|
|
const scoretext = document.getElementById('score-' + full_oid);
|
|
|
|
const score = Number(scoretext.textContent);
|
2022-07-16 21:00:02 +00:00
|
|
|
if (type == true) scoretext.textContent = score + 1;
|
|
|
|
else scoretext.textContent = score - 1;
|
2022-09-05 23:33:58 +00:00
|
|
|
post(`/vote/${kind}/option/${oid}`);
|
2022-07-16 21:00:02 +00:00
|
|
|
}
|
|
|
|
|
2022-09-05 23:33:58 +00:00
|
|
|
function poll_vote_1(oid, parentid, kind) {
|
2022-11-11 19:02:57 +00:00
|
|
|
for(let el of document.getElementsByClassName('presult-'+parentid)) {
|
|
|
|
el.classList.remove('d-none');
|
|
|
|
}
|
2022-09-05 23:33:58 +00:00
|
|
|
const full_oid = kind + '-' + oid
|
|
|
|
let curr = document.getElementById(`current-${kind}-${parentid}`)
|
2022-07-16 21:00:02 +00:00
|
|
|
if (curr && curr.value)
|
|
|
|
{
|
2022-09-05 23:33:58 +00:00
|
|
|
const scoretext = document.getElementById('score-' + curr.value);
|
|
|
|
const score = Number(scoretext.textContent);
|
2022-07-16 21:00:02 +00:00
|
|
|
scoretext.textContent = score - 1;
|
|
|
|
}
|
|
|
|
|
2022-09-05 23:33:58 +00:00
|
|
|
const scoretext = document.getElementById('score-' + full_oid);
|
2022-07-16 21:00:02 +00:00
|
|
|
|
2022-09-05 23:33:58 +00:00
|
|
|
const score = Number(scoretext.textContent);
|
2022-07-16 21:00:02 +00:00
|
|
|
scoretext.textContent = score + 1;
|
2022-09-05 23:33:58 +00:00
|
|
|
post(`/vote/${kind}/option/${oid}`);
|
|
|
|
curr.value = full_oid
|
2022-07-16 21:00:02 +00:00
|
|
|
}
|
|
|
|
|
2022-11-21 01:00:10 +00:00
|
|
|
function bet_vote(t, oid) {
|
|
|
|
postToast(t, `/vote/post/option/${oid}`,
|
|
|
|
{
|
|
|
|
},
|
|
|
|
() => {
|
|
|
|
for(let el of document.getElementsByClassName('bet')) {
|
|
|
|
el.disabled = true;
|
|
|
|
}
|
|
|
|
for(let el of document.getElementsByClassName('cost')) {
|
|
|
|
el.classList.add('d-none')
|
|
|
|
}
|
2022-12-04 15:40:32 +00:00
|
|
|
const scoretext = document.getElementById('option-' + oid);
|
|
|
|
const score = Number(scoretext.textContent);
|
2022-11-21 01:00:10 +00:00
|
|
|
scoretext.textContent = score + 1;
|
|
|
|
}
|
|
|
|
);
|
2022-11-07 10:49:49 +00:00
|
|
|
}
|