<commit_before>(function($) {
  "use strict";

  $.fn.quiz = function(opts) {

    var node = this,
        nodeScore = node.find('.score .current'),
        nodeTimer = node.find('.timer .time'),
        nodeAnswer = node.find('input.answer'),
        nodeAnswers = node.find('.answers'),

        nodeStart = node.find('.start'),
        nodePause = node.find('.pause'),
        nodeGiveup = node.find('.give-up'),
        nodeRestart = node.find('.restart'),
        nodeNext = node.find('.next'),
        nodePrev = node.find('.prev'),
        nodeQuestion = node.find('.question'),
        nodeOverlay = node.find('.overlay'),
        nodeOverlayInner = nodeOverlay.find('.inner'),
        nodeInfo = node.find('.quiz-info-wrap'),
        nodeMistakes = node.find('.mistakes'),

        nodeResults = node.find('.results'),

        options = opts || {},
        store = {},
        settings = null,

        answers = [],

        started = null,
        finished = null,
        last_tick = null,
        time_taken = 0,
        score = 0,
        wrong_answers = 0,
        maxScore = null,

        // Index of currently active question.
        // Only needed for force_order or one_by_one.
        current_question_index = null,


        timerHandle = null;

    // Retrieve settings store.
    if (node.find('.data')) {
      store = JSON.parse(node.find('.data').html());
      if (typeof(store) !== 'object' || !('id' in store)) {
        throw new Error("Invalid datastore!");
      }
    }

    settings = $.extend(store, options);

    function buildAnswerMap() {
      var map = {};

      for (var key in settings.questions) {
        var question = settings.questions[key];

        var answer = question.answer;
        if (settings.ignore_case) {
          answer = answer.toLowerCase();
        }
        if (settings.ignore_spaces) {
          answer = answer.replace(' ', '');
        }

        var answers = answer.split('|');

        for (var i = 0; i < answers.length; i++) {
          map[answers[i]] = question;
        }
      }

      return map;
    }

    function isPaged() {
      return settings.one_by_one || settings.force_order || settings.mode === "click";
    }


    function start() {
      answers = buildAnswerMap();
      maxScore = settings.questions.length;

      started = last_tick = new Date();

      updateTimerLabel();
      initTimer();

      nodePause.removeClass('disabled');
      nodeGiveup.removeClass('disabled');
      nodeAnswer.attr('disabled', null);

      // Handle "paged" quizzes which enforce a question order.
      if (isPaged()) {
        if (settings.allow_paging) {
          nodeNext.removeClass('disabled');
          nodePrev.removeClass('disabled');
        }

        nextQuestion();
      }

      // Remove start button.
      nodeStart.fadeOut(function() {
        nodeStart.remove();
      });


    }
<commit_msg>Now focusing input box on quiz start.<commit_after>(function($) {
  "use strict";

  $.fn.quiz = function(opts) {

    var node = this,
        nodeScore = node.find('.score .current'),
        nodeTimer = node.find('.timer .time'),
        nodeAnswer = node.find('input.answer'),
        nodeAnswers = node.find('.answers'),

        nodeStart = node.find('.start'),
        nodePause = node.find('.pause'),
        nodeGiveup = node.find('.give-up'),
        nodeRestart = node.find('.restart'),
        nodeNext = node.find('.next'),
        nodePrev = node.find('.prev'),
        nodeQuestion = node.find('.question'),
        nodeOverlay = node.find('.overlay'),
        nodeOverlayInner = nodeOverlay.find('.inner'),
        nodeInfo = node.find('.quiz-info-wrap'),
        nodeMistakes = node.find('.mistakes'),

        nodeResults = node.find('.results'),

        options = opts || {},
        store = {},
        settings = null,

        answers = [],

        started = null,
        finished = null,
        last_tick = null,
        time_taken = 0,
        score = 0,
        wrong_answers = 0,
        maxScore = null,

        // Index of currently active question.
        // Only needed for force_order or one_by_one.
        current_question_index = null,


        timerHandle = null;

    // Retrieve settings store.
    if (node.find('.data')) {
      store = JSON.parse(node.find('.data').html());
      if (typeof(store) !== 'object' || !('id' in store)) {
        throw new Error("Invalid datastore!");
      }
    }

    settings = $.extend(store, options);

    function buildAnswerMap() {
      var map = {};

      for (var key in settings.questions) {
        var question = settings.questions[key];

        var answer = question.answer;
        if (settings.ignore_case) {
          answer = answer.toLowerCase();
        }
        if (settings.ignore_spaces) {
          answer = answer.replace(' ', '');
        }

        var answers = answer.split('|');

        for (var i = 0; i < answers.length; i++) {
          map[answers[i]] = question;
        }
      }

      return map;
    }

    function isPaged() {
      return settings.one_by_one || settings.force_order || settings.mode === "click";
    }


    function start() {
      answers = buildAnswerMap();
      maxScore = settings.questions.length;

      started = last_tick = new Date();

      updateTimerLabel();
      initTimer();

      nodePause.removeClass('disabled');
      nodeGiveup.removeClass('disabled');
      nodeAnswer.attr('disabled', null);

      // Handle "paged" quizzes which enforce a question order.
      if (isPaged()) {
        if (settings.allow_paging) {
          nodeNext.removeClass('disabled');
          nodePrev.removeClass('disabled');
        }

        nextQuestion();
      }

      // Remove start button.
      nodeStart.fadeOut(function() {
        nodeStart.remove();
      });

      // Jump to input box for typed quiz.
      if (settings.mode === "type") {
        nodeAnswer.focus();
      }
    }

{'fraction_non_alphanumeric': 0.14694014794889038, 'fraction_numerical': 0.0013449899125756557, 'mean_word_length': 1.990950226244344, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5392553', 'n_tokens_mistral': 1739, 'n_tokens_neox': 1655, 'n_words': 371}