From dcbf60c134eb75563ee62645d9cce618384a1bfe Mon Sep 17 00:00:00 2001 From: echicken <echicken@bbs.electronicchicken.com> Date: Tue, 22 Nov 2016 11:44:25 -0500 Subject: [PATCH] submitPollAnswers - was missing 'sub' argument; does what it says on the tin; handle response from server, disable & style inputs. --- web/root/js/forum.js | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/web/root/js/forum.js b/web/root/js/forum.js index d85d751260..44332073af 100644 --- a/web/root/js/forum.js +++ b/web/root/js/forum.js @@ -381,13 +381,27 @@ function getVotesInThreads(sub) { ); } -function submitPollAnswers(id) { +function submitPollAnswers(sub, id) { + if ($('input[name="poll-' + id + '"]:checked').length < 1) return; + var answers = []; $('input[name="poll-' + id + '"]:checked').each( - function () { - alert($(this).val()); + function () { answers.push($(this).val()); } + ); + answers = answers.join('&answer='); + $.getJSON( + './api/forum.ssjs?call=submit-poll-answers&sub=' + sub + '&id=' + id + '&answer=' + answers, + function (data) { + $('input[name="poll-' + id + '"]').each( + function () { + $(this).attr('disabled', true); + if ($(this).prop('checked')) { + $(this).parent().parent().addClass('upvote-bg'); + } + } + ); + $('submit-poll-' + id).attr('disabled', true); } ); - // async ./api/forum.ssjs?call=submit-poll-answers&sub=x&id=x&answer=x&answer=x... } function pollControl(id, count) { -- GitLab