<commit_before>angular.module('ot.service.event', [

])
    .service('otEventService', function () {

        var self = {};

        self.renderEvent = function (event) {
            return event.template;
        };

        return self;

    })
;<commit_msg>#33 GUI: event rendering (wip)<commit_after>angular.module('ot.service.event', [

])
    .service('otEventService', function ($interpolate) {

        var variableRegex = /\$\{([:a-zA-Z_]+)\}/g;
        var self = {};

        self.renderEvent = function (event) {

            return event.template.replace(
                variableRegex,
                replacementFunction(event)
            );
        };


        function replacementFunction(event) {
            return function (match, expression) {
                if (expression.charAt(0) == ':') {
                    // We want a value
                    var valueKey = expression.substring(1);
                } else {
                    // We want an entity reference
                    var entity = event.entities[expression];
                    if (!entity) {
                        return replacementEntityError(event, expression);
                    }
                    // Link definition
                    var link = {
                        cls: ''
                    };
                    if (expression == 'PROJECT') {
                        link.uri = "#/project/" + entity.id;
                        link.name = entity.name;
                    }
                    // Link rendering
                    return $interpolate('<a href="{{uri}}" class="{{cls}}">{{name}}</a>')(link);
                }
            };
        }

        return self;

    })
;
{'fraction_non_alphanumeric': 0.12668621700879765, 'fraction_numerical': 0.002346041055718475, 'mean_word_length': 1.1787994891443168, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2263747', 'n_tokens_mistral': 434, 'n_tokens_neox': 393, 'n_words': 82}