<commit_before>angular.module('hap').directive('hapControl', HapControl);

HapControl.$inject = ['$http', '$compile'];
function HapControl($http, $compile) {
    var templateCache = {};

    return {
        restrict: 'E',
        bindToController: {
            item: '='
        },
        controller: ControlController,
        controllerAs: "me",
        scope: true,
        link: function (scope, element, attributes, ctrl) {
            var template = templateCache[ctrl.item.type];
            if (!template) templateCache[ctrl.item.type] = template = $http.get('/templates/controls/' + ctrl.item.type +'.html');

            template.then(function (resp) {
                element.html(resp.data);
                $compile(element.contents())(scope);
            });

            ctrl.init();
        }
    };
}

ControlController.$inject = ['WebEvents'];
function ControlController(events) {

    this.buttonClick = function() {
        events.emit('button-click', {
            id: this.item.id
        });
    };

    this.switchChanged = function() {
        events.emit('switch-changed', {<commit_msg>replace hap-control element with the template<commit_after>angular.module('hap').directive('hapControl', HapControl);

HapControl.$inject = ['$http', '$compile'];
function HapControl($http, $compile) {
    var templateCache = {};

    return {
        restrict: 'E',
        bindToController: {
            item: '='
        },
        controller: ControlController,
        controllerAs: "me",
        scope: true,
        link: function (scope, element, attributes, ctrl) {
            var template = templateCache[ctrl.item.type];
            if (!template) {
                template =
                    $http.get('/templates/controls/' + ctrl.item.type +'.html')
                        .then(function(resp) {return resp.data;});
                templateCache[ctrl.item.type] = template;
            }

            template.then(function (html) {
                var newElement = $compile(html)(scope);
                element.replaceWith(newElement);
            });

            ctrl.init();
        }
    };
}

ControlController.$inject = ['WebEvents'];
function ControlController(events) {

    this.buttonClick = function() {
        events.emit('button-click', {
            id: this.item.id
        });
    };

    this.switchChanged = function() {
        events.emit('switch-changed', {
{'fraction_non_alphanumeric': 0.14563508481588747, 'fraction_numerical': 0.0, 'mean_word_length': 2.053030303030303, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4647237', 'n_tokens_mistral': 656, 'n_tokens_neox': 639, 'n_words': 119}