$(document).ready(function() {
  var $question = $('#question');
  var $choices = $('#choices');
  var $answerAnother = $('#answer-another');

  $question.find('.choice').each(function(index, choice) {
    var $choice = $(choice);

    $choice.click(function() {
      $choices.replaceWith("Submitting ...");

      $.post('/response',
        {
          questionId: $question.data('question-id'),
          choiceId: $choice.data('choice-id')
        },
        function(data) {
          $question.replaceWith('Answer submitted.');
          $answerAnother.show();
        }
      );
    });
  });

  var $addQuestionForm = $('#add-question-form');
  var $questionTitle = $('#question-title');
  var $addChoice = $('#add-choice');
  var $addQuestion = $('#add-question');
  var $submitting = $('#submitting');
  var $addAnother = $('#add-another');
  var $choiceRows = $('#choice-rows');
  var choiceTemplate = $('#choice-template').html();

  $addQuestion.click(function() {
    var questionTitle = $questionTitle.val()

    var choices = $addQuestionForm.find('.choice').map(function() {
      return $(this).val();
    })
    .get()
    .filter(function(choice) { return choice != ''; });

    if (questionTitle == '') {
      alert('Question title required.');
      return;
    }

    if (choices.length == 0) {
      alert('At least one choice must not be blank.');
      return;
    }

    $addQuestionForm.remove();
    $submitting.show();

    $.post('/admin/add-question',
      {
        questionTitle: questionTitle,
        'choices[]': choices
      },
      function(data) {
        $submitting.hide();
        $addAnother.show();
      }
    );
  });

  $addChoice.click(function() {
    $choiceRows.append(choiceTemplate);
  });
});

@@ -1,8 +1,42 @@
+/* eslint-env browser, jquery */%0A%0A
 $(docume
@@ -317,17 +317,17 @@
 aceWith(
-%22
+'
 Submitti
@@ -336,9 +336,9 @@
  ...
-%22
+'
 );%0A%0A
@@ -492,36 +492,32 @@
        function(
-data
 ) %7B%0A          $q
@@ -1046,16 +1046,17 @@
 le.val()
+;
 %0A%0A    va
@@ -1210,16 +1210,17 @@
 hoice !=
+=
  ''; %7D);
@@ -1245,16 +1245,17 @@
 Title ==
+=
  '') %7B%0A 
@@ -1340,16 +1340,17 @@
 ength ==
+=
  0) %7B%0A  
@@ -1612,20 +1612,16 @@
 unction(
-data
 ) %7B%0A    

Apply ES5 lint feedback to public/js/survey.js.