<commit_before>/* global angular */
/* global Intl */
/* global $ */

angular.module('quassel')
.directive('input', function ($parse) {
    return {
        restrict: 'E',
        require: '?ngModel',
        link: function (scope, element, attrs) {
            if (attrs.ngModel && attrs.value) {
                $parse(attrs.ngModel).assign(scope, attrs.value);
            }
        }
    };
})
.directive('colorpicker', ['$mirc', function($mirc) {
    return {
        restrict: 'E',
        transclude: true,
        scope: {},
        require: '?colopickerMode',
        template: '<span ng-transclude></span>' +
        '<ul class="colors">' +
            '<li ng-repeat="color in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]">' +
                '<button type="button" class="btn btn-xs mirc-bg-{{color}}" ng-click="setColor(color)"></button>' +
            '</li>' +
        '</ul>',
        link: function (scope, element, attrs) {
            var mode = null;
            if (attrs.colopickerMode == 'foreColor' || attrs.colopickerMode == 'backColor') {
                mode = attrs.colopickerMode;
            } else {
                return;
            }

            scope.setColor = function(colorInd) {
                var color = $mirc.getColorByMIRCInd(colorInd);
                document.execCommand(mode, false, color);
            };
        }
    };
}])
.directive('ircMessage', ['$filter', '$parse', '$compile', '$sanitize', function($filter, $parse, $compile){

    var MT = require('message').Type;
    var dateFormat;
    if (typeof Intl != "undefined" && Intl.DateTimeFormat) {
        dateFormat = new Intl.DateTimeFormat(undefined, {weekday: "long", year: "numeric", month: "long", day: "numeric"});
    } else {
        dateFormat = {
            format: function(date) {
                return date.toDateString();
            }
        };
    }

    function nickplaceholder(sender) {
        var nickhash = $filter('hash')(sender);
        sender = sender.replace('"', '\\"');
        return '<span data-nickhash="' + nickhash + '" ng-nick="' + sender + '"></span>';
    }
    
    function escapecurlybraces(subject) {
      return subject.replace(/{{/g, '{<!---->{').replace(/}}/g, '}<!---->}');
    }

    function getmessagetemplate(message, scope) {
        var content, arr, servers, shouldCompile = true;
        switch(message.type) {
            case MT.Topic:
                content = $filter('linky')(message.content, '_blank');
                shouldCompile = false;
                break;
            case MT.Action:
            case MT.Plain:
                content = $filter('linky')(message.content, '_blank', {'class': 'check-embed'});
                content = $filter('color')(content);
                break;
            case MT.Nick:<commit_msg>Color-code notices as well (#260)<commit_after>/* global angular */
/* global Intl */
/* global $ */

angular.module('quassel')
.directive('input', function ($parse) {
    return {
        restrict: 'E',
        require: '?ngModel',
        link: function (scope, element, attrs) {
            if (attrs.ngModel && attrs.value) {
                $parse(attrs.ngModel).assign(scope, attrs.value);
            }
        }
    };
})
.directive('colorpicker', ['$mirc', function($mirc) {
    return {
        restrict: 'E',
        transclude: true,
        scope: {},
        require: '?colopickerMode',
        template: '<span ng-transclude></span>' +
        '<ul class="colors">' +
            '<li ng-repeat="color in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]">' +
                '<button type="button" class="btn btn-xs mirc-bg-{{color}}" ng-click="setColor(color)"></button>' +
            '</li>' +
        '</ul>',
        link: function (scope, element, attrs) {
            var mode = null;
            if (attrs.colopickerMode == 'foreColor' || attrs.colopickerMode == 'backColor') {
                mode = attrs.colopickerMode;
            } else {
                return;
            }

            scope.setColor = function(colorInd) {
                var color = $mirc.getColorByMIRCInd(colorInd);
                document.execCommand(mode, false, color);
            };
        }
    };
}])
.directive('ircMessage', ['$filter', '$parse', '$compile', '$sanitize', function($filter, $parse, $compile){

    var MT = require('message').Type;
    var dateFormat;
    if (typeof Intl != "undefined" && Intl.DateTimeFormat) {
        dateFormat = new Intl.DateTimeFormat(undefined, {weekday: "long", year: "numeric", month: "long", day: "numeric"});
    } else {
        dateFormat = {
            format: function(date) {
                return date.toDateString();
            }
        };
    }

    function nickplaceholder(sender) {
        var nickhash = $filter('hash')(sender);
        sender = sender.replace('"', '\\"');
        return '<span data-nickhash="' + nickhash + '" ng-nick="' + sender + '"></span>';
    }
    
    function escapecurlybraces(subject) {
      return subject.replace(/{{/g, '{<!---->{').replace(/}}/g, '}<!---->}');
    }

    function getmessagetemplate(message, scope) {
        var content, arr, servers, shouldCompile = true;
        switch(message.type) {
            case MT.Topic:
                content = $filter('linky')(message.content, '_blank');
                shouldCompile = false;
                break;
            case MT.Action:
            case MT.Notice:
            case MT.Plain:
                content = $filter('linky')(message.content, '_blank', {'class': 'check-embed'});
                content = $filter('color')(content);
                break;
            case MT.Nick:
{'fraction_non_alphanumeric': 0.17266949152542374, 'fraction_numerical': 0.00759180790960452, 'mean_word_length': 1.939802802283342, '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': '4214942', 'n_tokens_mistral': 1737, 'n_tokens_neox': 1668, 'n_words': 361}