2022-10-14 18:41:03 +00:00
|
|
|
function pinPost(t, id) {
|
2022-11-03 19:07:08 +00:00
|
|
|
postToastCallback(t, `/sticky/${id}`,
|
2022-10-14 18:41:03 +00:00
|
|
|
{
|
|
|
|
},
|
|
|
|
(xhr) => {
|
2022-11-03 19:07:08 +00:00
|
|
|
response = JSON.parse(xhr.response);
|
|
|
|
length = response["length"];
|
|
|
|
if (length == "permanently") {
|
|
|
|
t.innerHTML = t.innerHTML.replace(t.textContent, 'Pin for 1 hour');
|
|
|
|
t.classList.add('d-none');
|
|
|
|
} else {
|
|
|
|
t.innerHTML = t.innerHTML.replace(t.textContent, 'Pin permanently');
|
2022-10-14 18:41:03 +00:00
|
|
|
}
|
2022-11-03 19:07:08 +00:00
|
|
|
t.nextElementSibling.classList.remove('d-none');
|
2022-10-14 18:41:03 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
2022-10-30 15:20:11 +00:00
|
|
|
|
|
|
|
function unpinPost(t, id) {
|
2022-11-03 19:07:08 +00:00
|
|
|
postToastCallback(t, `/unsticky/${id}`,
|
2022-10-30 15:20:11 +00:00
|
|
|
{
|
|
|
|
},
|
2022-11-03 19:07:08 +00:00
|
|
|
() => {
|
|
|
|
t.classList.add('d-none');
|
|
|
|
const prev = t.previousElementSibling;
|
|
|
|
prev.innerHTML = prev.innerHTML.replace(prev.textContent, 'Pin for 1 hour');
|
|
|
|
prev.classList.remove('d-none');
|
2022-10-30 15:20:11 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|