This commit is contained in:
Aevann1 2022-04-25 23:41:46 +02:00
parent dde892d8c3
commit 76c72d42b2
7 changed files with 61 additions and 76 deletions

View file

@ -1,12 +1,3 @@
function post(url) {
const xhr = new XMLHttpRequest();
xhr.open("POST", url);
xhr.setRequestHeader('xhr', 'xhr');
var form = new FormData()
form.append("formkey", formkey());
xhr.send(form);
};
function post_toast3(t, url, button1, button2) {
t.disabled=true;
t.classList.add("disabled");
@ -306,38 +297,6 @@ document.onpaste = function(event) {
}
}
function poll_vote(cid, parentid) {
for(let el of document.getElementsByClassName('presult-'+parentid)) {
el.classList.remove('d-none');
}
var type = document.getElementById(cid).checked;
var scoretext = document.getElementById('poll-' + cid);
var score = Number(scoretext.textContent);
if (type == true) scoretext.textContent = score + 1;
else scoretext.textContent = score - 1;
post('/vote/poll/' + cid + '?vote=' + type);
}
function choice_vote(cid, parentid) {
for(let el of document.getElementsByClassName('presult-'+parentid)) {
el.classList.remove('d-none');
}
let curr = document.getElementById(`current-${parentid}`)
if (curr && curr.value)
{
var scoretext = document.getElementById('choice-' + curr.value);
var score = Number(scoretext.textContent);
scoretext.textContent = score - 1;
}
var scoretext = document.getElementById('choice-' + cid);
var score = Number(scoretext.textContent);
scoretext.textContent = score + 1;
post('/vote/choice/' + cid);
curr.value = cid
}
function handle_action(type, cid, thing) {