<commit_before>var app = angular.module('app', []);
app.config(['$locationProvider', function($locationProvider) {
  $locationProvider.html5Mode({
    enabled: true,
    requireBase: false
  });
}]);

app.service('linktoggle', function() {
  this.add = function(elements) {
    var current = this;
    elements.css({
      'cursor': 'pointer'
    }) //
    .on('click', function() {
      current.act(this);
    });
  };
  this.stop = function(num, tag) {
    for (var n = parseInt(num); n >= 1; n--) {
      if (tag == ('H' + n)) { return true; }
    }
    return false;
  };
  this.act = function(htmlElement) {
    var elem = angular.element(htmlElement);
    var tagName = htmlElement.tagName.toUpperCase();
    if (tagName == 'H1') {
      elem.nextAll().show();
      return;
    }
    var current = this;
    var hn = tagName.replace(/^H/, '');
    var all = elem.nextAll();
    var length = all.length;
    for (var i = 0; i < length; i++) {
      var nelem = all.get(i);
      var ntag = nelem.tagName.toUpperCase();
      if (/H\d+/.test(ntag) && current.stop(hn, ntag)) {
        break;
      }
      $(nelem).toggle();
    }
  };
});

app.service('codecss', function() {
  this.link = function(param) {
    return angular.element('<a href="/markdwon/test?html=' //
            + encodeURIComponent(param) //
            + '" target="_blank">测试一下</a>');
  };
  this.add = function(elements) {
    var current = this;
    elements.each(function() {
      if (angular.element(this).hasClass('language-html')) {
        angular.element(this).parent().after(current.link(this.innerHTML));
      }
      // Prism framework to highlight element.
      Prism.highlightElement(this, true);
    });
  };
});

app.service('catalog', function() {
  this.make = function() {
    var html = '<div class="catalog">';
    angular.element('h1, h2, h3, h4, h5, h6').each(function() {
      var cur = angular.element(this);
      var id = cur.attr('id');
      if (id) {
        html += '<' + this.tagName + '>';
        html += '<a href="#' + id + '">' + cur.text() + '</a>';
        html += '</' + this.tagName + '>';
      }
    });
    html += '</div>';
    return html;
  };
});

app.controller('appController', ['$scope', 
  function($scope) {
    $scope.http = {
      url: '/md/html?_=' + new Date().getTime() + '&filePath=' + $scope.file<commit_msg>add panel.<commit_after>var app = angular.module('app', []);
app.config(['$locationProvider', function($locationProvider) {
  $locationProvider.html5Mode({
    enabled: true,
    requireBase: false
  });
}]);

app.service('linktoggle', function() {
  this.add = function(elements) {
    var current = this;
    elements.css({
      'cursor': 'pointer'
    }) //
    .on('click', function() {
      current.act(this);
    });
  };
  this.stop = function(num, tag) {
    for (var n = parseInt(num); n >= 1; n--) {
      if (tag == ('H' + n)) { return true; }
    }
    return false;
  };
  this.act = function(htmlElement) {
    var elem = angular.element(htmlElement);
    var tagName = htmlElement.tagName.toUpperCase();
    if (tagName == 'H1') {
      elem.nextAll().show();
      return;
    }
    var current = this;
    var hn = tagName.replace(/^H/, '');
    var all = elem.nextAll();
    var length = all.length;
    for (var i = 0; i < length; i++) {
      var nelem = all.get(i);
      var ntag = nelem.tagName.toUpperCase();
      if (/H\d+/.test(ntag) && current.stop(hn, ntag)) {
        break;
      }
      $(nelem).toggle();
    }
  };
});

app.service('codecss', function() {
  this.link = function(param) {
    return angular.element('<a href="/markdwon/test?html=' //
            + encodeURIComponent(param) //
            + '" target="_blank">测试一下</a>');
  };
  this.add = function(elements) {
    var current = this;
    elements.each(function() {
      if (angular.element(this).hasClass('language-html')) {
        angular.element(this).parent().after(current.link(this.innerHTML));
      }
      // Prism framework to highlight element.
      Prism.highlightElement(this, true);
    });
  };
});

app.service('catalog', function() {
  this.make = function() {
    var html = '<div class="panel panel-default">';
    html += '  <div class="panel-heading">目录</div>';
    html += '  <div class="panel-body">';
    html += '    <div class="catalog">';
    var hs = angular.element('h1, h2, h3, h4, h5, h6');
    hs.each(function() {
      var cur = angular.element(this);
      var id = cur.attr('id');
      if (id) {
        html += '<' + this.tagName + '>';
        html += '<a href="#' + id + '">' + cur.text() + '</a>';
        html += '</' + this.tagName + '>';
      }
    });
    html += '    </div>';
    html += '  </div>';
    html += '</div>';
    return html;
  };
});

app.controller('appController', ['$scope', 
  function($scope) {
    $scope.http = {
      url: '/md/html?_=' + new Date().getTime() + '&filePath=' + $scope.file
{'fraction_non_alphanumeric': 0.20655270655270655, 'fraction_numerical': 0.00407000407000407, 'mean_word_length': 2.5107142857142857, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, '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': '6651829', 'n_tokens_mistral': 1659, 'n_tokens_neox': 1657, 'n_words': 329}