<commit_before>// bootstrap plugin loader
var jolokiaUrl = hawtioPluginLoader.parseQueryString()['url'] || "/hawtio/jolokia";

hawtioPluginLoader.addUrl("jolokia:" + jolokiaUrl + ":hawtio:type=plugin,name=*");
hawtioPluginLoader.addUrl('/hawtio/test.json');

interface IMyAppScope extends ng.IRootScopeService, ng.IScope {
  lineCount: (value:any) => number;
  params: ng.IRouteParamsService;
  is: (type:any, value:any) => bool;
  empty: (value:any) => bool;
  log: (variable:string) => void;
  alert: (text:string) => void;
}

var myApp = angular.module('hawtioCore', ['bootstrap', 'ngResource', 'ui']);

hawtioPluginLoader.addModule('hawtioCore');

myApp.config(($routeProvider) => {
  $routeProvider.
          when('/preferences', {templateUrl: 'app/core/html/preferences.html'}).
          when('/help', {
            redirectTo: '/help/overview'
          }).
          when('/help/:tabName', {templateUrl: 'app/core/html/help.html'}).

          otherwise({redirectTo: '/help/overview'});
});

myApp.service('localStorage', function () {
  // TODO Create correct implementation of windowLocalStorage
  var storage:WindowLocalStorage = window.localStorage || <any> (function () {
    return {};
  })();
  return storage;
});

myApp.factory('jolokia', ($location:ng.ILocationService, localStorage) => {
  var jolokiaUrl = $location.search()['url'] || url("/jolokia");
  // console.log("Jolokia URL is " + jolokiaUrl);
  var jolokia = new Jolokia(jolokiaUrl);
  localStorage['url'] = jolokiaUrl;
  return jolokia;
});

myApp.factory('workspace', ($location:ng.ILocationService, $compile:ng.ICompileService, $templateCache:ng.ITemplateCacheService, localStorage:WindowLocalStorage, jolokia, $rootScope) => {
  var answer = new Workspace(jolokia, $location, $compile, $templateCache, localStorage, $rootScope);
  answer.loadTree();
  return answer;
});


myApp.filter('humanize', () => humanizeValue)


myApp.run(($rootScope, $routeParams, jolokia, workspace, localStorage, viewRegistry, layoutFull) => {

  $.support.cors = true;

  /**
   * Count the number of lines in the given text
   */
  $rootScope.lineCount = lineCount;

  /**
   * Easy access to route params
   */
  $rootScope.params = $routeParams;

  /**
   * Wrapper for angular.isArray, isObject, etc checks for use in the view
   *
   * @param type {string} the name of the check (casing sensitive)
   * @param value {string} value to check
   */
  $rootScope.is = function (type:any, value:any):bool {
    return angular['is' + type](value);
  };

  /**
   * Wrapper for $.isEmptyObject()
   *
   * @param value  {mixed} Value to be tested
   * @return boolean
   */
  $rootScope.empty = function (value:any):bool {
    return $.isEmptyObject(value);
  };

  /**
   * Initialize jolokia polling and add handler to change poll
   * frequency
   */
  // only reset the update rate if its not defined
  var updateRate = localStorage['updateRate'];
  if (angular.isUndefined(updateRate)) {
    localStorage['updateRate'] = 5000;
  }

  $rootScope.$on('UpdateRate', (event, rate) => {
    jolokia.stop();
    if (rate > 0) {
      jolokia.start(rate);
    }
    console.log("Set update rate to: " + rate);
  });

  $rootScope.$emit('UpdateRate', localStorage['updateRate']);

  /**
   * Debugging Tools
   *
   * Allows you to execute debug functions from the view
   */
    // TODO Doesn't support vargs like it should
  $rootScope.log = function (variable:any):void {
    console.log(variable);
  };
  $rootScope.alert = function (text:string) {
    alert(text);
  };

  viewRegistry['fullscreen'] = layoutFull;
  viewRegistry['notree'] = layoutFull;
  viewRegistry['help'] = layoutFull;
  viewRegistry['preferences'] = layoutFull;

});


myApp.directive('expandable', function () {
  return {
    restrict: 'C',
    replace: false,
    link: function (scope, element, attrs) {
      var expandable = $(element);

      var title = expandable.find('.title');
      var button = expandable.find('.cancel');

      button.bind('click', function () {
        expandable.addClass('closed');
        expandable.removeClass('opened');
        return false;
      });

      title.bind('click', function () {
        expandable.toggleClass('opened');
        expandable.toggleClass('closed');
        return false;
      });
    }
  }
});

