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

  var Application = function() {
    var app = this;

    app.debug = false;
    app.WEAPON_APPEARING_INTERVAL = 100;
    app.WEAPON_COMBINATION_SIZE = 3;
    app.SHOOTING_TIME = 1000;

    app.$templates = $('.template').hide();
    app.$content   = $('#content');

    var log = function() {
      if (app.debug && window.console) {
        Function.prototype.apply.call(window.console.log, window.console,
                                        Array.prototype.slice.call(arguments));
      }
    };

    app.$ = function(selector) {
      return $(selector, app.$content);
    };

    app.Connection = {
      connection: null,
      active: false,

      start: function(host) {
        log("[Connection] Starting connection to", host);
        this.connection = "http://" + host;
        $(this).trigger("opened");
      },

      stop: function() {
        this.active = false;
        $(this).trigger("closed");
      },

      send: function(data) {
        log("[Connection] Sending to server", data);
        $.ajax(this.connection, { dataType: "jsonp", data: data });
      }
    },

    app.Controllers = {
      _app: app,

      _render: function(id) {
        var $template = app.$templates.filter(id);
        app.$content.html($template.html());
      },

      _getParam: function(key) {
        var query = window.location.search.substring(1),
            vars = query.split('&');
        for (var i = 0; i < vars.length; i++) {
          var pair = vars[i].split('=');
          if (decodeURIComponent(pair[0]) == key) {
            return decodeURIComponent(pair[1]);
          }
        }
      },

      _controllers: {
        index: function() {
          var app = this._app;

          var serverHost = this._getParam("server");
          if (!serverHost) {
            log("[Controller] [index] No server address provided");
            app.$("h2").text("Please supply a server address.");

          } else {
            $(app.Connection).on("opened", function() {
              app.Controllers.go("build");
            });
            app.Connection.start(serverHost);
          }
        },

        build: function() {
          // show weapons one-by-one
          var app = this._app;
          var $weapons = app.$("#weapons button");
          var addWeapon = function() {
            var $hidden = $weapons.filter(".hidden");
            var random = Math.round(Math.random() * $hidden.length-1);
            $hidden.eq(random).removeClass("hidden");
          };
          $weapons.addClass("hidden");
          window.setInterval(addWeapon, this._app.WEAPON_APPEARING_INTERVAL);

          // weapon construction
          var selectedWeapons = [];
          $weapons.on('click', function() {
            var weapon = $(this).text();
            selectedWeapons.push(weapon);
            log("[Controller] [build] weapons selected:", selectedWeapons);

            $(this).attr('disabled', true);

            if (selectedWeapons.length >= 3) { // time to shoot
              app.Controllers.go('shoot', { weapons: selectedWeapons });
            }
          });
        },

        shoot: function(params) {
          var app = this._app;

          log("[Controller] [Shoot] Shooting with weapons", params.weapons);

          // send fire
          app.Connection.send({
            w: params.weapons.join(',')
          });

          // go back after shooting time ended
          var goBack = function() {
            app.Controllers.go('build');
          };
          window.setTimeout(goBack, app.SHOOTING_TIME);
        }
      },

      go: function(page, params) {
        log("[Controller] viewing page", page, params);

        this._render('#' + page);
        if (page in this._controllers) {
          this._controllers[page].call(this, params);
        }
      }
    };

    app.start = function(){
      app.debug = !!(app.Controllers._getParam('debug'));
      app.Controllers.go('index');<commit_msg>Some minor bugfixes<commit_after>(function($, window){
  "use strict";

  var Application = function() {
    var app = this;

    app.debug = false;
    app.WEAPON_APPEARING_INTERVAL = 100;
    app.WEAPON_COMBINATION_SIZE = 3;
    app.SHOOTING_TIME = 1000;

    app.$templates = $('.template').hide();
    app.$content   = $('#content');

    var log = function() {
      if (app.debug && window.console) {
        Function.prototype.apply.call(window.console.log, window.console,
                                        Array.prototype.slice.call(arguments));
      }
    };

    app.$ = function(selector) {
      return $(selector, app.$content);
    };

    app.Connection = {
      connection: null,
      active: false,

      start: function(host) {
        log("[Connection] Starting connection to", host);
        this.connection = "http://" + host;
        $(this).trigger("opened");
      },

      stop: function() {
        this.active = false;
        $(this).trigger("closed");
      },

      send: function(data) {
        log("[Connection] Sending to server", data);
        $.ajax(this.connection, { dataType: "jsonp", data: data });
      }
    },

    app.Controllers = {
      _app: app,

      _render: function(id) {
        var $template = app.$templates.filter(id);
        app.$content.html($template.html());
      },

      _getParam: function(key) {
        var query = window.location.search.substring(1),
            vars = query.split('&');
        for (var i = 0; i < vars.length; i++) {
          var pair = vars[i].split('=');
          if (decodeURIComponent(pair[0]) == key) {
            return decodeURIComponent(pair[1]);
          }
        }
      },

      _controllers: {
        index: function() {
          var app = this._app;

          var serverHost = this._getParam("server");
          if (!serverHost) {
            log("[Controller] [index] No server address provided");
            app.$("h2").text("Please supply a server address.");

          } else {
            $(app.Connection).on("opened", function() {
              app.Controllers.go("build");
            });
            app.Connection.start(serverHost);
          }
        },

        build: function() {
          // show weapons one-by-one
          var app = this._app;
          var $weapons = app.$("#weapons button");
          var addWeapon = function() {
            var $hidden = $weapons.filter(".hidden");
            var random = Math.round(Math.random() * $hidden.length-1);
            $hidden.eq(random).removeClass("hidden");
          };
          $weapons.addClass("hidden").removeAttr('disabled');
          window.setInterval(addWeapon, app.WEAPON_APPEARING_INTERVAL);

          // weapon construction
          var selectedWeapons = [];
          $weapons.on('click', function() {
            var weapon = $(this).text();
            selectedWeapons.push(weapon);
            log("[Controller] [build] weapons selected:", selectedWeapons);

            $(this).attr('disabled', true);

            if (selectedWeapons.length >= app.WEAPON_COMBINATION_SIZE) {
              // time to shoot
              app.Controllers.go('shoot', { weapons: selectedWeapons });
            }
          });
        },

        shoot: function(params) {
          var app = this._app;

          log("[Controller] [Shoot] Shooting with weapons", params.weapons);

          // send fire
          app.Connection.send({
            w: params.weapons.join(',')
          });

          // go back after shooting time ended
          var goBack = function() {
            app.Controllers.go('build');
          };
          window.setTimeout(goBack, app.SHOOTING_TIME);
        }
      },

      go: function(page, params) {
        params = params || null;
        log("[Controller] viewing page", page, params);

        this._render('#' + page);
        if (page in this._controllers) {
          this._controllers[page].call(this, params);
        }
      }
    };

    app.start = function(){
      app.debug = !!(app.Controllers._getParam('debug'));
      app.Controllers.go('index');
{'fraction_non_alphanumeric': 0.1516978346456693, 'fraction_numerical': 0.003567913385826772, 'mean_word_length': 1.8314176245210727, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '848747', 'n_tokens_mistral': 2336, 'n_tokens_neox': 2261, 'n_words': 460}