redstrate.com/themes/red/assets/js/voting.js

18 lines
534 B
JavaScript
Raw Normal View History

2023-03-28 12:53:02 -04:00
function refresh(slug) {
2025-01-18 14:28:12 -05:00
fetch('https://voting.redstrate.com/votes/' + slug)
2023-03-28 12:53:02 -04:00
.then(function(response) {
return response.json();
})
.then(function(data) {
2023-09-04 07:59:34 -04:00
document.getElementById("num-votes").innerHTML = "❤️ " + data["votes"];
2023-03-28 12:53:02 -04:00
});
}
function addVote(slug) {
2025-01-18 14:28:12 -05:00
const request = new Request("https://voting.redstrate.com/votes/" + slug, {
2023-03-28 12:53:02 -04:00
method: "POST"
});
fetch(request)
.then((response) => { refresh(slug) });
}