myApp.constant('editablePropertyTemplate',
    '<div ng-mouseenter="showEdit()" ng-mouseleave="hideEdit()" class="ep" ng-hide="editing">' +
      '{{text}}&nbsp;<i class="ep-edit icon-pencil" title="Edit this item" ng-click="doEdit()"></i>' +
    '</div>' +
    '<div class="ep" ng-show="editing">' +
      '<form class="form-inline no-bottom-margin">' +
        '<fieldset>' +
          '<input type="text" value="{{text}}">' +
          '<i class="red icon-remove" title="Discard changes" ng-click="stopEdit()"></i>' +
          '<i class="green icon-ok" title="Save changes" ng-click="saveEdit()"></i>' +<commit_msg>Put the cross after the tick<commit_after>// bootstrap plugin loader
var jolokiaUrl = hawtioPluginLoader.parseQueryString()['url'] || "/hawtio/jolokia";

hawtioPluginLoader.addUrl("jolokia:" + jolokiaUrl + ":hawtio:type=plugin,name=*");
hawtioPluginLoader.addUrl('/hawtio/test.json');

interface IMyAppScope extends ng.IRootScopeService, ng.IScope {
  lineCount: (value:any) => number;
  params: ng.IRouteParamsService;
  is: (type:any, value:any) => bool;
  empty: (value:any) => bool;
  log: (variable:string) => void;
  alert: (text:string) => void;
}

var myApp = angular.module('hawtioCore', ['bootstrap', 'ngResource', 'ui']);

hawtioPluginLoader.addModule('hawtioCore');

myApp.config(($routeProvider) => {
  $routeProvider.
          when('/preferences', {templateUrl: 'app/core/html/preferences.html'}).
          when('/help', {
            redirectTo: '/help/overview'
          }).
          when('/help/:tabName', {templateUrl: 'app/core/html/help.html'}).

          otherwise({redirectTo: '/help/overview'});
});

myApp.service('localStorage', function () {
  // TODO Create correct implementation of windowLocalStorage
  var storage:WindowLocalStorage = window.localStorage || <any> (function () {
    return {};
  })();
  return storage;
});

myApp.factory('jolokia', ($location:ng.ILocationService, localStorage) => {
  var jolokiaUrl = $location.search()['url'] || url("/jolokia");
  // console.log("Jolokia URL is " + jolokiaUrl);
  var jolokia = new Jolokia(jolokiaUrl);
  localStorage['url'] = jolokiaUrl;
  return jolokia;
});

myApp.factory('workspace', ($location:ng.ILocationService, $compile:ng.ICompileService, $templateCache:ng.ITemplateCacheService, localStorage:WindowLocalStorage, jolokia, $rootScope) => {
  var answer = new Workspace(jolokia, $location, $compile, $templateCache, localStorage, $rootScope);
  answer.loadTree();
  return answer;
});


myApp.filter('humanize', () => humanizeValue)


myApp.run(($rootScope, $routeParams, jolokia, workspace, localStorage, viewRegistry, layoutFull) => {

  $.support.cors = true;

  /**
   * Count the number of lines in the given text
   */
  $rootScope.lineCount = lineCount;

  /**
   * Easy access to route params
   */
  $rootScope.params = $routeParams;

  /**
   * Wrapper for angular.isArray, isObject, etc checks for use in the view
   *
   * @param type {string} the name of the check (casing sensitive)
   * @param value {string} value to check
   */
  $rootScope.is = function (type:any, value:any):bool {
    return angular['is' + type](value);
  };

  /**
   * Wrapper for $.isEmptyObject()
   *
   * @param value  {mixed} Value to be tested
   * @return boolean
   */
  $rootScope.empty = function (value:any):bool {
    return $.isEmptyObject(value);
  };

  /**
   * Initialize jolokia polling and add handler to change poll
   * frequency
   */
  // only reset the update rate if its not defined
  var updateRate = localStorage['updateRate'];
  if (angular.isUndefined(updateRate)) {
    localStorage['updateRate'] = 5000;
  }

  $rootScope.$on('UpdateRate', (event, rate) => {
    jolokia.stop();
    if (rate > 0) {
      jolokia.start(rate);
    }
    console.log("Set update rate to: " + rate);
  });

  $rootScope.$emit('UpdateRate', localStorage['updateRate']);

  /**
   * Debugging Tools
   *
   * Allows you to execute debug functions from the view
   */
    // TODO Doesn't support vargs like it should
  $rootScope.log = function (variable:any):void {
    console.log(variable);
  };
  $rootScope.alert = function (text:string) {
    alert(text);
  };

  viewRegistry['fullscreen'] = layoutFull;
  viewRegistry['notree'] = layoutFull;
  viewRegistry['help'] = layoutFull;
  viewRegistry['preferences'] = layoutFull;

});


myApp.directive('expandable', function () {
  return {
    restrict: 'C',
    replace: false,
    link: function (scope, element, attrs) {
      var expandable = $(element);

      var title = expandable.find('.title');
      var button = expandable.find('.cancel');

      button.bind('click', function () {
        expandable.addClass('closed');
        expandable.removeClass('opened');
        return false;
      });

      title.bind('click', function () {
        expandable.toggleClass('opened');
        expandable.toggleClass('closed');
        return false;
      });
    }
  }
});

myApp.constant('editablePropertyTemplate',
    '<div ng-mouseenter="showEdit()" ng-mouseleave="hideEdit()" class="ep" ng-hide="editing">' +
      '{{text}}&nbsp;<i class="ep-edit icon-pencil" title="Edit this item" ng-click="doEdit()"></i>' +
    '</div>' +
    '<div class="ep" ng-show="editing">' +
      '<form class="form-inline no-bottom-margin">' +
        '<fieldset>' +
          '<input type="text" value="{{text}}">' +
          '<i class="green icon-ok" title="Save changes" ng-click="saveEdit()"></i>' +
          '<i class="red icon-remove" title="Discard changes" ng-click="stopEdit()"></i>' +
{'fraction_non_alphanumeric': 0.16807063838424846, 'fraction_numerical': 0.0010149193139145439, 'mean_word_length': 3.661305581835383, 'pattern_counts': {'":': 2, '<': 29, '<?xml version=': 0, '>': 53, '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': '2008401', 'n_tokens_mistral': 3192, 'n_tokens_neox': 3113, 'n_words': 671}