Important information: Google announced that, from September 2026, Android devices will require ALL apps to be signed by Google, effectively leading to an iOS situation. Value your right to a computer that does what you want; do not tolerate this monopolistic practice! Contact me if you don't understand why it is bad. Click to learn more.

 voting.js

View raw Download
text/plain • 843 B
ASCII text
        
            
1
function updateButtons(postID, score) {
2
document.getElementById(postID + "-voteup").classList.add("button-flat");
3
document.getElementById(postID + "-votedown").classList.add("button-flat");
4
5
if(score == 1) {
6
document.getElementById(postID + "-voteup").classList.remove("button-flat");
7
} else if(score == -1) {
8
document.getElementById(postID + "-votedown").classList.remove("button-flat");
9
}
10
}
11
12
async function vote(postID, score) {
13
if(score === 1) {
14
action = "voteup";
15
} else if(score === -1) {
16
action = "votedown";
17
} else {
18
action = "votes";
19
}
20
const response = await fetch(postID + "/" + action);
21
const info = await response.text();
22
document.getElementById(postID + "-vote").innerText = info.split(" ")[0];
23
updateButtons(postID, info.split(" ")[1])
24
}
25