<commit_before>this.Syntax_Checker = (function () {
  function ResultBox(form) {
    this.$el = null;
    this.$elBody = null;
    this.form = form;
  }

  ResultBox.prototype.init = function() {
    if (this.$el) {
      return this;
    }

    var $div = $("#errorSyntaxChecker");
    if ($div[0]) {
      this.$el = $div;
      this.$elBody = $div.find(".errorExplanationBody");

      return this.moveLast();
    }

    $div = $("<div/>", { id: 'errorSyntaxChecker', class: 'errorExplanation' });
    $div.append("<h2>" + "<%= I18n.t('cms.syntax_check') %>" + "</h2>");

    var $body = $("<div/>", { class: 'errorExplanationBody' });
    $div.append($body);

    this.$el = $div;
    this.$elBody = $body;

    return this.moveLast();
  };

  ResultBox.prototype.moveLast = function() {
    $(this.form.addonSelector).append(this.$el);
    return this;
  };

  ResultBox.prototype.showMessage = function(message) {
    this.init();
    this.$elBody.html(message);
    this.moveLast();
    return this;
  }

  ResultBox.prototype.showChecking = function() {
    return this.showMessage(SS.loading);
  };

  ResultBox.prototype.showResult = function (checks, errors) {
    if (errors.length == 0) {
      this.showMessage("<p>" + "<%= I18n.t('errors.template.no_errors') %>" + "</p>");
      return;
    }

    this.init();

    var ul = $("<ul/>");

    this.appendMessage(ul, checks, errors);

    this.$elBody.html("")
    this.$elBody.append("<p>" + "<%= I18n.t('errors.template.body') %>" + "</p>");
    this.$elBody.append(ul);

    this.moveLast();
    SS_Tooltips.render(".detail");

    $(window).trigger('resize');

    return this;
  };

  ResultBox.prototype.appendMessage = function (ul, checks, errors) {
    var results, self;
    var correct, detail, li, message, code, column;

    results = [];
    self = this;

    var errorHash = {};

    $.each(errors, function(_, error) {
      var id = error["id"];
      errorHash[id] = errorHash[id] || [];
      (errorHash[id]).push(error);
    });

    $.each(checks, function(id, check) {
      errors = errorHash[id];

      if (errors) {
        // append column name
        if (check["name"]) {
          column = $('<li class="column-name">');
          column.text(check["name"]);
          ul.append(column);
        }

        $.each(errors, function(_, error) {
          // append code
          code = $('<code>')
          code.text(error["code"]);
          ul.append('<li class="code">');
          ul.find('li:last').append(code);

          // append message
          ul.append('<ul>');
          ul.find('> ul:last').append('<li>');
          li = ul.find('> ul:last li:last');
          message = $('<span class="message detail">' + error["msg"] + '</span>');
          if (error["detail"]) {
            detail = $('<ul>').appendTo(message);
            $.each(error["detail"], function () {
              detail.append("<li>" + this + "</li>");
              detail.hide();
            });
          }
          li.append(message);

          // append correct
          if (error["correctContent"]) {
            correct = $('<a href="#" class="correct">' + "<%= I18n.t('cms.auto_correct.link') %>" + '</a>');
            correct.on("click", function (e) {
              var setContent, getContent, correctContent, type;

              correctContent = error["correctContent"];
              setContent = check["setContent"];
              getContent = check["getContent"];
              type = check["type"];

              setContent(correctContent(id, { content: getContent(), type: type }, error));
              $(self.form.addonSelector).find("button.syntax-check").trigger("click");

              return false;
            });
            li.append(correct)
          }
        });
      }
    });

    return;
  };

  function Syntax_Checker() {};

  Syntax_Checker.checks = {};
  Syntax_Checker.errors = [];
  Syntax_Checker.errorCount = 0;

  Syntax_Checker.form = null;
  Syntax_Checker.resultBox = null;
  Syntax_Checker.afterCheck = null;

  Syntax_Checker.render = function (form, options) {
    form = form || Cms_Form
    options = options || {};

    Syntax_Checker.form = form;
    Syntax_Checker.options = options;
    Syntax_Checker.resultBox = new ResultBox(Syntax_Checker.form);
    Syntax_Checker.afterCheck = options["afterCheck"];

    $(document).on("click", "button.syntax-check", function () {
      var button = this;
      button.disabled = true;

      var complete = function () {
        button.disabled = false;
      };

      Syntax_Checker.resultBox.init();
      Syntax_Checker.resultBox.showChecking();
      Syntax_Checker.asyncCheck().done(complete).fail(complete);
    });
  };

  Syntax_Checker.asyncCheck = function () {
    var defer = $.Deferred();

    var resolve = function() {

      try {
        Syntax_Checker.check();
        Syntax_Checker.resultBox.showResult(Syntax_Checker.checks, Syntax_Checker.errors);
        defer.resolve({ status: Syntax_Checker.errors.length == 0 ? "ok" : "failed" });
      } catch (e) {
        Syntax_Checker.resultBox.showMessage("<p>" + e + "</p>");
        defer.reject(null, null, error);
      }
    };

    resolve();

    return defer.promise();
  };

  Syntax_Checker.addCheck = function (id, options) {
    options = options || {};

    var name = options["name"] || null;<commit_msg>[fix] accessibility check error with no word dictionaries (#2598)<commit_after>this.Syntax_Checker = (function () {
  function ResultBox(form) {
    this.$el = null;
    this.$elBody = null;
    this.form = form;
  }

  ResultBox.prototype.init = function() {
    if (this.$el) {
      return this;
    }

    var $div = $("#errorSyntaxChecker");
    if ($div[0]) {
      this.$el = $div;
      this.$elBody = $div.find(".errorExplanationBody");

      return this.moveLast();
    }

    $div = $("<div/>", { id: 'errorSyntaxChecker', class: 'errorExplanation' });
    $div.append("<h2>" + "<%= I18n.t('cms.syntax_check') %>" + "</h2>");

    var $body = $("<div/>", { class: 'errorExplanationBody' });
    $div.append($body);

    this.$el = $div;
    this.$elBody = $body;

    return this.moveLast();
  };

  ResultBox.prototype.moveLast = function() {
    $(this.form.addonSelector).append(this.$el);
    return this;
  };

  ResultBox.prototype.showMessage = function(message) {
    this.init();
    this.$elBody.html(message);
    this.moveLast();
    return this;
  }

  ResultBox.prototype.showChecking = function() {
    return this.showMessage(SS.loading);
  };

  ResultBox.prototype.showResult = function (checks, errors) {
    if (errors.length == 0) {
      this.showMessage("<p>" + "<%= I18n.t('errors.template.no_errors') %>" + "</p>");
      return;
    }

    this.init();

    var ul = $("<ul/>");

    this.appendMessage(ul, checks, errors);

    this.$elBody.html("")
    this.$elBody.append("<p>" + "<%= I18n.t('errors.template.body') %>" + "</p>");
    this.$elBody.append(ul);

    this.moveLast();
    SS_Tooltips.render(".detail");

    $(window).trigger('resize');

    return this;
  };

  ResultBox.prototype.appendMessage = function (ul, checks, errors) {
    var results, self;
    var correct, detail, li, message, code, column;

    results = [];
    self = this;

    var errorHash = {};

    $.each(errors, function(_, error) {
      var id = error["id"];
      errorHash[id] = errorHash[id] || [];
      (errorHash[id]).push(error);
    });

    $.each(checks, function(id, check) {
      errors = errorHash[id];

      if (errors) {
        // append column name
        if (check["name"]) {
          column = $('<li class="column-name">');
          column.text(check["name"]);
          ul.append(column);
        }

        $.each(errors, function(_, error) {
          // append code
          code = $('<code>')
          code.text(error["code"]);
          ul.append('<li class="code">');
          ul.find('li:last').append(code);

          // append message
          ul.append('<ul>');
          ul.find('> ul:last').append('<li>');
          li = ul.find('> ul:last li:last');
          message = $('<span class="message detail">' + error["msg"] + '</span>');
          if (error["detail"]) {
            detail = $('<ul>').appendTo(message);
            $.each(error["detail"], function () {
              detail.append("<li>" + this + "</li>");
              detail.hide();
            });
          }
          li.append(message);

          // append correct
          if (error["correctContent"]) {
            correct = $('<a href="#" class="correct">' + "<%= I18n.t('cms.auto_correct.link') %>" + '</a>');
            correct.on("click", function (e) {
              var setContent, getContent, correctContent, type;

              correctContent = error["correctContent"];
              setContent = check["setContent"];
              getContent = check["getContent"];
              type = check["type"];

              setContent(correctContent(id, { content: getContent(), type: type }, error));
              $(self.form.addonSelector).find("button.syntax-check").trigger("click");

              return false;
            });
            li.append(correct)
          }
        });
      }
    });

    return;
  };

  function Syntax_Checker() {};

  Syntax_Checker.checks = {};
  Syntax_Checker.errors = [];
  Syntax_Checker.errorCount = 0;

  Syntax_Checker.form = null;
  Syntax_Checker.resultBox = null;
  Syntax_Checker.afterCheck = null;

  Syntax_Checker.render = function (form, options) {
    form = form || Cms_Form
    options = options || {};

    Syntax_Checker.form = form;
    Syntax_Checker.options = options;
    Syntax_Checker.resultBox = new ResultBox(Syntax_Checker.form);
    Syntax_Checker.afterCheck = options["afterCheck"];

    $(document).on("click", "button.syntax-check", function () {
      var button = this;
      button.disabled = true;

      var complete = function () {
        button.disabled = false;
      };

      Syntax_Checker.resultBox.init();
      Syntax_Checker.resultBox.showChecking();
      Syntax_Checker.asyncCheck().done(complete).fail(complete);
    });
  };

  Syntax_Checker.config = {};

  Syntax_Checker.asyncCheck = function () {
    var defer = $.Deferred();

    var resolve = function() {

      try {
        Syntax_Checker.check();
        Syntax_Checker.resultBox.showResult(Syntax_Checker.checks, Syntax_Checker.errors);
        defer.resolve({ status: Syntax_Checker.errors.length == 0 ? "ok" : "failed" });
      } catch (e) {
        Syntax_Checker.resultBox.showMessage("<p>" + e + "</p>");
        defer.reject(null, null, e);
      }
    };

    resolve();

    return defer.promise();
  };

  Syntax_Checker.addCheck = function (id, options) {
    options = options || {};

    var name = options["name"] || null;
{'fraction_non_alphanumeric': 0.1807084065476741, 'fraction_numerical': 0.002959400721353926, 'mean_word_length': 2.411356466876972, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 61, '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': '1211535', 'n_tokens_mistral': 3415, 'n_tokens_neox': 3275, 'n_words': 602}