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

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

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

      return this.moveLast();
    }

    $div = $("<div/>", { id: 'errorMobileChecker', class: 'errorExplanation' });
    $div.append("<h2>" + Mobile_Size_Checker.message["header"] + "</h2>");

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

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

    return this.moveLast();
  };

  ResultBox.prototype.moveLast = function() {
    $(Cms_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 () {
    if (Mobile_Size_Checker.error.length === 0) {
      return this.showMessage("<p>" + Mobile_Size_Checker.message["mobile_check"] + "</p>");
    }

    var ref = Mobile_Size_Checker.error;
    this.$elBody.html('');
    for (var j = 0, len = ref.length; j < len; j++) {
      var err = ref[j];
      this.$elBody.append('<p class="error">' + err + '</p>');
    }

    return this.moveLast();
  };

  function Mobile_Size_Checker() {
  }

  Mobile_Size_Checker.message = {
    header: "<%= I18n.t('cms.mobile_size_check') %>",
    body: "",
    success: "<%= I18n.t('errors.messages.mobile_size_check_success') %>",
    failure: "<%= I18n.t('errors.messages.mobile_size_check_failure') %>",
    mobile_disable: "<%= I18n.t('errors.messages.mobile_size_check_disable') %>",
    mobile_check: "<%= I18n.t('errors.messages.mobile_size_check_size') %>",
    SizeCheckServerError: "<%= I18n.t('errors.messages.mobile_size_check_server_error') %>"
  };

  Mobile_Size_Checker.error = [];

  Mobile_Size_Checker.url = "/.cms/mobile_size_check/check.json";

  Mobile_Size_Checker.rootUrl = "";

  Mobile_Size_Checker.imgs = [];

  Mobile_Size_Checker.hostFullUrl = "";

  Mobile_Size_Checker.resultBox = new ResultBox();

  Mobile_Size_Checker.render = function () {
    return $(document).on("click", "button.mobile-size-check", function () {

      if (!Mobile_Size_Checker.enabled) {
        Mobile_Size_Checker.resultBox.showMessage("<p>" + Mobile_Size_Checker.message["mobile_disable"] + "</p>");
        return;
      }

      var button = this;
      button.disabled = true;

      Mobile_Size_Checker.resultBox.showChecking();
      Mobile_Size_Checker.reset();

      var resolved = function(html) {
        Mobile_Size_Checker.check(html, function () {
          Mobile_Size_Checker.resultBox.showResult();
          button.disabled = false;
        });
      };

      var rejected = function(xhr, status, error) {
        Mobile_Size_Checker.resultBox.showMessage("<p>" + Mobile_Size_Checker.message["SizeCheckServerError"] + "</p>");
        button.disabled = false;
      }

      Cms_Form.getHtml(resolved, rejected);
    });
  };

  Mobile_Size_Checker.reset = function () {
    this.message["body"] = "";
    this.imgs = {};
    this.error = "";
  };

  Mobile_Size_Checker.get_str_byte = function (str) {
    var ESCAPECHAR, ESCAPEDLEN_TABLE, char, i, size;
    ESCAPECHAR = ";,/?:@&=+$ ";
    ESCAPEDLEN_TABLE = [0, 1, 1, 1, 2, 3, 2, 3, 4, 3];
    size = 0;
    if (str === null || str === "") {
      return size;
    }
    for (i in str) {
      char = str[i];
      if (ESCAPECHAR.indexOf(char) >= 0) {
        size++;
      } else {
        size += ESCAPEDLEN_TABLE[encodeURI(char).length];
      }
    }
    return size;
  };

  Mobile_Size_Checker.check = function (html, complete) {
    var err_str, imgs, isThumb, j, len, mobile_size, numOfImage, ref, size, src, str_id, str_src;
    mobile_size = Mobile_Size_Checker.mobile_size;
    size = Mobile_Size_Checker.get_str_byte(html);
    if (mobile_size < size) {
      err_str = "<p class=\"error\">";
      err_str += Mobile_Size_Checker.message["SizeCheckError"];
      err_str += "(本文サイズ：" + (parseInt(size / 1024)) + "KB)";
      err_str += "</p>";
      Mobile_Size_Checker.error = [err_str];
      complete();
      return;<commit_msg>[fix] Mobile_Size_Checker.get_str_byte : encodeURI faild (#3802)<commit_after>this.Mobile_Size_Checker = (function () {
  function ResultBox() {
    this.$el = null;
    this.$elBody = null;
  }

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

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

      return this.moveLast();
    }

    $div = $("<div/>", { id: 'errorMobileChecker', class: 'errorExplanation' });
    $div.append("<h2>" + Mobile_Size_Checker.message["header"] + "</h2>");

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

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

    return this.moveLast();
  };

  ResultBox.prototype.moveLast = function() {
    $(Cms_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 () {
    if (Mobile_Size_Checker.error.length === 0) {
      return this.showMessage("<p>" + Mobile_Size_Checker.message["mobile_check"] + "</p>");
    }

    var ref = Mobile_Size_Checker.error;
    this.$elBody.html('');
    for (var j = 0, len = ref.length; j < len; j++) {
      var err = ref[j];
      this.$elBody.append('<p class="error">' + err + '</p>');
    }

    return this.moveLast();
  };

  function Mobile_Size_Checker() {
  }

  Mobile_Size_Checker.message = {
    header: "<%= I18n.t('cms.mobile_size_check') %>",
    body: "",
    success: "<%= I18n.t('errors.messages.mobile_size_check_success') %>",
    failure: "<%= I18n.t('errors.messages.mobile_size_check_failure') %>",
    mobile_disable: "<%= I18n.t('errors.messages.mobile_size_check_disable') %>",
    mobile_check: "<%= I18n.t('errors.messages.mobile_size_check_size') %>",
    SizeCheckServerError: "<%= I18n.t('errors.messages.mobile_size_check_server_error') %>"
  };

  Mobile_Size_Checker.error = [];

  Mobile_Size_Checker.url = "/.cms/mobile_size_check/check.json";

  Mobile_Size_Checker.rootUrl = "";

  Mobile_Size_Checker.imgs = [];

  Mobile_Size_Checker.hostFullUrl = "";

  Mobile_Size_Checker.resultBox = new ResultBox();

  Mobile_Size_Checker.render = function () {
    return $(document).on("click", "button.mobile-size-check", function () {

      if (!Mobile_Size_Checker.enabled) {
        Mobile_Size_Checker.resultBox.showMessage("<p>" + Mobile_Size_Checker.message["mobile_disable"] + "</p>");
        return;
      }

      var button = this;
      button.disabled = true;

      Mobile_Size_Checker.resultBox.showChecking();
      Mobile_Size_Checker.reset();

      var resolved = function(html) {
        Mobile_Size_Checker.check(html, function () {
          Mobile_Size_Checker.resultBox.showResult();
          button.disabled = false;
        });
      };

      var rejected = function(xhr, status, error) {
        Mobile_Size_Checker.resultBox.showMessage("<p>" + Mobile_Size_Checker.message["SizeCheckServerError"] + "</p>");
        button.disabled = false;
      }

      Cms_Form.getHtml(resolved, rejected);
    });
  };

  Mobile_Size_Checker.reset = function () {
    this.message["body"] = "";
    this.imgs = {};
    this.error = "";
  };

  Mobile_Size_Checker.get_str_byte = function (str) {
    var ESCAPECHAR, ESCAPEDLEN_TABLE, char, i, size;
    ESCAPECHAR = ";,/?:@&=+$ ";
    ESCAPEDLEN_TABLE = [0, 1, 1, 1, 2, 3, 2, 3, 4, 3];
    size = 0;
    if (str === null || str === "") {
      return size;
    }
    for (i in str) {
      char = str[i];
      if (ESCAPECHAR.indexOf(char) >= 0) {
        size++;
      } else {
        try {
          size += ESCAPEDLEN_TABLE[encodeURI(char).length];
        } catch (e) {
          console.error("Mobile_Size_Checker.get_str_byte failed : " + e);
        }
      }
    }
    return size;
  };

  Mobile_Size_Checker.check = function (html, complete) {
    var err_str, imgs, isThumb, j, len, mobile_size, numOfImage, ref, size, src, str_id, str_src;
    mobile_size = Mobile_Size_Checker.mobile_size;
    size = Mobile_Size_Checker.get_str_byte(html);
    if (mobile_size < size) {
      err_str = "<p class=\"error\">";
      err_str += Mobile_Size_Checker.message["SizeCheckError"];
      err_str += "(本文サイズ：" + (parseInt(size / 1024)) + "KB)";
      err_str += "</p>";
      Mobile_Size_Checker.error = [err_str];
      complete();
      return;
{'fraction_non_alphanumeric': 0.16997354497354497, 'fraction_numerical': 0.007716049382716049, 'mean_word_length': 3.0686098654708522, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 45, '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': '3831344', 'n_tokens_mistral': 3164, 'n_tokens_neox': 3073, 'n_words': 501}