<commit_before>// Original code developed by University of Twente, taken and adapted from:
// http://go-lab.gw.utwente.nl/sources/tools/conceptmap/src/main/webapp/coffee/ConfigDialog0.1.js

(function() {
  "use strict";
  window.ut = window.ut || {};

  window.ut.tools = window.ut.tools || {};

  window.ut.tools.conceptmapper = window.ut.tools.conceptmapper || {};

  window.ut.tools.conceptmapper.ConfigDialog = (function() {
    function ConfigDialog(appName, currentConfiguration, configurationCallback) {
      var $dialogElement, $fieldset, $form,
        _this = this;
      $dialogElement = $(document.body).find("#ut_tools_conceptmapper_ConfigDialog");
      $fieldset = $("<fieldset/>");
      $.each(currentConfiguration, function(id, setting) {
        $input;
        var $input;
        if (setting.type === "boolean") {
          $input = $("<input type='checkbox' name='" + id + "'> " + setting.label + "</input>");
          if (setting.value === "true") {
            $input.attr("checked", "checked");
          }
          $fieldset.append($input);
        } else if (setting.type === "array" || setting.type === "string") {
          $input = $("<input type='text' name='" + id + "'></input>");
          $input.val(setting.value);
          $fieldset.append("<label for='" + id + "'>" + setting.label + "</label>");
          $fieldset.append($input);
        } else {
          $input = $("<input type='text' name='" + id + "'></input>");
          $fieldset.append("<label for='" + id + "'>" + setting.label + "</label>");
          $fieldset.append($input);
        }
        $input.attr("title", "" + setting.description + ".");
        if (setting.configurable === "false") {
          $input.attr("readonly", true);
        }
        return $fieldset.append("<br/>");
      });
      $form = $("<form/>");
      $form.append($fieldset);
      $form.submit(function() { event.preventDefault(); });
      $dialogElement.append($form);
      var $saveBtn = $("<button class='btn'>{{ gettext("Save") }}</button>");
      $saveBtn.click(function() {
            $.each(currentConfiguration, function(id, settings) {
              if (settings.type === "boolean") {
                $fieldset.find("input[name='" + id + "']").each(function(index, input) {
                  return currentConfiguration["" + id].value = $(input).is(':checked').toString();
                });
              }
              if (settings.type === "array") {
                $fieldset.find("input[name='" + id + "']").each(function(index, input) {
                  return currentConfiguration["" + id].value = $(input).val().split(",");
                });
              }
              if (settings.type === "string") {
                return $fieldset.find("input[name='" + id + "']").each(function(index, input) {
                  return currentConfiguration["" + id].value = $(input).val();
                });
              }
            });
            configurationCallback({ 'appName' : appName, 'config' : currentConfiguration });
          });
      $dialogElement.append($saveBtn);
    };

    return ConfigDialog;

  })();

  var keys = [];
  for(var k in window.golab.tools.configurationDefinition) keys.push(k);
  var appName = keys[0];
  var config = window.golab.tools.configurationDefinition[appName];
  
  new window.ut.tools.conceptmapper.ConfigDialog(appName, config, golabConfigurationSavedCallback);
}).call(this);

/*<commit_msg>Improve ConfigDialog to support bootstrap<commit_after>// Original code developed by University of Twente, taken and adapted from:
// http://go-lab.gw.utwente.nl/sources/tools/conceptmap/src/main/webapp/coffee/ConfigDialog0.1.js

(function() {
  "use strict";
  window.ut = window.ut || {};

  window.ut.tools = window.ut.tools || {};

  window.ut.tools.conceptmapper = window.ut.tools.conceptmapper || {};

  window.ut.tools.conceptmapper.ConfigDialog = (function() {
    function ConfigDialog(appName, currentConfiguration, configurationCallback) {
      var $dialogElement, $fieldset, $form,
        _this = this;
      $dialogElement = $(document.body).find("#ut_tools_conceptmapper_ConfigDialog");
      $form = $("<form class='form-horizontal' role='form'/>");

      $.each(currentConfiguration, function(id, setting) {
        var $current_line = $("<div class='form-group'></div>");

        var $input;
        if (setting.type === "boolean") {
          var $current_container = $("<div class='col-sm-offset-2 col-sm-10'><div class='checkbox'><label></label></div></div>");
          $input = $("<input type='checkbox' name='" + id + "'> " + setting.label + "</input>");
          $current_container.find("label").append($input);

          if (setting.description) {
            $current_container.append("<span class='help-block''>" + setting.description + "</span>");
          }
          if (setting.value === "true") {
            $input.attr("checked", "checked");
          }
          $current_line.append($current_container);
        } else if (setting.type === "array" || setting.type === "string") {
          var $current_label = $("<label for='" + id + "' class='col-sm-2 control-label'>" + setting.label + "</label>");
          var $current_container = $("<div class='col-sm-10'></div>");
          $input = $("<input type='text' name='" + id + "' size='50'></input>");
          $input.val(setting.value);
          $current_container.append($input);
          $current_line.append($current_label);
          if (setting.description) {
            $current_container.append("<span class='help-block''>" + setting.description + "</span>");
          }

          $current_line.append($current_container);
        } else {
          var $current_label = $("<label for='" + id + "' class='col-sm-2 control-label'>" + setting.label + "</label>");
          var $current_container = $("<div class='col-sm-10'></div>");
          $input = $("<input type='text' name='" + id + "'></input>");
          $input.val(setting.value);
          $current_container.append($input);
          $current_line.append($current_label);
          if (setting.description) {
            $current_container.append("<span class='help-block''>" + setting.description + "</span>");
          }

          $current_line.append($current_container);
        }
        $input.attr("title", "" + setting.description + ".");
        if (setting.configurable === "false") {
          $input.attr("readonly", true);
        }
        $form.append($current_line);
      });
      $form.submit(function() { event.preventDefault(); });
      $dialogElement.append($form);
      var $saveBtn = $("<button class='btn'>{{ gettext("Save") }}</button>");
      $saveBtn.click(function() {
            $.each(currentConfiguration, function(id, settings) {
              if (settings.type === "boolean") {
                $form.find("input[name='" + id + "']").each(function(index, input) {
                  return currentConfiguration["" + id].value = $(input).is(':checked').toString();
                });
              }
              if (settings.type === "array") {
                $form.find("input[name='" + id + "']").each(function(index, input) {
                  return currentConfiguration["" + id].value = $(input).val().split(",");
                });
              }
              if (settings.type === "string") {
                return $form.find("input[name='" + id + "']").each(function(index, input) {
                  return currentConfiguration["" + id].value = $(input).val();
                });
              }
            });
            configurationCallback({ 'appName' : appName, 'config' : currentConfiguration });
          });
      $dialogElement.append($saveBtn);
    };

    return ConfigDialog;

  })();

  var keys = [];
  for(var k in window.golab.tools.configurationDefinition) keys.push(k);
  var appName = keys[0];
  var config = window.golab.tools.configurationDefinition[appName];
  
  new window.ut.tools.conceptmapper.ConfigDialog(appName, config, golabConfigurationSavedCallback);
}).call(this);

/*
{'fraction_non_alphanumeric': 0.1909473163492456, 'fraction_numerical': 0.0021023992085085334, 'mean_word_length': 2.5130321459600347, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 49, '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': '3831971', 'n_tokens_mistral': 2343, 'n_tokens_neox': 2287, 'n_words': 405}