diff --git a/themes/red/assets/js/voting.js b/themes/red/assets/js/voting.js new file mode 100644 index 0000000..7950266 --- /dev/null +++ b/themes/red/assets/js/voting.js @@ -0,0 +1,18 @@ +function refresh(slug) { + fetch('https://voting.redstrate.com/votes/view/' + slug) + .then(function(response) { + return response.json(); + }) + .then(function(data) { + console.log(data) + document.getElementById("num-votes").innerHTML = data["votes"] + " votes"; + }); +} + +function addVote(slug) { + const request = new Request("https://voting.redstrate.com/votes/submit/" + slug, { + method: "POST" + }); + fetch(request) + .then((response) => { refresh(slug) }); +} diff --git a/themes/red/layouts/_default/art-detail.html b/themes/red/layouts/_default/art-detail.html index da4984b..8145ea3 100644 --- a/themes/red/layouts/_default/art-detail.html +++ b/themes/red/layouts/_default/art-detail.html @@ -4,7 +4,7 @@
...
+