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

  String.prototype.toBool = function() {
    switch(this.toLowerCase()) {
      case "false": case "no": case "0": case "":
      return false;
      default: return true;}
  };


  var PluginManagerModel = function PluginManagerModel() {
    var self = this;
    self.controlablePlugins = ko.observableArray();
    self.enablePlugin = function(plugin) {
      if (plugin.isEnabled()) return;
      plugin.isEnabled(true);
    };

    self.disablePlugin = function(plugin) {
      if (!plugin.isEnabled()) return;
      plugin.isEnabled(false);
    };
  }

  var PluginManager;
  PluginManager = function PluginManager(cockpit) {
    console.log('Loading Plugin Manager plugin.');
    this.cockpit = cockpit;
    this.model = new PluginManagerModel();
    var self = this;
    var config = new PluginManagerConfig();

    $('#settings #plugin-settings').append('<div id="plugin-manager-settings"></div>');
    $('#plugin-manager-settings').load('plugin/plugin-manager/settings.html',
      function() {
        cockpit.loadedPlugins.forEach(function (plugin) {
          // TODO: needs to be put into a  wrapping object for cleanliness
          plugin.isEnabled = ko.observable(true);

          plugin.isEnabled.subscribe(function(newIsEnabled) {
            if (!!newIsEnabled == true) { plugin.enable(); }
            else { plugin.disable(); }
            if (!!plugin.config.isEnabled != !!newIsEnabled) {
              plugin.config.isEnabled = !!newIsEnabled;
              config.set(plugin.name, plugin.config);
            }
          });

          if (plugin.canBeDisabled) {
            self.model.controlablePlugins.push(plugin);
            config.get(plugin.name, function(pluginConfig) {
              if (pluginConfig != undefined && pluginConfig.isEnabled != undefined ) {
                plugin.config = pluginConfig;
                plugin.isEnabled(pluginConfig.isEnabled.toBool());
              }
            })
          }
        });
        ko.applyBindings(self.model, document.getElementById("pluginManager-settings"));<commit_msg>Cleanup code<commit_after>(function (window, $, undefined) {
  'use strict';

  String.prototype.toBool = function() {
    switch(this.toLowerCase()) {
      case "false": case "no": case "0": case "":
      return false;
      default: return true;}
  };


  var PluginManagerModel = function PluginManagerModel() {
    var self = this;
    self.controlablePlugins = ko.observableArray();
    self.enablePlugin = function(plugin) {
      if (plugin.isEnabled()) return;
      plugin.isEnabled(true);
    };

    self.disablePlugin = function(plugin) {
      if (!plugin.isEnabled()) return;
      plugin.isEnabled(false);
    };
  }

  var PluginManager;
  PluginManager = function PluginManager(cockpit) {
    console.log('Loading Plugin Manager plugin.');
    this.cockpit = cockpit;
    this.model = new PluginManagerModel();
    var self = this;
    var config = new PluginManagerConfig();

    $('#plugin-settings').append('<div id="plugin-manager-settings"></div>');
    $('#plugin-manager-settings').load('plugin/plugin-manager/settings.html',
      function() {
        cockpit.loadedPlugins.forEach(function (plugin) {
          // TODO: needs to be put into a  wrapping object for cleanliness
          plugin.isEnabled = ko.observable(true);

          plugin.isEnabled.subscribe(function(newIsEnabled) {
            if (newIsEnabled == true) { plugin.enable(); }
            else { plugin.disable(); }

            plugin.config.isEnabled = newIsEnabled.toString();
            config.set(plugin.name, plugin.config);
          });

          if (plugin.canBeDisabled) {
            self.model.controlablePlugins.push(plugin);
            config.get(plugin.name, function(pluginConfig) {
              if (pluginConfig != undefined && pluginConfig.isEnabled != undefined ) {
                plugin.config = pluginConfig;
                plugin.isEnabled(pluginConfig.isEnabled.toBool());
              }
            })
          }
        });
        ko.applyBindings(self.model, document.getElementById("pluginManager-settings"));
{'fraction_non_alphanumeric': 0.1332694151486098, 'fraction_numerical': 0.00047938638542665386, 'mean_word_length': 2.557544757033248, 'pattern_counts': {'":': 8, '<': 7, '<?xml version=': 0, '>': 7, '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': '1780606', 'n_tokens_mistral': 1139, 'n_tokens_neox': 1109, 'n_words': 218}